The Sonar API remains supported. You can migrate one flow at a time. New projects should start on the Agent API to access multi-provider models, built-in tools, and the latest platform features.
Missing a Sonar parameter you rely on? Tell us at api@perplexity.ai — it helps us prioritize what lands on the Agent API next.
Why migrate
The Agent API is Sonar leveled up: the same grounded, real-time web search, now on an endpoint built for agentic work — with any frontier model behind it and every knob exposed. It keeps everything Sonar does well and adds capabilities that are hard to build on top of chat completions:- Same search, more models — Keep the same grounded, real-time web search, now with any frontier model behind it (OpenAI, Anthropic, Google, xAI) alongside Perplexity’s own. Sonar serves only Perplexity’s Sonar models.
- Fully configurable — Set search depth, reasoning, and multi-step behavior with tools and parameters, instead of picking a fixed Sonar tier you can’t tune.
- Transparent, usage-based pricing — Model tokens bill at direct provider rates with no markup, plus a flat fee per tool invocation, so you pay for what you actually use — instead of Sonar’s per-request search fee tiered by search context size. See pricing.
- Agentic by default — The model runs an autonomous agentic loop within a single request: it reasons, calls a tool, observes the result, and repeats until it has enough to answer. It can call built-in tools such as
web_searchandfetch_url, connect remote MCP servers, and run your own custom functions, chaining multiple tool calls without a round trip back to your code. - Better performance — The Agent API produces higher-quality answers than chat completions on the same task.
- Model fallback — Pass a prioritized list of models and let the API serve the first available one, instead of managing failover yourself.
- Typed output items — The response is a typed
outputarray of items (messages, tool calls, and search/tool results) rather than a flatchoicesarray, which better represents multi-step agent behavior. - Future-proof — New models and platform features land on the Agent API first.
Sonar vs Agent API
| Capability | Sonar API | Agent API |
|---|---|---|
| Perplexity Sonar model | ||
| Third-party models (OpenAI, Anthropic, Google, xAI) | ||
| Built-in web search | ||
| People Search | ||
| Finance Search | ||
| Code sandbox | ||
| MCP servers | ||
| Model fallback | ||
| Structured outputs | ||
| Streaming | ||
| Async mode |
messages array and returns a choices array.
The Agent API splits the two: you send an input (a string or an array of input items) and read a typed output array of items — messages, tool calls, and search or tool results — that represents each step the model took.
Sonar
Agent API
choices array with the answer at choices[0].message.content and sources at the top level.
The Agent API returns a typed output array: a message item holds the text (in an output_text content block) and a separate search_results item holds the sources.
Sonar response
Agent API response
Migrating from chat completions
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
Sonar returns achoices array, with the final text at choices[0].message.content.
The Agent API returns a typed output array of items — the answer text lives in a message item’s content block with type: "output_text".
Iterate output and branch on each item’s type to read messages, tool calls, and search or tool results.
Reasoning is surfaced only as response.reasoning.* streaming events — it never appears as an output item.
Sonar
Agent API
Metering usage? The response
usage object is renamed on the Agent API (input_tokens/output_tokens instead of prompt_tokens/completion_tokens, and the search count moves under usage.tool_calls_details). See the API reference for the full schema.Streaming
Sonar streaming returns incremental chunks with adelta.content field on each choice.
The Agent API streams typed server-sent events.
Update stream consumers to branch on each event’s type.
Sonar
Agent API
response.output_text.delta events; tool calls and reasoning arrive as their own events (response.output_item.*, response.reasoning.*), not as text deltas.
4. Web search and citations
web_search runs Perplexity’s own search — the same real-time, grounded web search that was built into Sonar, now exposed as a tool.
In Sonar it was on by default; on the Agent API you turn it on by adding web_search to the request’s tools — until you do, the model answers from its own knowledge without searching (that is why the earlier steps returned ungrounded answers).
The tool also carries the search controls, so Sonar’s top-level search_recency_filter and search_domain_filter move into its filters.
See the Web Search reference for the full set of options.
Sonar
Agent API
Inline citations
Thefast preset cites out of the box — call preset="fast" and the answer comes back with inline [n] markers, like Sonar did.
[n] markers are embedded directly in the answer text (response.output_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.
A preset’s system prompt is tuned by Perplexity and can change over time, and it differs from one preset to another (see Choose a preset and model). To get inline citations consistently — whatever preset or model you use — set the rule yourself in instructions:
5. Choose a preset and model
A preset bundles a model, search config, tools, and reasoning behind one name that Perplexity keeps tuning — sensible defaults out of the box, no wiring required. Migrating a Sonar tier is usually a one-liner: for example,sonar-deep-research maps to preset="medium".
Sonar
Agent API
model, max_steps, custom web_search filters — and everything else keeps the preset’s defaults.
Presets and models are billed by the model and tools a request actually uses. Check pricing and rate limits before cutting over — output is not byte-identical to Sonar.
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
Missing a Sonar parameter 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):| Sonar parameter | Agent API equivalent |
|---|---|
| Domain, recency, and date filters ( search_domain_filter, search_recency_filter, search_*_date_filter, last_updated_*_filter) | Same names, inside the web_search tool’s filters |
web_search_options.search_context_size | search_context_size on the web_search tool, not in filters |
web_search_options.user_location | user_location on the web_search tool, not in filters |
num_search_results | max_results on the web_search tool — a cap on the total number of results |
reasoning_effort | reasoning.effort |
| Sonar parameter | Agent API equivalent |
|---|---|
enable_search_classifier | Provide the web_search tool and let the model decide when to search |
disable_search | Omit the web_search tool. With a preset, the preset’s tools stay enabled — tools: [] does not clear them and there is currently no public way to disable preset tools; max_tool_calls: 0 disables all tool calls as a blunt workaround |
search_mode | web (the default) is implicit. academic has no direct equivalent; use web_search with domain filters and prompting. For sec, use Finance Search for structured finance data or web_search filtered to SEC sources for filing/source retrieval |
search_type (Pro Search) | No direct equivalent — map "fast" to the fast preset (formerly fast-search) and "pro" to preset: "low" (formerly pro-search) for the multi-step Pro Search behavior, or set max_steps on an explicit model to bound multi-step search. There is no "auto" classifier equivalent |
return_related_questions | Prompt the model to end with a few follow-up questions, optionally through a structured output schema |
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.
Multimodal input
| Sonar content part | Agent API |
|---|---|
image_url | input_image content part (data URI or HTTPS URL) |
file_url / pdf_url | No equivalent |
video_url | No equivalent |