If you wired up Perplexity's Sonar API in 2025, your code calls an endpoint that Perplexity no longer supports. It still answers, for now, because Perplexity rewrites those requests behind the scenes.
The Perplexity API in 2026 gives developers web-grounded answers with citations through the Agent API, and raw ranked search results through the Search API. You pay per token plus per search, with no free tier, and choose an effort level from fast to ultra instead of a Sonar model. This guide covers pricing, keys, code, and citations.
Every price and limit here comes from Perplexity's own docs as of November 12, 2026. I tested the parsing code below against the response models in Perplexity's official Python SDK, version 0.46.1, using the response shapes its docs publish.
Disclosure: MentionsAPI publishes this blog and sells an API that checks how Perplexity, ChatGPT, and other engines mention brands. It comes up once, in the section on tracking what users see.
What is the Perplexity API in 2026?
The Perplexity API is a set of developer endpoints for web-grounded AI. The Agent API returns a generated answer with cited sources, the Search API returns ranked web results as JSON, and three smaller APIs cover model routing, embeddings, and probability scoring. Most teams that say "Perplexity API" mean the Agent API, the successor to Sonar.
- Agent API (POST /v1/agent): an answer with sources, built by a model running web search and other tools.
- Search API (POST /search): up to 20 ranked results per query with page text, and no generated answer.
- Orchestrator, Embeddings, and Decisions: model routing in OpenAI or Anthropic format, vectors, and yes-or-no probabilities.
The Agent API is model-agnostic. Its model list includes OpenAI, Anthropic, Google, xAI, and open-weight models, plus Perplexity's own sonar model at $0.25 per million input tokens and $2.50 per million output tokens.
What happened to the Perplexity Sonar API?
Perplexity ended support for Sonar Chat Completions on September 27, 2026, and now recommends the Agent API for all work. Synchronous and streaming Sonar requests still return answers because Perplexity reformulates them as Agent API requests, rolling out model by model. Asynchronous Sonar requests are no longer supported and must move to the Agent API's background mode.
That date comes from Perplexity's migration guide. The guide maps each old Sonar model to an effort level, which is a preset bundle of model, search settings, step limit, and system prompt:
| Old Sonar model | Agent API effort | Model behind it (Nov 2026) | Max steps |
|---|---|---|---|
| sonar | fast | openai/gpt-6-luna | 1 |
| sonar-pro | fast | openai/gpt-6-luna | 1 |
| sonar-reasoning-pro | low | openai/gpt-6-luna | 5 |
| sonar-deep-research | high | openai/gpt-6.1-terra | 40 |
| (new) | xhigh | anthropic/claude-opus-5-5 | 300 |
Note the third column. Most effort levels now run on OpenAI or Anthropic models that Perplexity hosts with its own search, and Perplexity can swap the model when its evals improve. Pin a version such as [email protected] if you need identical behavior month to month.
The request shape changed too. Sonar took a messages array and returned choices plus a citations list. The Agent API takes an input and returns a typed output array, with a search_results item for sources and a message item for the answer.
If you still run Sonar code, the move takes four changes:
- Point requests at /v1/agent and swap the model name for an effort level.
- Send your prompt as input instead of a messages array.
- Read sources from the search_results output item instead of a citations list.
- Replace async Sonar jobs with background runs: send background set to true, then poll by response id.
How much does the Perplexity API cost?
The Search API costs $5 per 1,000 requests, or $1 with Fast Search. The Agent API charges model tokens plus $2.50 per 1,000 web searches, so cost depends on the effort level. In Perplexity's own benchmarks, a fast request cost $0.0014 to $0.0018, low cost $0.006 to $0.012, and high cost $0.12 to $0.14 per request.
| What you call | How it bills | Published price |
|---|---|---|
| Search API | Per successful request | $5 per 1,000 ($1 with Fast Search) |
| Agent API web_search tool | Per invocation | $2.50 per 1,000 ($1 with Fast Search) |
| Agent API fetch_url tool | Per invocation | $0.50 per 1,000 |
| perplexity/sonar model | Per token | $0.25 in, $2.50 out per 1M tokens |
| openai/gpt-6-luna model | Per token | $0.10 in, $0.50 out per 1M tokens |
The rates come from Perplexity's pricing page. A Search API request with up to five queries in an array still bills as one request, and failed or rate-limited requests are free.
Token prices alone do not tell you what a call costs, because an effort level decides how many steps and searches run. The per-request figures from Perplexity's Sonar comparison benchmarks are the closest thing to a real price list.
Those benchmark numbers are Perplexity's own, measured on research-style questions. Short factual prompts use fewer tokens, and long reports use more, so check the usage.cost.total_cost field in each response for your real number.
On the same benchmarks, Perplexity reports that fast scored 26.67% on BrowseComp against 7.00% for the old sonar model, at a fifth of the cost per request. That is a vendor-run test, but the direction is clear: the replacement is cheaper and stronger on multi-step questions.
How to get a Perplexity API key
To get a Perplexity API key, sign in to the API console at console.perplexity.ai, add a card and buy credits under billing, then generate a key on the API Keys page. There is no free tier, and new accounts start at usage tier 0 with one request per second. Store the key in an environment variable, never in code.
- Sign in at console.perplexity.ai with the account that will own billing.
- Open Billing, add a payment method, and buy credits. Turn on automatic top-up for production.
- Open the API Keys page and generate a key. Copy it immediately.
- Export it as PERPLEXITY_API_KEY and send it as a Bearer token on every request.
Your first call needs nothing but curl:
export PERPLEXITY_API_KEY="your_api_key_here"
curl https://api.perplexity.ai/v1/agent \
-H "Authorization: Bearer $PERPLEXITY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"effort": "fast", "input": "What is the best CRM for a 10-person sales team?"}'Rate limits rise with lifetime spend. Perplexity's usage tiers run from 1 request per second at tier 0 to 33 at tier 4, which needs $1,000 in total credit purchases.
Token limits apply separately, per model, per minute and per hour. You can hit a 429 while well under your request limit, so read error.type in the response before you retry.
A value of request_rate_limit_exceeded means wait about a second, and token_rate_limit_exceeded names the window you hit. An overloaded error is not a rate limit at all, so retry with backoff or add a fallback model.
How to read citations from the Agent API
The Agent API returns sources in a search_results item, separate from the answer text, and each result has an id, URL, title, snippet, and dates. The answer marks claims with bracketed numbers that point to those ids: the fast effort level writes [1], while low, medium, and high write [web:1]. Parse both forms, and treat the results list as the source of truth.
Here is a function that does that and returns the cited URLs, every URL searched, and the call's cost:
import os
import re
import requests
API_KEY = os.environ["PERPLEXITY_API_KEY"]
def ask_perplexity(question, effort="fast"):
"""One Agent API call: the answer, the sources it cited, and what the call cost."""
r = requests.post(
"https://api.perplexity.ai/v1/agent",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"effort": effort, "input": question},
timeout=120,
)
r.raise_for_status()
data = r.json()
sources, answer = {}, ""
for item in data.get("output", []):
if item["type"] == "search_results":
for result in item["results"]:
sources[result["id"]] = result["url"]
elif item["type"] == "message":
answer += "".join(c.get("text", "") for c in item["content"] if c["type"] == "output_text")
# fast cites as [1]; low, medium, and high cite as [web:1]
cited_ids = {int(n) for n in re.findall(r"\[(?:web:)?(\d+)\]", answer)}
usage = data.get("usage") or {}
return {
"answer": answer,
"cited": [sources[i] for i in sorted(cited_ids) if i in sources],
"searched": list(sources.values()),
"cost_usd": (usage.get("cost") or {}).get("total_cost"),
}I tested it by validating sample responses against the SDK's ResponseCreateResponse model, then running the parser on them. It handled numbered markers, web-typed markers, answers with no markers, a marker pointing at a missing id, and responses without cost data.
Keep cited and searched apart. A source can appear in search_results without being cited in the answer, and only the cited ones show up as links to a reader.
Already using the OpenAI SDK? Set the base URL to https://api.perplexity.ai/v1 and call client.responses.create, since Perplexity accepts /v1/responses as an alias.
Which effort level should you use?
Use fast for single facts and short answers, low for everyday research with a few searches, medium for questions that chain evidence across many sources, and high for deep research where completeness beats speed. Use xhigh only for open-ended agent work like running code. Each step up costs several times more per request, so test the cheapest level first.
- fast: one step, Fast Search, about $1.40 to $1.80 per 1,000 calls.
- low: up to 5 steps with URL fetching, about $6 to $12 per 1,000.
- medium: up to 15 steps, about $16 to $31 per 1,000.
- high: up to 40 steps, about $121 to $136 per 1,000.
The jump from medium to high is the one to watch. On Perplexity's benchmarks it added 4 to 6 points of accuracy for roughly four to eight times the cost per request.
You can also override any part of an effort level, such as the model, max_steps, or tools, by passing it next to effort. That is how you keep fast's search setup while swapping in perplexity/sonar or a model your team already trusts.
When to use the Search API instead
Use the Search API when you want Perplexity's ranked web results but plan to write the answer with your own model, or need no answer at all. It returns up to 20 results per query with title, URL, extracted page text, and dates, for a flat $5 per 1,000 requests. There is no token bill, so costs stay predictable.
One request can carry up to five related queries and still bill once, though each query uses a rate-limit unit. Filters cover up to 20 domains, up to 20 languages, recency, date windows, and a country code.
Two details trip people up. A result's snippet can come back empty, so check it before you hand it to a model, and a successful request with zero results still bills.
The tradeoff is simple: the Agent API costs more per call but writes and cites the answer for you. The Search API is cheaper and more controllable, and leaves the writing, citing, and prompt work to your code.
Does the Perplexity API show what perplexity.ai users see?
Not reliably: in the API, your effort level picks the model, and most effort levels run on OpenAI or Anthropic models with Perplexity's search. The perplexity.ai app runs its own configuration, personalization, and model choices. So an API answer tells you what that configuration says, which may differ from what a real Perplexity user reads for the same question.
That matters if you are measuring brand visibility. AI answers also vary run to run: a SparkToro and Gumshoe study found less than a 1-in-100 chance that an AI tool repeats the same brand list for one prompt, Search Engine Journal reported.
For product features, like answering questions with sources inside your app, the Agent API is the right tool. For monitoring how Perplexity presents your brand to its users, sample the live app answer, on many prompts, over several weeks.
The API tells you what a model with Perplexity's search says. Only the live app tells you what Perplexity users read.The rule for brand tracking
MentionsAPI's perplexity_live mode captures the live perplexity.ai answer with its inline citations for 85 credits per call. Its quick mode checks ChatGPT, Claude, Gemini, and Perplexity together for 150 credits.
Mistakes to avoid with the Perplexity API
Most Perplexity API problems in late 2026 come from code written for Sonar. The old endpoint still answers, which hides the migration until something breaks, and the citation format, cost model, and response shape all changed. These are the mistakes worth checking for first, roughly in order of how often they bite.
- Leaving production on the Sonar endpoint because it still answers.
- Parsing only [1] markers and missing every [web:1] citation from low, medium, and high.
- Reading a top-level citations array that the Agent API does not return.
- Running high or xhigh on simple lookups that fast answers for a hundredth of the price.
- Retrying 429s blindly instead of checking whether the request or token limit was hit.
- Treating API answers as proof of what perplexity.ai shows its users.
Frequently asked questions
Is the Perplexity API free?
How much does the Perplexity API cost?
How do I get a Perplexity API key?
Is the Perplexity Sonar API still available?
Can I use the OpenAI SDK with the Perplexity API?
Does the Perplexity API return the same answers as perplexity.ai?
Move off Sonar, then pick the cheapest effort that works
The Perplexity API in 2026 is the Agent API for cited answers and the Search API for raw results. Move any Sonar integration now, start new work on the fast effort level, and parse both citation formats. Then check usage.cost.total_cost on real traffic before you raise the effort level.
Pin an effort version in production. Perplexity moved fast to a new model in August 2026, and it will move again.