The
Perplexity API is a developer platform for adding current web search, cited answers, multi-provider models and agent tools to software.
It is not one endpoint or one model. Perplexity currently offers four main developer choices:
- Agent API for model and tool orchestration across multiple providers;
- Sonar API for generated answers grounded in web search;
- Search API for ranked raw web results;
- Embeddings API for semantic retrieval and related vector workflows.
For a new agentic application, Perplexity recommends starting with the Agent API. Sonar remains supported and can be the simpler choice when the product only needs a cited answer. Search API is preferable when the application—not Perplexity—should control synthesis. Embeddings solve a different problem: searching and organizing a corpus by meaning.
Consumer Free, Pro and Max subscriptions do not include API usage. The developer platform uses separate keys, groups, limits and pay-as-you-go billing.
This guide is for architects and developers choosing and implementing the API. For the end-user product, see the
Perplexity AI cornerstone.
Perplexity APIs at a glance
| API | Returns | Best for | Billing center |
| Agent API | Model output plus optional tool results and actions | Agents, multi-provider apps, tool use, research workflows | Model tokens plus tool invocations |
| Sonar API | Generated web-grounded answer with citations | Answer engines, support, research summaries | Tokens plus request/search costs |
| Search API | Ranked pages and snippets | Custom retrieval, indexing, source discovery | $5 per 1,000 requests |
| Embeddings API | Numeric vectors | Semantic search, RAG, clustering, similarity | Input tokens |
Which Perplexity API should you use?
Choose Agent API when
- one interface should reach models from several providers;
- the model needs web, URL, people, finance or sandbox tools;
- the task can require several steps;
- you want presets or background work;
- functions, MCP or custom tools are part of the architecture;
- or a new project may grow beyond one cited answer.
Choose Sonar when
- the application needs a complete readable answer;
- web grounding and citations are mandatory;
- a Chat Completions-style interface is convenient;
- and the workflow does not need general tool orchestration.
Choose Search API when
- you want raw results, not generated prose;
- ranking, filtering or caching belongs in your application;
- you need to feed retrieval into another model or deterministic pipeline;
- or you want to inspect and score sources before generation.
Choose embeddings when
- the content is mainly your own corpus;
- semantic similarity matters;
- you are building retrieval-augmented generation;
- or you need clustering, deduplication or recommendation features.
Many production systems use more than one. Search can retrieve candidate pages, embeddings can rank internal passages, and an Agent API model can synthesize or act.
Agent API
The
Agent API is a multi-provider interface. Perplexity currently exposes models from providers including OpenAI, Anthropic, Google, xAI, Z.AI, Moonshot AI and Nvidia through one API, subject to the live catalog.
Its main endpoint is:
POST https://api.perplexity.ai/v1/agent
For OpenAI Responses API compatibility, /v1/responses is also accepted as an alias.
Main Agent API tools
- web_search retrieves current web information.
- fetch_url extracts a named page.
- people_search finds professional and people information.
- finance_search retrieves finance data.
- sandbox runs code in an isolated container.
- custom functions and supported MCP integrations extend application-specific action.
Only expose tools needed by the request. A model that can answer a question does not need database write access.
Basic Python example
Install the official SDK:
pip install perplexityai
Set the API key outside source code:
export PERPLEXITY_API_KEY="replace-with-your-key"
Then call a current model or preset from the live catalog:
from perplexity import Perplexity
client = Perplexity()
response = client.responses.create(
preset="low",
input=(
"Find the current EU source that defines the application dates "
"for general-purpose AI obligations. State the dates and cite the source."
),
)
print(response.output_text)
print(response.usage.cost.total_cost)
Presets package a model, tool and token strategy for a use case. A named model gives more control but also makes the integration sensitive to model retirement and replacement.
Agent API with explicit search
from perplexity import Perplexity
client = Perplexity()
response = client.responses.create(
model="openai/gpt-5.6-sol",
input="What materially changed in the Python 3.15 release notes?",
tools=[{"type": "web_search"}],
instructions=(
"Use the official Python documentation. Search only when the question "
"requires current information. Distinguish final releases from previews."
),
)
print(response.output_text)
Model names are time-sensitive. Read the
current model catalog rather than copying one identifier permanently from an article.
Sonar API
Sonar combines search and generation. The output is a complete answer with supporting sources rather than a list of links.
The native endpoint is:
POST https://api.perplexity.ai/v1/sonar
Perplexity also supports the OpenAI Chat Completions format, which makes migration and library reuse straightforward.
Sonar models
At review, the core range included:
- sonar for economical grounded answers;
- sonar-pro for stronger and more complete retrieval and synthesis;
- sonar-reasoning-pro for reasoning-oriented work;
- sonar-deep-research for multi-search research.
Model availability, context windows and parameters can change.
Sonar with the OpenAI Python client
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PERPLEXITY_API_KEY"],
base_url="https://api.perplexity.ai",
)
response = client.chat.completions.create(
model="sonar-pro",
messages=[
{
"role": "user",
"content": (
"Compare the current official annual prices of Perplexity Pro "
"and Max in the United States. Cite Perplexity documentation."
),
}
],
)
print(response.choices[0].message.content)
Compatibility does not mean every provider-specific parameter behaves identically. Test errors, streaming, citations and structured output before replacing an existing backend.
Search API
The Search API returns ranked results with fields such as title, URL, snippet and date. It does not charge separate token fees.
Endpoint:
POST https://api.perplexity.ai/search
cURL example
curl -X POST "https://api.perplexity.ai/search" \
-H "Authorization: Bearer $PERPLEXITY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "site:europa.eu general-purpose AI Code of Practice final",
"max_results": 5,
"search_context_size": "high"
}'
Supported controls include country, language and domain filters, as well as limits on returned results and context. A negative domain filter can exclude a source, but do not use exclusion to hide legitimate contrary evidence.
Search API versus Sonar
Suppose an application answers a regulatory question.
With Search API, the developer can:
- restrict retrieval to official domains;
- inspect dates and duplicate pages;
- score sources;
- send selected passages to a chosen model;
- and preserve a deterministic source log.
With Sonar, one request can return a readable cited answer faster.
Search gives control. Sonar gives convenience.
Embeddings API
Embeddings convert text into vectors whose distance represents semantic similarity.
At review, Perplexity listed:
| Model | Dimensions | Price per 1M input tokens |
| pplx-embed-v1-0.6b | 1,024 | $0.004 |
| pplx-embed-v1-4b | 2,560 | $0.03 |
| pplx-embed-context-v1-0.6b | 1,024 | $0.008 |
| pplx-embed-context-v1-4b | 2,560 | $0.05 |
Contextualized embeddings incorporate document context to distinguish chunks whose meaning depends on surrounding material. They cost more and should be evaluated on the actual retrieval benchmark.
Before choosing vector dimensions, estimate database size, latency, indexing time and recall. A bigger vector is not automatically a better production system.
Perplexity API pricing
All prices below were checked on July 24, 2026 and can change.
Agent API model and tool costs
Third-party model tokens are billed at the provider’s direct price without Perplexity markup, according to the documentation. The chosen model controls that part of the bill.
| Tool | Price |
| web_search | $0.0025 per invocation |
| fetch_url | $0.00025 per invocation |
| people_search | $0.005 per invocation |
| finance_search | $0.005 per invocation |
| sandbox | $0.03 per container session |
A sandbox session uses a 20-minute billing window, which is not described as a runtime cap. Searches launched from the SDK inside the sandbox are billed separately.
Search API price
$5 per 1,000 requests, or half a cent per request, with no separate token charge.
Sonar token prices
| Model | Input per 1M tokens | Output per 1M tokens |
| Sonar | $1 | $1 |
| Sonar Pro | $3 | $15 |
| Sonar Reasoning Pro | $2 | $8 |
| Sonar Deep Research | $2 | $8 |
Sonar Deep Research also listed:
- citation tokens: $2 per million;
- search queries: $5 per 1,000;
- reasoning tokens: $3 per million.
Sonar request fees
For Sonar, Sonar Pro and Sonar Reasoning Pro, add a request fee based on search context:
| Model | Low per 1,000 | Medium per 1,000 | High per 1,000 |
| Sonar | $5 | $8 | $12 |
| Sonar Pro | $6 | $10 | $14 |
| Sonar Reasoning Pro | $6 | $10 | $14 |
Search context size is the amount of retrieved web material, not the model’s total context window.
Sonar Pro Search fees
Sonar Pro can use multi-step Pro Search:
| Search type | Low / Medium / High per 1,000 requests |
| Fast | $6 / $10 / $14 |
| Pro | $14 / $18 / $22 |
| Auto | Depends on classification |
Token charges still apply.
Token charges still apply.
Cost examples
Search API cost example
100,000 requests:
$$100{,}000 \div 1{,}000 \times $5 = $500$$
This excludes your own generation, database and infrastructure.
Sonar Pro
Assume one medium-context request with:
- 2,000 input tokens;
- 1,000 output tokens.
Approximate variable cost:
- input: $0.006;
- output: $0.015;
- medium request fee: $0.010;
- total: $0.031 per request.
At 100,000 comparable requests, that is about $3,100 before caching, retries or other system costs.
Agent API cost example
Perplexity’s pricing page showed a representative low research preset with 2,000 input tokens, 1,000 output tokens, one search and one URL fetch costing $0.00675. Actual cost changes with the model and tool use. Read usage.cost.total_cost from completed responses when available.
API subscription versus Perplexity Pro
| Consumer subscription | API platform |
| Used through Perplexity interfaces | Used inside software |
| Monthly or annual personal/team plan | Pay as you go |
| Includes search modes and product features | Includes endpoints, keys and developer controls |
| Does not include matching API credit | Does not grant a Pro or Max seat |
| Limits described by product usage | Rate limits and account tiers |
Keep the two budgets separate.
API keys and groups
Never embed a Perplexity key in browser JavaScript, a mobile binary or a public repository.
Use:
- a server-side secret manager;
- separate keys for development, staging and production;
- least-privilege groups and roles;
- named owners;
- rotation;
- spend alerts;
- and rapid revocation.
API Groups support shared billing, permissions and usage management. Separate teams or applications when ownership, budget or data classification differs.
Rate limits and usage tiers
Perplexity assigns rate capacity partly through cumulative API purchases. At review, published thresholds began with Tier 0 and progressed at cumulative purchases of $50, $250, $500, $1,000 and $5,000.
The exact requests-per-minute and token limits depend on product and tier. Read response headers and the current
rate-limit documentation.
Build for limits:
- exponential backoff with jitter;
- bounded retries;
- idempotency for actions;
- queues and concurrency control;
- timeouts;
- graceful degraded behavior;
- and monitoring by endpoint and status code.
Retries can multiply both cost and duplicate action if idempotency is missing.
Data privacy and retention
Perplexity states a Zero Data Retention policy for its Chat Completions API: prompt and response content sent through that API is not retained or used to train models, while billing metadata such as token count, model, timestamp, duration and API-key identifier is kept.
Do not casually extend that exact claim to every newer API surface without confirming the relevant documentation and contract. Agent tools, third-party models, custom functions and external systems can introduce additional processors and logs.
Production review should cover:
- the exact endpoint;
- selected model provider;
- tools and external destinations;
- logging in your own application;
- error and observability vendors;
- regional requirements;
- sensitive-data redaction;
- subprocessors and contract terms.
Grounding does not remove hallucinations
The API can return a cited answer that:
- cites a page too broadly;
- selects a secondary source over the original;
- misses a decisive source;
- combines incompatible dates;
- or draws an inference the page does not support.
For material facts, store:
- query;
- response;
- retrieved source URLs;
- access time;
- relevant passage or content hash;
- model and API version;
- validation result.
Do not expose an unsupported answer merely because finish_reason indicates completion.
Production architecture
A robust source-grounded application often uses:
- Query normalization to identify entity, date and region.
- Retrieval with Search, Sonar or Agent tools.
- Source policy to prefer and reject defined classes.
- Generation with an explicit output schema.
- Claim validation against retrieved passages.
- Safety and permissions before any action.
- Observability for latency, cost, errors and source quality.
- Human escalation for high-risk or low-confidence results.
The model call is one component, not the complete product.
Evaluation before launch
Build a representative set of queries and label:
- required sources;
- acceptable answer;
- prohibited claims;
- freshness;
- latency target;
- cost ceiling;
- escalation condition.
Measure:
- retrieval recall;
- citation precision;
- claim correctness;
- source authority;
- refusal quality;
- latency percentiles;
- cost distribution;
- and behavior under missing or conflicting evidence.
Re-run the evaluation when changing model, search context, prompt, tool set or endpoint.
Common implementation mistakes
Choosing Sonar when raw retrieval is needed
Do not parse generated prose back into a search index. Use Search API.
Building a custom agent on Sonar by accident
For new multi-tool work, start with Agent API unless Sonar’s simpler contract is intentionally sufficient.
Hard-coding a volatile third-party model
Use configuration and a tested fallback.
Treating domains as truth labels
Domain filtering narrows scope; it does not validate every page.
Ignoring request fees
Sonar’s token rate is not the whole price. Add context or Pro Search fees.
Logging prompts containing sensitive data
Provider retention is only one layer. Application logs may become the larger exposure.
Giving the model a write tool during early testing
Start read-only and validate proposed actions.
Using consumer plan limits to estimate API throughput
They are unrelated.
Frequently asked questions
Is the Perplexity API free?
It is pay as you go. Promotions may exist, but production planning should use current published rates.
Which Perplexity API is best for a new app?
Agent API is the recommended general starting point. Use Sonar for a simple cited-answer contract and Search API when you need raw results.
What is Sonar?
Sonar is Perplexity’s web-grounded answer API. It retrieves current information and generates a response with citations.
Is the Perplexity API OpenAI-compatible?
Sonar supports the OpenAI Chat Completions format. Agent API accepts a Responses-compatible alias. Parameter and feature parity still require testing.
How much does Search API cost?
$5 per 1,000 requests at review, with no token charge.
Does Perplexity Pro include API credits?
No.
Can Agent API use models from other companies?
Yes. Perplexity lists multiple providers through one interface. Use the live catalog for current names and rates.
Does the API train on my data?
Perplexity states that Chat Completions content is not retained or used for training. Confirm the policy for each endpoint, model and external tool in the architecture.
Can I use Perplexity for RAG?
Yes. Search, embeddings and grounded generation can all support retrieval-augmented systems.
How should I control API cost?
Choose the simplest endpoint, cap output and tool calls, cache appropriate results, route simple tasks to cheaper models, monitor total request cost and bound retries.
The bottom line
Perplexity’s developer advantage is search as a first-class primitive.
Use Search API when your system should own retrieval and synthesis. Use Sonar when one call should return a grounded answer. Use Agent API when the application needs models, tools and multi-step orchestration. Use embeddings for semantic work over a corpus.
Then engineer the parts the API cannot decide for you: evidence standards, permissions, evaluation, logging, failure behavior and spend control.