Perplexity Agent API: How to Add AI Search to Your Own App

Human Verified

Share to: , and

A wide hero shot of a developer at a desk at dusk, laptop screen showing a single clean cited answer panel, a small key resting beside the keyboard, soft window light. No readable text, no logos.

By Faheem R. Khattak | Facts checked 27 November 2026

Perplexity Agent API: How to Add AI Search to Your Own App

You can add live, cited web search to your own app with one API key, one endpoint, and one first call — and the whole thing takes less than an hour to get working. That is the promise of the Perplexity Agent API, and this guide delivers it step by step: get a key, make your first call, pick how deep the research should go, read the citations, understand what each request costs, and handle the limits and errors that every real app hits. Everything here was checked against Perplexity’s own documentation on 27 November 2026, and the code samples follow the docs as they stand today — not the older tutorials that still dominate search results.

One warning before you start, because it is the single most important fact in this guide: if you searched for the “Sonar API”, you are in the right place — but the Sonar API is no longer the product. Perplexity ended support for Sonar Chat Completions on 27 September 2026 and replaced it with the Agent API. The endpoint moved, the request shape changed, and model names were replaced by effort levels. Old synchronous Sonar calls still return answers for now, because Perplexity reformulates them behind the scenes as Agent API requests, but asynchronous Sonar requests are dead, and Perplexity recommends the Agent API for every new project. This guide teaches the Agent API throughout, and its second section explains exactly what happened to Sonar and what to do if your code still calls it. If you follow an older tutorial that teaches POST /v1/sonar with a sonar-pro model, you are following the previous generation. Start here instead.

Two more dated warnings, both about money. First, prices in this guide are as they stood on 27 November 2026, and one of them moves within days of publication: the introductory rates for Gemini 4 Carbon (and Gemini 4 Argon) end on 30 November 2026, three days after this guide was checked. The guide states that date wherever the price appears, so nothing here goes silently stale. Second, the Perplexity API is prepaid and pay-as-you-go — there is no subscription that buys API access, and the sign-up credit some new accounts receive does not unlock the Agent API on its own. You must buy API credits before your first Agent API call. The setup section explains the trap plainly, so your first call works the first time. Checked 27 November 2026.

A wide hero shot of a developer at a desk at dusk, laptop screen showing a single clean cited answer panel, a small key resting beside the keyboard, soft window light. No readable text, no logos.

What the Perplexity API Is in Late 2026: Seven APIs, One Key

<img src="

A developer's desk seen from above with seven small blank cards fanning out from one glowing key, dark theme, teal accents. No readable text.

” alt=”A developer’s desk seen from above with seven small blank cards fanning out from one glowing key, dark theme, teal accents. No readable text.”>

The Perplexity API is not one endpoint and it is not the Perplexity chat app. It is a pay-as-you-go developer platform of seven core APIs, all reached with one API key and one credit balance, according to Perplexity’s quickstart, updated 20 November 2026. You send it a request from your code, and it returns web-grounded results — a generated answer with citations, ranked search results, a model’s raw output, a scheduled web check, a page’s content, embeddings, or a scored decision, depending on which API you called. What it is not is equally important: it is not a chatbot interface, it is not a hosted website, and it does not give you a user interface. You build the front end. The API gives you the search-grounded intelligence; the app around it is yours.

Here is the map, one line per API. The Agent API is the one this guide teaches: send a question, get back a model-generated answer with inline citations, built by a model running web search and other tools. The Search API returns ranked web results as JSON — title, URL, snippet, dates — with no model and no generated answer; your code decides what to keep. The Orchestrator API gives direct access to frontier and open-weight models through the same key, in OpenAI or Anthropic request formats, for plain model access without Perplexity search. The Monitor API runs scheduled web checks: a Search monitor finds results for a query, a Page monitor tracks text changes at known URLs, and an Agent monitor runs an Agent API task on a schedule. The Context API returns the content of web pages you already have URLs for, as Markdown by default. The Embeddings API turns text and images into vectors for semantic search and retrieval. The Decisions API answers yes/no, multiple-choice and scored questions about text or images, with calibrated probabilities.

Three of those seven — Monitor, Orchestrator and Context — arrived only recently, and our report on the Monitor, Orchestrator and Context launches covers what each one added. The Orchestrator API left private preview in November 2026, and the Monitor and Context APIs are new enough that their pricing and limits are still settling — this guide gives their prices in the costs section, from the pricing page updated 24 November 2026, and otherwise stays focused on the Agent API and its Search API contrast.

Why does the seven-API shape matter to a developer choosing where to start? Because the most common mistake is calling the wrong one. If your app needs an answer it can show a user, with sources attached, that is the Agent API. If your app needs raw results it can rank, filter, or feed into its own model, that is the Search API. If your app needs a model and nothing else — no search, no citations — that is the Orchestrator API, and you should not pay for search tool calls you never use. The decision section later in this guide turns that into a table you can apply to your own use case.

One boundary for this guide. It does not re-explain Perplexity the product — what the chat app does, how Search, Pro Search and Research differ, what Free, Pro and Max cost, or what the Comet browser is. That is a different question, and our Perplexity explainer answers it in full, including the Sonar retirement at the top and the API in one section. This guide is the developer surface only: endpoints, code, effort levels, models, citations in output, pricing math, limits, and errors. The two pieces are written to fit together — read the explainer if you want the product context, then come back here to build.

The billing shape is the same across all seven APIs, and it is worth stating once here and once in the setup section: prepaid credits, pay-as-you-go, no subscription required for the API, and a Pro or Max chat subscription does not buy API access. The Agent API bills model tokens at the chosen model’s per-million-token rate plus a fee per tool call. The Search API bills per successful request — $5.00 per 1,000 requests standard, $1.00 per 1,000 with Fast Search — with no token billing at all. There is no per-request fee on the Agent API beyond the tokens and the tool calls. Everything in this guide prices from that shape, and the costs section works two of Perplexity’s own examples to the cent.

What Happened to the Sonar API — and What to Do If Your Code Still Calls It

A road sign at a fork in the road, one old road fading into mist, one new road lit ahead, dusk light. No readable text.

Sonar was Perplexity’s original developer API: a Chat Completions endpoint, POST /v1/sonar, with four models — sonar, sonar-pro, sonar-reasoning-pro and sonar-deep-research. You sent a messages array, named a model, and got back a choices array with the answer, plus citations, search_results, images and related questions. If you built anything on Perplexity’s API before the autumn of 2026, that is almost certainly what you built on — and it is the shape every older tutorial still teaches.

On 27 September 2026, Perplexity ended support for Sonar Chat Completions. The legacy reference page says it plainly: “Sonar Chat Completions has been superseded by the Agent API (POST /v1/agent). This page is kept as a legacy reference.” The replacement is not a renamed endpoint with the same shape. The Agent API is a different request format — the OpenAI Responses format — in which you send an input instead of a messages array, and you choose an effort level instead of a model name. For ranked web results with page text and no generated answer, the replacement is the Search API (POST /search).

What “ended support” precisely means is narrower than “stopped working”, and the distinction decides what you must do this week. Synchronous and streaming Sonar requests still return answers today, because Perplexity is reformulating them behind the scenes as Agent API requests, rolling out gradually by model. Asynchronous Sonar requests are no longer supported at all — there is no reformulation and no support; they must move to background mode in the Agent API. Perplexity recommends the Agent API for every new project. So if your code still calls Sonar synchronously, it probably still works today — but it is running on borrowed time, on a compatibility layer Perplexity has already said it is winding down, and you cannot know when the reformulation finishes rolling out to the model your code names, because Perplexity publishes no per-model status and no completion date. Do not state, and do not assume, that any particular Sonar model has stopped working or that all of them still work. Migrate now, while the old calls still answer and you can compare the new output against the old.

The migration itself is four changes, and Perplexity’s migration guide, updated 12 November 2026, walks each one. First, the endpoint: POST /v1/sonar becomes POST /v1/agent (or its alias POST /v1/responses). Second, the request shape: chat.completions.create() becomes responses.create(); the messages array becomes input — a plain string for a single turn, or an array of input items, or top-level instructions to preserve system prompts and multi-turn behaviour; and max_tokens becomes max_output_tokens. Third, the model choice: model is replaced by effort. Fourth, the response shape: the answer text is response.output_text, a drop-in for Sonar’s choices[0].message.content; for anything more than text, you iterate the typed output array and branch on each item’s type; and sources live in an output item of type search_results, each result carrying an id that the [n] markers in the answer text map to.

The model-to-effort mapping is the part most likely to be wrong in what you read elsewhere, because an earlier version of the migration guide said something different. The current guide, updated 12 November 2026, says:

Old Sonar modelNew effort level
sonarfast
sonar-profast
sonar-reasoning-prolow
sonar-deep-researchhigh

Note the two surprises. Sonar Pro maps to fast, not to a deeper level — the same level as plain Sonar. And Sonar Reasoning Pro maps to low, not to medium. An earlier guide, and an earlier explainer of ours, recorded Sonar Pro as low and Sonar Reasoning Pro as medium; that mapping is superseded. Use the table above. For deep research, the guide points to xhigh as the top level, with no Sonar predecessor.

Streaming changes too. Sonar streamed delta.content chunks per choice. The Agent API streams typed server-sent events: answer text arrives as response.output_text.delta events, while tool calls and reasoning arrive as their own response.output_item.* and response.reasoning.* events. If your streaming code parses Sonar deltas, it will not parse Agent API events; the streaming section of this guide shows the new shape.

Some Sonar parameters have no Agent API equivalent at all, and you need to check your old code for each of them rather than discovering the gap in production. There is no equivalent for search_language_filter; for stream_mode (Agent streaming is always typed server-sent events, closest to Sonar’s concise mode, with no full-mode inline-metadata format); for video results — return_videos, num_videos and media_response, because the Agent API returns no videos; for regex response_format (type: "regex" — redesign around a JSON schema, which is supported and is not restricted to specific models on the Agent API); for web_search_options.image_results_enhanced_relevance; for video_url input; and for academic search_mode (use web_search with domain filters and prompting instead, or Finance Search — or web_search filtered to SEC sources — for SEC work). Other parameters moved rather than vanishing: domain, recency and date filters now live inside the web_search tool’s filters under the same names; num_search_results becomes max_results on web_search; reasoning_effort becomes reasoning.effort; return_related_questions becomes a prompt asking the model to end with follow-up questions, optionally via a structured-output schema; return_images becomes the image_search tool; disable_search becomes omitting the web_search tool — with the caveat that, when you use an effort level, the effort’s tools stay enabled and tools: [] does not clear them, so max_tool_calls: 0 is the blunt workaround that disables all tool calls; search_type “fast” becomes the fast effort level and “pro” becomes the low effort level; web_search_options.search_context_size becomes explicit token budgets (max_tokens, max_tokens_per_page) on web_search; and enable_search_classifier becomes providing web_search and letting the model decide when to search.

Files change shape as well. Sonar’s image_url becomes an input_image content part; file_url and pdf_url become input_file with base64 file_data or an HTTPS file_url. Native input allows 30 active files and 50 MiB combined, where Sonar allowed a per-file allowance; previous_response_id reuses inline documents across calls.

For reference, here is what the old pattern looked like — shown only so you can recognise it in your own code, and labelled as retired. Do not build on it:

# RETIRED — Sonar Chat Completions (support ended 27 Sep 2026)
# Do not use for new work. Migrate to POST /v1/agent (see below).
from openai import OpenAI

client = OpenAI(
    api_key="<token>",
    base_url="https://api.perplexity.ai"
)

response = client.chat.completions.create(
    model="sonar-pro",
    messages=[{"role": "user", "content": "What is the capital of France?"}],
)

That code names an endpoint and a model that Perplexity no longer supports. Its replacement is the first call in the next sections — POST /v1/agent with effort="fast" and an input string. One thing survives of the name “Sonar”: the model perplexity/sonar still exists inside the Agent API, as Perplexity’s own model, at $0.25 per million input tokens and $2.50 per million output tokens — see the models section. The name lives on as a model, not as the API.

Agent API vs Search API: Which One Your App Actually Needs

A split scene: a finished answered letter on one side, a neat stack of raw source pages on the other, answer versus raw results. No readable text.

The two APIs beginners confuse most are the Agent API and the Search API, because both start from a question about the web and both return something with sources. The difference is what comes back and who does the deciding. The Agent API returns a model-generated answer with inline citations: a model runs web search and other tools, reads the results, and writes you an answer. The Search API returns ranked web results as JSON and stops there: no model is called, no answer is written, and your code decides what to keep, what to discard, and what to pass to a model of its own. One gives you an answer; the other gives you the raw material for an answer.

QuestionAgent APISearch API
What comes back?A generated answer with [n] citations, plus a search_results listRanked results: title, URL, snippet, dates — no answer
Is a model called?Yes — the model you pick or the effort level picksNo
How is it billed?Model tokens + a fee per tool call$5.00 per 1,000 requests ($1.00 with Fast Search); no token billing
EndpointPOST /v1/agentPOST /search
Rate limit1–33 requests/sec by usage tier50 query units/sec on every tier
Best forShowing a user a cited answerYour own retrieval, ranking, or RAG pipeline

Use the Agent API when the output of your app is an answer a human reads. A support chatbot that answers “what changed in the new tax rules” with sources. A research assistant that summarises the morning’s news on a topic. A shopping helper that compares two products with prices it found this week. A study app that explains a current event and shows where each claim came from. In all of these, the value is the synthesis — the model did the reading — and the citations are what make the synthesis trustworthy. You pay for the model’s tokens and for each tool call it makes, and the costs section shows how small those numbers are for short answers.

Use the Search API when the output of your app is data your code acts on. Your own retrieval pipeline, where you fetch results, re-rank them with your own logic, and feed the best pages to a model you chose elsewhere. Bulk retrieval, where you need results for hundreds of queries and do not want a model call per query. A monitoring job that checks whether new pages mention a topic. A dataset builder that collects URLs and snippets for later processing. In all of these, a generated answer would be waste — you would be paying model tokens for prose you throw away — and the Search API’s flat per-request price is both cheaper and more predictable. One request with a five-query array is billed once ($0.005 standard, $0.001 Fast Search), so batching queries is a real saving.

Use both when your pipeline has two stages. Search first for retrieval — get the ranked results, apply your own filters, dedupe by URL, keep the ten pages that matter — then call the Agent API with those pages as context, or let the Agent API do its own search and use the Search API results as a cross-check. This is the shape of most serious retrieval-augmented generation (RAG) systems: a cheap, fast retrieval stage, then an expensive, careful generation stage. The Search API section later in this guide covers the retrieval stage in full, including multi-query calls and the Time Machine for searching the web as it was on a past date.

There is a third option, and it is the one to reach for when you want neither an answer nor search results: the Orchestrator API. It gives direct access to frontier and open-weight models through the same key and the same credit balance, in OpenAI Chat Completions, OpenAI Responses, or Anthropic Messages format, billed per token with no per-request fee. If your app needs a model to write code, classify text, or summarise a document you already have — and the web is irrelevant — the Orchestrator API is the right call, and you should not pay Agent API tool fees for searches you never run. Its perplexity/auto routing picks a model per request. One caution, stated exactly as the docs state it: on the Orchestrator API, OpenAI models and most Anthropic models require usage Tier 1, and Opus 5/5.5 and Fable 5/5.1/5.2 require Tier 2, with a request above your tier returning HTTP 402. Whether the same gating applies to the Agent API was not verified in the docs read for this guide, so this guide does not claim it does.

The practical rule is short. If a user reads the output, Agent API. If code reads the output, Search API. If no search is involved at all, Orchestrator API. Pick wrong and you will feel it in the bill or in the output: an Agent API call where a Search API call would do costs model tokens for an answer nobody reads, and a Search API call where an answer was needed hands your user a pile of links instead of a reply.

Getting an API Key and Credits in Under Three Minutes

A hand holding a small brass key over a laptop, a wallet and a prepaid card nearby, access and prepaid billing theme. No readable text or numbers.

Setup is four steps in the browser and one command in your terminal, and Perplexity’s quickstart says the whole thing takes under three minutes. The steps are: create or select your project in the API Console at console.perplexity.ai; open API Keys; click + Generate API Key; and copy the key before you leave the page, because the console shows the full key only once. If you close the page without copying it, the key is gone — you generate a new one. That is the whole ceremony. There is no form, no waitlist, and no approval step for a basic key.

Then comes the step most first-timers miss, and it is the reason this section exists: your project needs API credits. If you only have sign-up credit, open Billing and buy API credits before you call the Agent API or the Orchestrator API. This is the sign-up-credit trap, and it is worth stating in full because it looks like a bug when you hit it. Some new accounts receive a one-time sign-up credit. It expires 60 days after it is added, and API usage draws from it before any credits you purchase — but sign-up credits alone do not unlock the Agent API, the Orchestrator API, or batch creation. Add API credits to your balance to access them. So the sequence is: generate the key, buy credits, then call. If your first Agent API call fails with an access error and you have never bought credits, that is almost certainly why — the key is fine, the balance is the problem.

Keep the billing model separate in your head from the consumer product, because the two have nothing to do with each other. The API is prepaid credits and pay-as-you-go; no subscription is required for the API, and a Pro or Max chat subscription does not buy API access. Our guide to Perplexity’s Free, Pro and Max plans covers what the subscriptions buy — the chat app, not the API. If someone tells you a Pro subscription comes with API access, they are wrong; the pricing page and the quickstart both treat the two as separate billing systems.

Now put the key where your code can read it without ever containing it. Set it as an environment variable — on macOS or Linux, export PERPLEXITY_API_KEY="your_api_key_here" in your shell, or on Windows, setx PERPLEXITY_API_KEY "your_api_key_here" — and confirm it is set without printing it. Both official SDKs read PERPLEXITY_API_KEY automatically, so your code never holds the key as a string. Direct HTTP calls send it as Authorization: Bearer $PERPLEXITY_API_KEY. The key hygiene rules are simple and absolute: never paste a real key into code, into an article, into a screenshot, or into a public repository; never ship a key in client-side code, where anyone can read it from the browser — keys live on your server, behind your own back end; and never commit a .env file that holds one. If a key leaks, generate a new one in the console and retire the old one. The docs do not publish a rotation interval, so this guide states none — rotate when a key has been exposed, when a team member leaves, or when your own policy says so, not on a schedule Perplexity never announced.

One more setup fact, for teams: rate limits and usage tiers are set by cumulative lifetime credit purchases for the organisation, never downgraded once reached. That is covered in full in the limits section, but it matters at setup time because it means the first purchase is not just funding — it is also the first step up the tier ladder. Tier 0, with $0 purchased, already allows 1 Agent API request per second; Tier 1, at $50 of lifetime purchases, allows 3 per second. You do not need to buy your way to a usable tier before your first call. Start small, measure what your app actually spends, and let the tiers follow your usage.

Your First Agent API Call: cURL, Python, and TypeScript

A monitor showing abstract blocks of code with no legible text, a single green checkmark pulse and a small answer card appearing beside it, dark editor theme. No readable text.

The first call is the smallest useful thing the API can do: one question, one answer, with citations. Run it before you build anything else, because it tests your key, your credits, and your network in one shot, and it gives you the response shape you will build everything else on. The question to use is one whose answer changes with the news — something like “What happened in the world today?” or “Who won the most recent match between these two teams?” — because a question with a stable, textbook answer will not prove the search actually ran. If the answer comes back with citations to pages published this week, the search ran. If it comes back with no citations, something is wrong with the call, not with the question.

Start with cURL, straight from Perplexity’s own API reference:

curl --request POST 
  --url https://api.perplexity.ai/v1/agent 
  --header 'Authorization: Bearer <token>' 
  --header 'Content-Type: application/json' 
  --data '{
    "input": "What happened in the world today?",
    "effort": "fast"
  }'

Four things to notice. The URL is https://api.perplexity.ai/v1/agent — the base URL is https://api.perplexity.ai/v1, and the alias POST /v1/responses works too, in the OpenAI Responses format, so OpenAI SDK clients work with the base URL set. The Authorization header carries the key as a Bearer token — replace <token> with your key, or better, with $PERPLEXITY_API_KEY from your environment so the key never appears in your shell history. The body has two fields: input, the question as a plain string, and effort, the depth level — fast here, because this is a single-fact lookup and latency matters most. And input is required, while either model or effort must be present; if you pass a models fallback chain as well, models takes precedence.

Now the same call in Python, with the official SDK. Install it with pip install perplexityai — Python 3.10 or newer — and the client reads your key from the environment:

from perplexity import Perplexity

client = Perplexity()  # Automatically uses PERPLEXITY_API_KEY

response = client.responses.create(
    effort="fast",
    input="What happened in the world today?",
)

print(response.output_text)

Perplexity() with no arguments picks up PERPLEXITY_API_KEY from the environment. client.responses.create(...) is the Responses-format call — the same responses.create() shape the migration guide describes, replacing Sonar’s chat.completions.create(). The effort="fast" argument picks the depth level, and response.output_text is the answer text — the drop-in for Sonar’s choices[0].message.content. That is the whole first program: four lines of real code, and it prints a cited answer.

The TypeScript equivalent uses the official SDK, installed with npm install @perplexity-ai/perplexity_ai — Node.js 20 or newer — and follows the same shape:

import { Perplexity } from "@perplexity-ai/perplexity_ai";

const client = new Perplexity(); // Automatically uses PERPLEXITY_API_KEY

const response = await client.responses.create({
  effort: "fast",
  input: "What happened in the world today?",
});

console.log(response.output_text);

Same call, same fields, same answer. The SDKs cover the Agent API, Search, Embeddings, Decisions, Monitor, batches, files, skills and models, plus the legacy Sonar API — so once this call works, the rest of the platform is the same client with different methods. If you would rather skip the SDK entirely, the cURL call above is the whole API: every SDK method is a wrapper around the same HTTP request.

Look at what comes back before you move on, because the shape of the response is the shape of everything that follows. A successful response is a JSON object with an id, a status of completed, the model that actually served the request, an effort field naming the level and version that ran (for example fast@2026-10-16.0 — send that value back as effort to run the same configuration again), and an output array. Inside output there are typed items: a message item whose content holds the answer text, and a search_results item holding the sources, each with an id — and the [n] markers in the answer text map to the result whose id is n. There is also a usage block with input_tokens, output_tokens, total_tokens, and a cost object with input_cost, output_cost, total_cost, cache costs, and tool_calls_cost — the exact amount this one request cost you, in dollars. Read that block after your first call. It is the cheapest possible lesson in what your app will spend.

If the first call fails, the error section of this guide maps the common failures — a 400 for a bad effort name or version, a 429 for rate limits, an access error when credits are missing — but the most likely cause is the simplest: the key was not set in the environment, or the credits were never bought. Check those two first. The Responses format will be familiar if you have used OpenAI’s API, and our guide to the OpenAI API covers that shape in full; the sibling tutorial for another vendor’s API, our guide to building your first app with the Gemini API, shows the same “first call, then streaming, then tools” pattern applied elsewhere, if you want a second example of the shape before you commit to this one.

Effort Levels Explained: fast, low, medium, high, xhigh, ultra

Six ascending steps from a quick single step to a tall staircase, depth versus speed metaphor, calm blue gradient. No text or numbers.

Effort levels are the new model picker — and they are the single biggest conceptual change from Sonar. Under Sonar you named a model: sonar for quick answers, sonar-deep-research for deep ones. Under the Agent API you name an effort level — fast, low, medium, high, xhigh or ultra — and Perplexity supplies the bundle behind it: a model, a search configuration, a number of reasoning steps, a system prompt, and a set of tools. You pick how deep the work should go; Perplexity picks the machinery. That is the whole idea, and it is why the migration guide replaces model with effort rather than with a new model name.

Effort levelGood atUse when
fastSingle-fact lookups, definitions, quick summaries with inline citationsThe answer is one fact or a short summary; latency matters most; no multi-step research is needed
lowEveryday research, light multi-step lookups with current information and inline citationsA query needs current information with light research and tool use
mediumMulti-hop browsing, wide aggregation across many sources, inline citationsA question requires chaining evidence across many sources over several rounds
highExpert-level reasoning, exhaustive source coverage, inline citationsYou need deep, source-heavy research without code execution, where completeness matters more than latency
xhighOpen-ended agentic work: code in a sandbox, long tool-use loops, many sources at onceA task is open-ended rather than a single question — it runs code, orchestrates tool use, builds a result step by step
ultraBroad research and data-gathering where coverage matters mostYou want the most complete result and can accept long runs

That table is Perplexity’s own, from the Effort page updated 19 November 2026, and it is the decision tool. Start at the top and stop at the first level that can actually answer the question. A one-fact lookup is fast. A question about today’s news with a little digging is low. A question that needs evidence chained across several sources is medium. A literature-style sweep is high. A task that needs code run in a sandbox is xhigh. A broad data-gathering job where you want the most complete result and can wait is ultra. The most common beginner error is starting at high for everything, because it feels safer. It is not safer — it is slower and more expensive, and for a one-fact question it buys nothing. The cheapest level that answers correctly is the right level, and the way to find it is to test: run the same question at fast and at low, compare the answers, and only move up when the cheaper level gets it wrong or leaves sources out.

There are three ways to use an effort level, and the choice is about stability versus freshness. Dynamic — call the level by name, effort="low" — is the recommended default: Perplexity updates the underlying configuration as its evaluations show improvements, and your application picks those improvements up automatically with no code changes. Pinned — call it with a version, effort="fast@2026-10-16.0" — keeps running one released configuration after the level moves on; use it where stability is required, for example in a production feature whose output you have tested. Frozen — copy the level’s current public values (model, tools, system prompt, parameters) into your request and omit effort — insulates you from future updates, but a few settings live outside the documented request schema, so the docs say to pin a version if you need the complete configuration. You can mix them: dynamic in most environments, pinned where stability is required. The response tells you which version ran, in its effort field — send that value back to pin exactly what you just ran.

Two warnings about the machinery behind the levels, both dated. First, the models behind the levels move, and they moved recently. The 2026-11-11.0 versions of all six levels omit max_output_tokens, so each generation gets up to 128,000 output tokens, capped by the model’s supported limit. But the changelog records that xhigh now selects xhigh@2026-11-18.0, which uses openai/gpt-6.2-sol with no fallback model, replacing Claude Opus 5.5 and its GPT-6.1 Sol fallback — tools, high reasoning effort, the 300-step limit and context compaction settings unchanged. Earlier pinned versions are unchanged. And ultra (ultra@2026-11-05.0) runs on anthropic/claude-opus-5-5 and has no frozen configuration; call it by name or pin the returned version. This guide re-checked the live Effort page at draft time, 27 November 2026: the page still carries the 19 November update date and the 2026-11-11.0 note, and the per-level current-value blocks did not render in full in that check, so the step counts below are the 2026-11-11.0 version values as recorded in Perplexity’s own documentation — fast 1 step, low 5 steps, medium 15 steps, high 40 steps, xhigh 300 steps — and the live Effort page is the authority if they have moved since. That churn is the point: do not hard-code a model behind an effort level into your product decisions, and pin a version in production.

Second, Perplexity promises that when it updates an effort level it aims to keep the same cost and latency band — the model may change, but updates are tuned to stay close to the current per-request cost, and step counts and tool budgets are kept close to their current values. Quality is the dimension updates optimise for. That promise is what makes the dynamic form safe to use: the level you call today should cost roughly what it costs after the next update, even if the model behind it changes. It is also why the effort level, not the model, is the right thing to put in your code — you are buying a cost and latency band with a quality target, and Perplexity manages the machinery inside it.

A few mechanics worth knowing. Any field you pass alongside an effort level overrides that default — but tools is the exception: tools merge per tool instead of replacing the whole set, so listing one tool overrides only that tool’s options and leaves the effort level’s other tools enabled. You cannot disable an effort level’s tools by passing tools: []; max_tool_calls: 0 is the blunt workaround that disables all tool calls. Dynamic effort levels automatically use a stable prompt_cache_key for their shared prompt prefix (system prompt and tool definitions), which improves prompt-cache reuse across independent requests that use the same level; you do not need to set the key yourself, and an explicit request-level prompt_cache_key overrides the default. And an unknown effort name, an unknown version, or a malformed value returns HTTP 400 — so a typo in effort fails loudly, which is better than failing silently with the wrong depth. For readers new to multi-step tool use, our guide to AI agents explains what an agent loop is — the model searching, reading, searching again — which is exactly what the deeper effort levels are doing under the hood.

Choosing a Model — or Letting the Effort Level Choose

A row of distinct tools laid out on a workbench, a wrench, a scalpel, a hammer and a lens, different models for different jobs. No brand marks, no text.

You have two ways to pick the brain behind a request: let the effort level choose, or name a model directly. The effort level is the default and the right choice for most apps — it bundles the model with the search config, the step budget, the system prompt and the tools, and it keeps the cost and latency band stable as Perplexity updates the machinery. Name a model directly only when you have a reason: you need a specific model’s behaviour, you are benchmarking, or you are building a feature whose output you have validated against one model and want to hold fixed. When you name a model, you take on the choices the effort level was making for you — including the step budget, which defaults to 1 when a model is named directly, so a research loop that needs several steps needs max_steps set explicitly.

Models are named in provider/model format: openai/gpt-6.2-sol, anthropic/claude-opus-5-5, perplexity/sonar. The catalogue spans OpenAI, Anthropic, Google, xAI, Z.AI, DeepSeek, Moonshot AI, NVIDIA and Perplexity, according to the pricing page. You can also pass a fallback chain of up to five models in models — tried in order until one succeeds, with response.model reflecting the model that actually served the request. That chain is your cheapest insurance against a model being unavailable or overloaded: list your preferred model first, a cheaper or more available one second, and let the API fall through.

The rates below are the ones this guide could verify first-hand on Perplexity’s own pages on 27 November 2026 — from the changelog and the pricing page, both primary sources — with one exception: the perplexity/sonar rate is carried from our primary read of the Models reference on 15 November 2026 (see the note on that row), because the rate table did not render in today’s check either. The full rate table on the Agent API Models reference page did not render in today’s check, so the rates for the rest of the catalogue are not listed here rather than guessed: check the live Models reference page before you commit to a model, because model rates change and the page is the authority. Every price is per one million tokens, and every price below is as it stood on 27 November 2026, except perplexity/sonar, which is as it stood on 15 November 2026 — re-verify it on the live Models reference before relying on it.

ModelInput / 1M tokensCached input / 1MOutput / 1MNote
perplexity/sonar$0.25$0.0625$2.50Perplexity’s own model, inside the Agent API; the cheapest Perplexity-native option; rate carried from our 15 November 2026 read (see Sources)
openai/gpt-6.2-sol$2.00 ($4.00 above 272K input)$0.10$10.00 ($15.00 above 272K)Now the model behind xhigh; default-processing rates
openai/gpt-6.2-astra$8.00 ($16.00 above 272K input)$0.40$40.00 ($60.00 above 272K)Frontier tier; default-processing rates
google/gemini-4-neon$3.00$0.15$15.00Frontier intelligence, fast end-to-end completion
google/gemini-4-hydrogen$1.50$0.075$7.50Everyday coding and agentic work
google/gemini-4-carbon$2.00$0.10$10.00Introductory rate through 30 Nov 2026 — check the live page after that date
google/gemini-3.7-flash / 3.8-flash$0.75$0.075$3.75Current rates apply through 31 Dec 2026

Three facts in that table do most of the work. First, perplexity/sonar is the cheapest Perplexity-native option in the table by a wide margin — $0.25 in and $2.50 out — which makes it the natural default when you name a model directly for short, cited answers and want the bill to stay small. Second, the OpenAI models carry a price step at 272,000 input tokens: above that threshold, input and cache-read prices double and output prices rise by 50% — so a very long context costs more per token than a short one, and the threshold is the first thing to check if your app sends long documents. Third, two of the prices are already scheduled to move: Gemini 4 Carbon’s introductory $2.00/$10.00 ends on 30 November 2026, three days after this guide was checked, and the Gemini 3.7/3.8 Flash rates apply only through 31 December 2026. If you are reading this after either date, the live pricing page — not this table — is the price.

Service tiers scale the token rates on models that list them: flex multiplies by 0.5× and priority by 2×. Flex is the way to halve the token bill on work that can wait; priority is the way to pay double for faster handling. Check whether the model you chose lists the tiers before you rely on either.

How do you actually choose? Use the decision framework in our guide to choosing an AI model — speed, cost and reasoning depth, applied to your own workload — but the short version for this API is: start with an effort level, not a model, and let Perplexity manage the machinery; name a model only when you have measured a reason to. If you do name one, the catalogue’s families are covered in depth elsewhere on this site: our guide to Claude’s models covers the Sonnet, Opus and Haiku models that appear behind xhigh and ultra, and our DeepSeek explainer covers the DeepSeek models that sit in the catalogue via Perplexity hosting. And one rule that saves more money than any model choice: the cheapest model is not always the cheapest request, because tool calls dominate short answers — a $0.0025 web search is more than the tokens in a one-sentence answer on almost any model. The costs section proves that with Perplexity’s own arithmetic.

Citations in Your App: Reading search_results and Rendering [n] Markers

A magnifying glass over a paragraph with small numbered markers, source documents fanned behind on a tablet, verification theme. No readable text.

Citations are the reason to use this API instead of a plain model, and they are also the part most apps get wrong. The mechanism is simple once you see it, and it is worth learning exactly, because a citation rendered wrong is worse than no citation at all — it tells your user a source says something it does not.

Agent API answers carry inline [n] markers embedded in the answer text itself — not in a separate field. The sources come back separately, in an output item of type search_results, and each result carries an id. Each [n] marker maps to the result whose id is n. That is the whole mapping: read the answer text, find the markers, look up each number in the search_results list, and render the matching source under the answer. The response JSON from the Models reference page shows the shape in practice: a search_results item holding a results array — each entry with an id, a title, a url, a snippet, a date and a last_updated — followed by a message item whose text carries markers like [web:1][web:2] in the worked example. The marker format in rendered text is the plain [n] form; the web:n form appears in the raw example output. Either way, the number is the key, and the search_results list is the lookup table.

To render a source list under an answer, the pattern is: take response.output_text for the text; walk the output array for the item whose type is search_results; collect its results into a map from id to {title, url}; then, for each [n] in the text, link the marker to the matching source and list the sources — title and URL, in the order they first appear — beneath the answer. In code, the shape is:

response = client.responses.create(
    effort="low",
    input="What did the central bank decide this week?",
)

answer = response.output_text

sources = {}
for item in response.output:
    if item.type == "search_results":
        for result in item.results:
            sources[result.id] = result

# Render the answer, then list sources[1], sources[2], ...
# in the order their [n] markers first appear.

That snippet follows the response shape the API reference documents — a typed output array, a search_results item, results with id fields — and the marker mapping the migration guide states. If your SDK version surfaces the output items differently, the mapping is the same: the number in the text is the id in the results list.

Two things make citations reliable rather than decorative. First, make the requirement explicit. The [n] markers are embedded in the answer text by default, but if you want numbered citations to be explicit and complete, override the effort level’s default instructions — for example, instruct the model to cite every factual claim with a numbered marker and to end with a source list. instructions is a system instruction for the model, and it is the lever for citation discipline, just as it is for tone, format and language. Second, check the sources yourself before you trust the answer. A citation proves that a source exists and that the model looked at it; it does not prove the source is right, current, or saying what the answer claims it says. Open the link. Read the date. That discipline is what separates a cited answer from a sourced one, and the method for testing citation quality — checking each claim against its source — is covered in depth in the citation section of our Perplexity explainer; this guide does not re-litigate it, but it points to it because it is the other half of this section.

There is one more distinction, for the Search API side of the same question: a Search API snippet is query-relevant text extracted from the page, not the full page — the same page can return different text for different queries. Do not present a snippet as a quotation from the page, and do not treat it as the page’s content. It is an extract chosen for your query. If your app needs the full page, that is the Context API’s job — it returns the page’s content as Markdown — not the Search API’s. And for readers thinking about the other side of citations — how content gets cited by AI answer engines in the first place — our guide to generative engine optimisation covers the mechanics from the publisher’s side.

The Search API: Raw Ranked Results Without an Answer

A library card-catalogue drawer pulled open with neat index cards, a search beam across them, raw ranked results metaphor, warm light. No readable text.

The Search API is the quieter half of the platform, and the one that experienced developers end up using most. It is POST https://api.perplexity.ai/search, and it does exactly one thing: it returns ranked web results as JSON. No model is called, no answer is written, and there is no token billing. Your code decides what to keep, what to discard, and what to pass to a model — yours, or the Agent API’s, or another vendor’s entirely.

The response fields are few and precise. Each result has a title (always present), a url (always present), a snippet — query-relevant text extracted from the page, not the full page — a date (the publication date in YYYY-MM-DD form, omitted when unknown), a last_updated date, and the request carries an id. Results are ordered best match first. Read date with a fallback — result.date or "unknown" in Python — because a missing date is normal, not an error, and an app that crashes on it will crash often.

The controls are: query, one query or an array of up to five; each query is 1–8,192 bytes of UTF-8. max_results, from 1 to 20, default 10 — and it caps the combined results list across all queries, not each query, so raise it for multi-query calls and dedupe the combined list by URL. search_type: web (the default, 1–20 results), fast (lower latency, 1–20), or people (professionals, employees and public figures, 1–50 results). Domain, language, date and country filters narrow the results, and there is a multi-query mode: one request can carry up to five queries, and it is billed once — $0.005 standard, $0.001 Fast Search — even though it consumes one rate-limit unit per query.

curl --request POST 
  --url https://api.perplexity.ai/search 
  --header 'Authorization: Bearer <token>' 
  --header 'Content-Type: application/json' 
  --data '{
    "query": ["electric vehicle sales 2026", "EV battery prices 2026"],
    "max_results": 10,
    "search_type": "web"
  }'

In the SDKs, the call is client.search.create() in both Python and TypeScript. The pattern to build on is: send the queries, get the ranked results, dedupe by URL, keep the ones whose dates are fresh enough for your purpose, and then decide — show the list to the user, feed the best pages to a model, or store the URLs for later. The Search API is at its best when your app adds value between the search and the answer: your own ranking, your own filters, your own domain knowledge about which sources to trust. If your app adds nothing between the two, call the Agent API instead and let the model do the reading.

One feature deserves its own paragraph, because it is new and because it changes what “search” can mean: the Time Machine. The Search API and the Context API accept snapshot_as_of — a cutoff up to 365 days in the past, as an RFC 3339 time with a time zone, for example 2026-11-01T00:00:00Z. A Search result then comes from the copy of the page Perplexity saved at or before that time; a page with no copy from that time returns status.type: "no_content". The Agent API’s web_search and fetch_url tools accept the same value inside filters. The use cases are concrete: answer a question as the web stood on a past date, reproduce a result from a known point in time, or check what a page said before it was edited. The limits are tight — Time Machine is 1 request per second at Tier 0, and 50 requests in total at Tiers 1–5, after which retrying does not help — so it is a precision tool, not a bulk one. And one limitation to know: POST /search takes queries, not URLs, and has no parameter to fetch a page live or control cache age. For fetching known URLs, use the Context API.

When does Search beat Agent? When your app owns the retrieval: your own RAG pipeline, your own ranking, bulk retrieval across many queries, or a monitoring job that only needs to know whether new results exist. The Search API’s rate limit is generous — 50 query units per second, burst 50, on every tier — and its billing is flat and predictable. When does Agent beat Search? Whenever a human reads the output. The two are not rivals; they are the two stages of the same pipeline, and the strongest apps use both.

What a Request Costs: Tokens, Tools, and Worked Examples

A simple balance scale with small coins on one side and a tiny search globe on the other, tokens-plus-tools billing metaphor. No numbers or readable text.

Every Agent API request has two bills, and understanding that is the whole of Perplexity pricing. The first bill is model tokens: what you send in, at the chosen model’s per-million-token input rate, and what the model generates, at its output rate — including reasoning tokens, which are billed at the output rate, and including the tokens of any helper models inside tools, such as the extraction model inside fetch_url, which all count toward the requested model’s budget. The second bill is tool calls: a fee per invocation of each tool the model uses. There is no per-request fee. The Search API, by contrast, has one bill only: per successful request, with no token billing at all.

The tool fees, from the pricing page updated 24 November 2026, are:

ToolPrice
web_search (standard)$0.0025 per invocation ($2.50 per 1,000)
web_search (Fast Search, search_type: "fast")$0.001 per invocation ($1.00 per 1,000)
image_search$0.0025 per successful invocation
fetch_url$0.0005 per invocation (plus the extraction model’s tokens if the tool uses a model to extract content)
people_search$0.005 per invocation ($5 per 1,000)
finance_search$0.005 per invocation ($5 per 1,000)
sandbox$0.03 per started 20-minute block (a billing unit, not a runtime cap; measured from container start through its last command)
sandbox SDK web search$0.001 per invocation

Now the arithmetic, using Perplexity’s own worked examples from the pricing page — not invented ones. Example one, an Agent API web search: openai/gpt-5.6-terra, 500 fresh input tokens plus 200 output tokens plus one standard web search. Input tokens $0.001, output tokens $0.0024, web search $0.0025 — $0.0059 total. Note that the example names GPT-5.6 Terra; model names in examples can lag the catalogue, so quote it as Perplexity’s own example, not as a current recommendation. Example two, an Agent API research call at the low effort level: openai/gpt-6-luna, 2,000 fresh input tokens plus 1,000 output tokens plus one Fast Search plus one fetch. Model input $0.0002, model output $0.0005, Fast Search $0.001, fetch $0.0005 — $0.0022 total. Perplexity’s own note under the examples: “Actual effort level costs vary with the model, token usage, and tool calls. When present, usage.cost.total_cost reports an estimate. Check Billing in the API Console for charged amounts.”

The lesson in both examples is the same, and it is the most useful pricing fact in this guide: for short answers, the tool calls are a large share of the bill — sometimes the larger share. In example one, the single web search ($0.0025) is over 40% of the $0.0059 total, nearly as much as the input and output tokens combined ($0.0034). In example two, the Fast Search plus the fetch ($0.0015) cost more than twice the model tokens ($0.0007). That is why the cheapest model is not always the cheapest request, and why the effort level matters more than the model name for cost — a deeper effort level runs more searches, more fetches, and more steps, and each of those is billed. A fast call that searches once is a fraction of a cent; an xhigh run that searches dozens of times and runs code in a sandbox for an hour is dollars. Both are correct prices for what they do. The mistake is paying the second price for the first job.

How do you read what a request actually cost? The usage.cost object on every response reports input_cost, output_cost, total_cost, cache creation and cache read costs, and tool_calls_cost with a per-tool breakdown in tool_calls_cost_details. Log it. It is an estimate — the console’s Billing page is the charged amount — but it is the fastest way to learn what your app actually spends per feature, and to catch the moment a feature starts searching ten times per answer instead of once.

The other five APIs price separately, and the figures are small enough to state in one paragraph each. The Search API is $5.00 per 1,000 successful requests standard, $1.00 per 1,000 with Fast Search. The Monitor API is $0.001 per succeeded Search run, $0.001 per counted fetched URL in a succeeded Page run, and Agent runs bill as Agent API usage with no separate Monitor fee; failed and skipped runs are free. The Context API is $1.00 per 1,000 fetched URLs, with a failed URL free, and criteria scoring billed as Decisions API input tokens on top. The Embeddings API runs from $0.004 per million tokens for the standard 0.6b model to $0.12 per million for the contextualised v2 9b model — Perplexity’s own example is 40 million tokens on the contextualised v1 4b model at $0.05 per million, which is $2.00. The Decisions API is $0.02 per million input tokens for the v1.3 decider and $0.01 for the flash version, with output tokens free and no per-request fee; web grounding runs one Fast Search per question, up to 100, at $0.001 each, so at most $0.10 in searches per request, plus $0.0005 per successful URL fetch.

Two dated warnings close this section, and both are already in the models table. Gemini 4 Carbon’s introductory rate — $2.00 in, $0.10 cached, $10.00 out per million tokens — applies through 30 November 2026. After that date, check the live pricing page; this guide does not state the post-introductory rate, because Perplexity had not published the new figure in the pages read on 27 November 2026. Gemini 3.7 Flash and 3.8 Flash at $0.75/$0.075/$3.75 apply through 31 December 2026. All prices in this guide were checked 27 November 2026: re-verify on the live pricing page before you commit to a model for a production app, because Perplexity’s prices move on announced dates and the docs always carry the current figure.

Rate Limits, Usage Tiers, and Surviving a 429

A narrow gate with a patient queue of small glowing orbs passing through one at a time, a clock face blurred above, throttling metaphor. No readable text.

Rate limits are the part of the API that bites hardest in production and least in testing, because a demo makes one call at a time and a real app makes many. Perplexity’s limits have two dimensions, and a request must pass both: a request limit (requests per second, shared across all models and all API keys in the organisation) and token limits (tokens per minute and per hour, per organisation and per model — traffic on one model does not use another model’s budget). You can get a 429 while well under the request limit if a token budget is exhausted, and a request rejected for token budget still counts one request against the request limit, so tight retry loops on token 429s can trip the request limit too. Respect both, or you will chase the wrong one.

The tiers are set by cumulative lifetime credit purchases — not your current balance — and once reached, a tier is kept permanently, with no downgrade. That permanence is generous: a tier you earn in a busy month stays earned in a quiet one.

TierTotal credits purchasedAgent API requests/secAgent API tokens/min (per model)Agent API tokens/hour (per model)
Tier 0$015,000,000300,000,000
Tier 1$50+36,000,000360,000,000
Tier 2$250+88,000,000480,000,000
Tier 3$500+1710,000,000600,000,000
Tier 4$1,000+3313,000,000780,000,000
Tier 5$5,000+3316,000,000960,000,000

Read that table with the right sense of scale. The token budgets are enormous — five million tokens a minute at Tier 0 — because they are per model, and a single app’s traffic on one model rarely approaches them. The request limit is the binding one for most apps: 1 request per second at Tier 0, 3 at Tier 1, 8 at Tier 2, 17 at Tier 3, 33 at Tiers 4 and 5. If your app serves ten users at once and each user triggers one Agent API call, Tier 0 will 429 you. The fix is not cleverer code — it is a queue on your side, a higher tier from lifetime purchases, or both. And remember what counts against the request limit: every Agent API call — POST /v1/agent, GET /v1/agent/{id} polls, cancel, resume, and file downloads, on both /v1/agent and /v1/responses. Polling is not free: at 1 request per second, polling once a second leaves no room for new requests. Poll with backoff, or use streaming with reconnect instead.

When you do hit a 429, the response tells you which limit you hit, in its error.type field. There are three values, and each has its own remedy. request_rate_limit_exceeded means you exceeded the request rate: wait the Retry-After interval — normally 1 second — then retry. token_rate_limit_exceeded means you exceeded a token budget: wait Retry-After, and retry with backoff; the error message names the window, per-minute or per-hour. overloaded is not a rate limit at all — it is upstream model capacity: retry with backoff, or use the models fallback list to try another model. A 429 carries a Retry-After header but no x-ratelimit-* headers; successful responses that went through rate limiting include x-ratelimit-limit, x-ratelimit-remaining, x-ratelimit-used and x-ratelimit-reset (in Unix seconds). Read them. They are the API telling you how much room you have left.

Two behaviours surprise developers and are worth knowing before you meet them in production. First, pauses are not errors. While a request runs, tokens are not reserved; if the budget runs out mid-run, the request pauses before its next turn and resumes automatically. Do not resubmit a paused request — you will pay twice for the same work. Streaming can surface this with stream_options.include_token_pause_events: true, which yields response.paused and response.resumed events, with keepalive comments every 15 seconds while paused. Non-streaming requests cannot report a pause — it appears only as added latency — and the API holds a non-streaming connection for at most 30 minutes; a request the client abandons is cancelled server-side even while paused. Use background: true for work that must survive a client timeout. Second, token counting includes all input tokens (uncached, cached, and cache write) and all output tokens including reasoning tokens, and a request can make several model calls while using tools — including helper models inside tools such as fetch_url extraction — all of which count toward the requested model’s budget. If models is set, the budget is the first entry’s; if only an effort level is named, usage counts against a budget keyed on the effort level name.

The other APIs have their own limits, stated briefly. The Search API allows 50 query units per second, burst 50, on every tier — a multi-query request consumes one unit per query. Embeddings allow 85 requests per second at Tier 0, 170 at Tiers 1–3, and 335 at Tiers 4–5, with contextualised embeddings five times higher. The Context API allows 1, 3, or 5 requests per second and 10, 15, or 25 URLs per request by tier, with no request carrying more than 50 URLs. The Time Machine limits are the tightest on the platform — 1 request per second at Tier 0, and 50 requests in total at Tiers 1–5 — and after all 50 are used, retrying does not help.

Streaming, Background Runs, and Long Research Jobs

A river splitting into a live stream and a still reservoir, both flowing to the same destination, streaming versus background jobs, dusk blue. No text.

Your first call waits for the whole answer before it returns anything. For a short answer on fast, that is fine — the wait is a second or two. For a long research job on high, xhigh or ultra, it is not: the user stares at a blank screen for minutes, wonders if the app crashed, and clicks away — or your HTTP client times out and the work is lost. Streaming and background mode are the two answers, and they solve different halves of the problem. Streaming fixes the experience: the answer arrives piece by piece as it is generated. Background mode fixes the durability: the job runs on Perplexity’s side and survives a dropped connection. Use streaming when the user is watching; use background when the job must finish whether or not anyone is watching.

Streaming is one argument: set stream to true on the call, and the API answers with server-sent events instead of a single JSON object. The events are typed, and the types are the shape to learn. Answer text arrives as response.output_text.delta events — your app appends each delta’s text to what the user sees. Tool calls and reasoning arrive as their own response.output_item.* and response.reasoning.* events, so you can show “searching the web…” while the model searches, instead of showing nothing. The stream ends with a response.completed event carrying the full response object. In the SDKs, the pattern is:

stream = client.responses.create(
    effort="low",
    input="Summarise the morning's technology news.",
    stream=True,
)

for event in stream:
    print(event)

In Python the loop is for event in stream; in JavaScript it is for await (const event of stream). The docs’ own guidance is to print only the text deltas in a first app and ignore the rest — the event sequence is there when you need it, and the quickstart’s streaming examples show the first events, the text deltas, and the final event. Over cURL, streaming is a "stream": true field in the JSON body, and the server answers with a stream of server-sent events. One practical note from the docs: if you test streaming from the command line, use --no-buffer with curl, or curl will wait and collect the output before showing it — which defeats the entire purpose of streaming. And streaming does not change what you pay: the same tokens are generated and billed whether they arrive all at once or piece by piece. It changes only the experience.

Background mode is a different argument with a different shape. Set background: true, and with stream: false the request returns immediately with status: "queued" instead of waiting for the answer. You then poll GET /v1/responses/{id} until the response reaches a terminal status — completed, failed, incomplete or cancelled. Background runs are durable: you can stream them and reconnect after a drop, and a request the client abandons is not the same as a background run you stop polling — the run continues server-side. That durability is the reason to use background mode for anything long: a research job on ultra that runs for many minutes, a batch of questions your app fires off and collects later, or any job where the client’s own timeout is shorter than the model’s work. Remember the two limits from the rate-limits section: polling counts against your requests-per-second budget, so poll with backoff — and at 1 request per second, polling once a second leaves no room for new requests — and a non-streaming request’s connection is held for at most 30 minutes, so a job that might run longer belongs in background mode, not in a held connection.

When to use which, in one paragraph. Stream when a user is waiting on the answer and the job is short enough that a held connection is safe — a chat reply, a summary, a quick research question. Go background when the job is long, when the user has navigated away, when you are running many jobs and collecting results later, or when the effort level is xhigh or ultra and the run may take many minutes. Use ultra itself only for broad research and data-gathering where coverage matters most and long runs are acceptable — it is the deepest level on the platform, and it is slow by design. And the two dials that control how long and how large a job gets are max_steps — the maximum research-loop steps, from 1 to 500, defaulting to 1 when a model is named directly, and at least 3 when using finance_search with a direct model — and max_output_tokens, the total output-token budget across the run, which you only need to set when you want a cap, because each generation can otherwise produce up to 128,000 output tokens. Turn max_steps up when the agent gives up too early; turn max_output_tokens down when the answers are longer than your app needs. For readers new to the agent loop itself — the model searching, reading, searching again — our guide to AI agents explains the loop in plain language, and it is the same loop running inside every background job in this section.

Errors, Edge Cases, and Production Hardening

A sturdy vault door with layered locks and a shield motif on a server rack, production hardening theme, muted tones. No readable text.

A demo that assumes every call completes is a demo that will break in production. The API’s errors are few and well documented, and the hardening is mostly discipline: validate before you trust, retry only what is retryable, keep keys on the server, and check your old code against the dropped-parameter list before you migrate.

ErrorWhat it meansWhat to do
HTTP 400, bad effort or versionUnknown effort level name, unknown version, or malformed effort valueCheck the spelling and the version; use the effort value from a previous response to pin a known version
HTTP 400, otherBad request — for example, neither model nor effort supplied, or an invalid parameterFix the request; never retry a 400 unchanged
HTTP 402On the Orchestrator API, the requested model is above your usage tierBuy credits to reach the tier, or pick a model your tier allows; do not claim this gating applies to the Agent API — it was not verified there
HTTP 429 request_rate_limit_exceededRequest rate exceededWait Retry-After (normally 1 second), then retry
HTTP 429 token_rate_limit_exceededToken budget (per minute or per hour) exhaustedWait Retry-After; retry with backoff; the message names the window
HTTP 429 overloadedUpstream model capacity, not a rate limitRetry with backoff, or fall through the models fallback list to another model

Three retry rules cover almost everything. Retry 429s, with backoff and with the Retry-After interval respected — never in a tight loop, because a rejected request still counts against the request limit. Retry transient server errors the same way. Never retry a 400, a 401, or a 403 unchanged: those are your bug, your key, or your account, and retrying them wastes requests and can trip the request limit on top of the original failure. And never resubmit a request that paused for token budget — it resumes automatically, and resubmitting pays twice.

Then the migration checklist, for anyone moving old Sonar code. Walk your codebase for each parameter with no Agent API equivalent — search_language_filter, stream_mode, return_videos, num_videos, media_response, regex response_format, web_search_options.image_results_enhanced_relevance, video_url, academic search_mode — and redesign each one rather than passing it through and hoping. Regex structured output is gone; JSON schema structured output is the replacement, supported on the Agent API and not restricted to specific models. Check the file limits too: native input allows 30 active files and 50 MiB combined, and the docs do not publish a list of accepted file types for input_file in the pages read for this guide, so do not assume a format is accepted — test it. Check the effort-level tools behaviour: tools: [] does not disable an effort level’s tools, and max_tool_calls: 0 is the blunt workaround. And check your streaming parser: Sonar’s delta.content chunks are gone, replaced by typed server-sent events.

Finally, production hardening in the narrow sense. Rotate keys when one is exposed, when a team member leaves, or when your own policy says so — the docs publish no rotation interval, so this guide states none. Never ship a key in client-side code; the key lives on your server, behind your own back end, and the browser calls your back end, never Perplexity directly. Use the models fallback chain of up to five models so one model’s outage is not your outage. Use dynamic effort levels for freshness and pinned versions where stability is required, and read the effort field on every response so you know which version actually ran. Send a stable prompt_cache_key on requests that share a prompt prefix, so later requests can read the cached prefix — dynamic effort levels already set one for their shared prompt, and an explicit key overrides it. And validate structured output before you trust it: a JSON schema makes invalid output rare, not impossible, and a production app parses defensively and retries or falls back when validation fails.

The Verdict: When Perplexity’s API Beats Building Search Yourself

Three distinct paths in a calm landscape converging at a viewpoint with a compass on a stone, choosing the right API per use case. No text.

Building web search yourself is a serious undertaking: crawling, indexing, ranking, freshness, spam, and the infrastructure to do it at scale — before you have written a single line of answer generation. Perplexity’s API exists so you do not have to. The question is not whether the API is good — it is whether your use case is one of the ones it is built for. The verdict, by use case:

Quick cited answers inside an app — use the Agent API at fast or low. A support chatbot, a research helper, a news summariser, a shopping comparison, a study aid. One call, one answer, citations attached, a fraction of a cent per request. This is the API’s home ground, and it is where it beats building search yourself by the widest margin: the search, the reading, the synthesis and the citations arrive in one response, and your app adds the interface. Start here, and measure before you move up the effort levels.

Your own retrieval pipeline — use the Search API. Your own RAG system, your own ranking, bulk retrieval, monitoring, dataset building. Flat per-request pricing, no model tokens, 50 query units a second on every tier, and multi-query calls billed once. This is the API for developers who want the web as data, not as prose, and who have their own ideas about what to do with it. Pair it with the Agent API for the generation stage, or with a model elsewhere, as your architecture dictates.

Deep research features — use high or xhigh. A research product that sweeps many sources, an analyst tool that builds a briefing from dozens of pages, an open-ended task that runs code in a sandbox and assembles a result step by step. Accept the longer runs and the larger bills — they are the price of depth — and run them in background mode so a dropped connection does not lose the work. Pin the effort version in production, because the model behind the level will change.

Plain multi-model access — use the Orchestrator API. Code, classification, summarisation of documents you already have, anything where the web is irrelevant. One key, one credit balance, OpenAI or Anthropic formats, no search tool fees. Do not pay Agent API prices for a job that needs no search.

What not to build on it is as important as what to build. It is not a general search index for bulk crawling: 50 query units a second and per-request billing make it the wrong tool for harvesting the web at scale, and the Time Machine’s 50-request total at Tiers 1–5 is a precision instrument, not a bulk one. It is not a free tier in the sense developers often mean: there is no free tier stated on the primary pages read for this guide, and what is verified is narrower — sign-up credit exists, it expires after 60 days, and on its own it does not unlock the Agent API. Budget for credits from the first call. And it is not a source of truth: citations prove a source was consulted, not that it is right, and your app should say so to its users rather than presenting cited answers as verified fact.

The one-paragraph start-here recommendation: open the API Console, generate a key, buy a small amount of API credit, and make your first Agent API call at effort="fast" with a question whose answer changed this week. Read the usage.cost on the response — it will be a fraction of a cent. Render the citations under the answer. Then try the same question at low, compare the two answers, and let the comparison tell you which level your app actually needs. That loop — call, read the cost, read the citations, move up only when the cheaper level fails — is the whole discipline of using this API well. The docs will move, the models behind the effort levels will change, and Gemini 4 Carbon’s price will move on 30 November 2026 — but that loop will not. Checked 27 November 2026.

Sources

  • Perplexity — “Pricing” (docs.perplexity.ai/docs/getting-started/pricing, updated 24 November 2026): Agent API model and tool pricing; Search, Monitor, Context, Embeddings and Decisions prices; the two worked cost examples ($0.0059 and $0.0022); service-tier scaling (flex 0.5×, priority 2×); Gemini 4 Carbon/Argon introductory rates through 30 November 2026 and Gemini 3.7/3.8 Flash rates through 31 December 2026. Read in full, 27 November 2026. The pricing page’s model rate table did not render in the text fetch on that date, so model rates in this guide are limited to the ones verified first-hand from the changelog and the pricing page’s prose; the live Agent API Models reference is the authority for the rest of the catalogue.
  • Perplexity — “How to migrate from Sonar” (docs.perplexity.ai/docs/agent-api/migrate-from-sonar/how-to, updated 12 November 2026): the Sonar retirement, the endpoint and method change, messages to input, model to effort, the current Sonar-to-effort mapping (sonar and sonar-pro to fast, sonar-reasoning-pro to low, sonar-deep-research to high), output handling (response.output_text, search_results ids), streaming event changes, dropped parameters, and file limits (30 files / 50 MiB). Read in full, 27 November 2026.
  • Perplexity — “Effort” (docs.perplexity.ai/docs/agent-api/effort, updated 19 November 2026): the six effort levels and what each is good at; dynamic, pinned and frozen use; version forms; HTTP 400 on unknown effort or version; the 2026-11-11.0 versions omitting max_output_tokens (up to 128,000 output tokens per generation); the cost and latency profile promise. Read in full, 27 November 2026. The page’s per-level current-value blocks rendered only in part in that check, so per-level step counts are given as the 2026-11-11.0 version values with the live page named as the authority.
  • Perplexity — “Quickstart” (docs.perplexity.ai/docs/getting-started/quickstart, updated 20 November 2026): the seven core APIs; key generation (project, API Keys, + Generate API Key, full key shown once); credits required before calling the Agent or Orchestrator APIs; SDKs (Python 3.10+, Node.js 20+); PERPLEXITY_API_KEY; streaming. Read in full, 27 November 2026.
  • Perplexity — “Create Agent Response” API reference (docs.perplexity.ai/api-reference/agent-post): POST /v1/agent request and response schema — input (required), instructions, background, language_preference, max_output_tokens, max_steps (1–500, default 1 with a direct model), model (provider/model), models (1–5 fallback chain), effort, streaming, temperature and top_p, usage.cost. Read in full, 27 November 2026.
  • Perplexity — “Create Chat Completion”, legacy Sonar reference (docs.perplexity.ai/api-reference/legacy/sonar-post): the retirement notice verbatim; the old endpoint POST /v1/sonar; the old models sonar, sonar-pro, sonar-reasoning-pro and sonar-deep-research; the old response shape (choices, citations, search_results, images, related_questions); the old search filters. Read in full, 27 November 2026.
  • Perplexity — “Rate Limits & Usage Tiers” (docs.perplexity.ai/docs/admin/rate-limits-usage-tiers): the tier table (cumulative purchases, never downgraded); Agent API requests per second and tokens per minute/hour per tier; the three 429 error.type values and remedies; polling counting against requests per second; the Search API’s 50 units per second on every tier; Embeddings, Context and Time Machine limits; the 30-minute non-streaming hold; token-pause behaviour. Read in full, 27 November 2026.
  • Perplexity — “Perplexity Search API / Quickstart” (docs.perplexity.ai/docs/search/quickstart, updated 20 November 2026): POST https://api.perplexity.ai/search; client.search.create() in both SDKs; response fields (results with title, URL, snippet, date, last_updated, and a request id); max_results 1–20, default 10; date omitted when unknown. Read in full, 27 November 2026.
  • Perplexity — “How Search Works” (docs.perplexity.ai/docs/search/overview, updated 24 November 2026): ranked results with no model and no answer; the snippet as query-relevant extracted text, not the full page; multi-query (up to 5 queries, max_results capping the combined list, billed once, 1 rate-limit unit per query); search types web, fast and people (people: max 50); query 1–8192 bytes UTF-8. Read in full, 27 November 2026.
  • Perplexity — “Changelog”, November 2026 entries (docs.perplexity.ai/docs/resources/changelog): xhigh now using GPT-6.2 Sol (xhigh@2026-11-18.0, no fallback); Gemini 4 Neon, Hydrogen and Carbon rates; GPT-6.2 Sol and Astra rates; Gemini 3.7/3.8 Flash rates through 31 December 2026; sign-up credits not unlocking the Agent or Orchestrator APIs; Orchestrator out of private preview; Time Machine snapshot_as_of (up to 365 days); Monitor, Context and Decisions v1.3 news; ultra (ultra@2026-11-05.0, Claude Opus 5.5, no frozen configuration). Read in full, 27 November 2026.
  • Perplexity — “SDK overview” (docs.perplexity.ai/docs/sdk/overview, updated 17 November 2026): pip install perplexityai; @perplexity-ai/perplexity_ai; the SDKs covering the Agent API, Search, Embeddings, Decisions and Monitor, plus batches, files, skills, models and legacy Sonar; client = Perplexity() reading PERPLEXITY_API_KEY. Read in full, 27 November 2026. The page’s code blocks rendered only in part in that check; SDK method names follow the migration guide and the API reference.
  • Perplexity — “Agent API Models” reference (docs.perplexity.ai/docs/agent-api/models, updated 24 November 2026): the model catalogue, token pricing, service tiers and provider documentation; the worked response example showing the search_results and output_text shapes. Read 27 November 2026; the rate table did not render in the text fetch, so its rates are not quoted here beyond the changelog-verified figures in the models section. The one exception is perplexity/sonar ($0.25 input / $2.50 output per 1M tokens), carried from our primary read of this page on 15 November 2026 for the Perplexity explainer (post 5796); re-verify it on the live page.
  • Perplexity API Console (console.perplexity.ai): key generation and Billing pages, as cited in the Quickstart. Accessed 27 November 2026.
  • Site sources linked in the article: the Perplexity explainer (post 5796); the Monitor, Orchestrator and Context launch report; Perplexity’s Free, Pro and Max pricing guide (post 434); the OpenAI API explainer; the Gemini API first-app tutorial (D6); the AI model picker; the Claude models explainer; the DeepSeek explainer; the generative engine optimisation explainer; the AI agents explainer. All verified HTTP 200 on 27 November 2026.

Share to: , and

Faheem R. Khattak

Senior automation engineer and AI marketing journo covering LLMs, algorithms, analytics, core updates, Bing search, and technical SEO.

0 Comments

Leave a Reply

Optional Take Tag:

🛡️ Spam protection: Honeypot + Time-Trap Active

This site uses Akismet to reduce spam. Learn how your comment data is processed.