Use the migration skill
The fastest path is to let your coding agent do the migration. Open it in the project you want to migrate and send it this:1. Update the endpoint and method
Point requests at/v1/agent and switch from chat.completions.create() to responses.create().
For plain text, the Agent API takes the same role/content items, so the body barely changes: pass the array as input instead of messages and rename the model.
Sonar
Agent API
2. Map messages to input
Sonar takes your prompt as amessages array; the Agent API takes it as input.
For simple single-turn prompts, pass a plain string.
To preserve a system prompt or a multi-turn transcript, pass an array of input items or use the top-level instructions field.
Sonar
Agent API
3. Update output handling
Read the answer text fromresponse.output_text — the drop-in replacement for Sonar’s choices[0].message.content.
When you need more than the answer text (tool calls, search results), iterate the typed output array and branch on each item’s type.
Sonar
Agent API
Streaming
Sonar streaming returns incremental chunks with adelta.content field on each choice.
The Agent API streams typed server-sent events, so update stream consumers to branch on each event’s type.
For the answer text, consume response.output_text.delta events; tool calls and reasoning arrive as their own response.output_item.* and response.reasoning.* events, not as text deltas.
Sonar
Agent API
4. Web search
Perplexity’s own search — the grounded web search that was built into Sonar — is available through theweb_search tool.
In Sonar it was always on; on the Agent API you turn it on by adding web_search to the request’s tools — otherwise the model answers from its own knowledge without searching.
Search controls move onto the tool too, so Sonar’s top-level search_recency_filter and search_domain_filter go into its filters.
See the Web Search reference for the full set of options.
Sonar
Agent API
Inline citations
Sonar returned inline[n] citations by default.
To get the same on the Agent API, tell the model to cite the numbered web search results in its instructions:
[n] markers are embedded directly in the answer text, not in a separate field.
The sources they point to come back separately in an output item with type: "search_results" — read them from its results, each carrying an id, and each [n] marker maps to the result whose id is n.
5. Map Sonar models to presets
Starting points we suggest:sonar → fast, sonar-pro → low, sonar-reasoning-pro → medium, sonar-deep-research → high.
See Presets for details.
Sonar
Agent API
6. Migrate async requests (optional)
Sonar’s async API maps to Agent API background runs: submit withbackground: true and poll the response by id.
See Background Runs for the request shape, polling, reconnect, and the full lifecycle.
Parameter reference
Map the common Sonar parameters to their Agent API equivalents. Some are direct field moves; others are the closest Agent API pattern, and those rows call out the missing 1:1 equivalent.Missing a Sonar behavior you rely on? Tell us at api@perplexity.ai — it helps us prioritize what lands on the Agent API next.
Standard OpenAI parameters
These standard OpenAI parameters carry over unchanged:temperature, top_p, and stream.
A couple of parameters change on the Agent API:
max_tokensis renamed tomax_output_tokens.response_formatkeeps the same shape forjson_schema, and structured outputs are not restricted to specific Perplexity models on the Agent API. Sonar’sresponse_format.type: "regex"has no Agent API equivalent — redesign regex flows around a JSON schema.
Sonar-specific parameters
Direct equivalents (some renamed or relocated):
No direct field — map to a tool or pattern:
No Agent API equivalent — drop these:
search_language_filter.stream_mode— Agent API streaming always emits typed SSE events with reasoning and tool activity as separate events, closest to Sonar’sconcisemode; there is nofull-mode inline-metadata format.- Image results (
return_images,num_images,image_domain_filter,image_format_filter,web_search_options.image_results_enhanced_relevance) — not supported; the Agent API returns noimages. - Video results (
return_videos,num_videos,media_response) — not supported; the Agent API returns novideos.