What Is the Perplexity AI API?
“Perplexity AI API” is an umbrella term for a set of developer services built around search, generation, model access, and retrieval.
It is separate from the consumer Perplexity application. You do not need a Perplexity Pro subscription to use the APIs. Instead, you create an API account, add billing, buy credits, and pay for usage.
The four services solve different problems:
Agent API combines language models with tools such as web search and URL fetching. Use it when the output should be a written answer rather than a result list.
Search API returns ranked web results as structured data. Use it when your application—not Perplexity—will decide how to process and display those results.
Router API exposes open-weight models hosted by Perplexity through compatible endpoints. It is model infrastructure, not a search-answer engine.
Embeddings API converts text into vectors for semantic retrieval and RAG systems.
In plain English: “I need an answer” usually points to Agent; “I need search results” points to Search.
The Four Perplexity APIs, Ranked by Use Case
This ranking reflects how closely each product matches the usual reason developers search for “Perplexity AI API”: adding current web information to an application. It is not a claim that one API is technically better than another.
1. Agent API: Best for Web-Grounded Answers
The Agent API is the closest match to the familiar Perplexity experience. It can use a selected model or a preset, call web tools, and return a generated answer with supporting sources.
Its canonical endpoint is POST /v1/agent. Perplexity also accepts POST /v1/responses as an alias so existing OpenAI Responses API integrations can use the service with limited changes. The base URL for that compatibility layer is:
https://api.perplexity.ai/v1
Agent API costs are additive. You pay the selected model's token rate, then pay separately for any tools invoked. A web_search call currently costs $0.0025; fetch_url costs $0.0005.
That makes Agent the easiest option for producing cited answers, but not the easiest bill to forecast. One user request can trigger model tokens and several tool calls.
Verdict: Start here if the search step and written answer belong in the same request.
2. Search API: Best for Raw Search Results
The Search API returns ranked results with titles, URLs, snippets, and extracted content. It also supports domain, language, country, and date controls.
It costs $5 per 1,000 successful requests, or $0.005 per request, with no additional token charge for the Search API response. One request may contain up to five queries and still count as one billing unit, although each query consumes a rate-limit unit.
There is a less obvious boundary: a successful request is billable even when it returns no results. Invalid, rate-limited, and upstream-failed requests are not billed.
Search gives you more control than Agent, but also more work. Your application must decide how to rank, summarize, cite, cache, or display the results.
Verdict: Choose Search when the result set is the product—or when you already have your own generation layer.
3. Router API: Best for Hosted Open-Weight Models
The Router API provides a common endpoint for open-weight models hosted by Perplexity. It supports OpenAI- and Anthropic-compatible interfaces, which can reduce the amount of provider-specific integration code.
Router requests are billed at the requested model's published token rates. There is no separate per-request fee. Cache reads, cache writes, long context, and reasoning tokens may have model-specific rates.
The important distinction: Router is not automatically a web-search API. Calling a model through Router does not recreate the cited Perplexity answer experience.
Verdict: Use Router for model access. Do not select it merely because your application needs current web information.
4. Embeddings API: Best for Custom RAG
Perplexity offers standard and contextualized embedding models. Current published rates are:
| Model |
Dimensions |
Price per 1M 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 |
Embeddings are inexpensive compared with generation. The trade-off is ownership: you must supply the documents, vector store, retrieval logic, and generation model.
Verdict: Pick Embeddings when control over the corpus and retrieval pipeline matters more than a ready-made web answer.
Perplexity AI API Pricing and Cost
The phrase “Perplexity API cost” does not have one number. Each API measures usage differently.
The following prices were checked against Perplexity's published pricing on August 20, 2026.
Current Sonar and Tool Pricing
| Product |
Input |
Output |
Other charges |
| Sonar |
$1/1M tokens |
$1/1M tokens |
Request fee may apply by search context |
| Sonar Pro |
$3/1M tokens |
$15/1M tokens |
Request fee may apply by search context |
| Sonar Reasoning Pro |
$2/1M tokens |
$8/1M tokens |
Request fee may apply by search context |
| Sonar Deep Research |
$2/1M tokens |
$8/1M tokens |
$2/1M citation tokens; $3/1M reasoning tokens; $5/1K search queries |
| Search API |
— |
— |
$5/1K successful requests |
Agent web_search |
— |
— |
$0.0025/invocation |
Agent fetch_url |
— |
— |
$0.0005/invocation |
Agent sandbox |
— |
— |
$0.03/session, covering up to 20 active minutes for billing |
Do not copy these rates into a permanent budget spreadsheet without a date. API prices and available models change.
How to Calculate Perplexity API Cost
For Search API, the basic formula is simple:
Search API cost = successful requests × $0.005
For Agent API, add the selected model's token cost and the tools actually invoked:
Agent API cost = input tokens + output tokens + tool invocations
Legacy Sonar cost is more complicated because it can combine token rates with search-context or query charges:
Legacy Sonar cost = token cost + applicable request or search cost
Perplexity's own Agent API example uses 500 input tokens, 200 output tokens, and one web search. The published total is $0.006175. In that example, the web search alone costs $0.0025—large enough that estimating tokens but ignoring tools would materially understate the bill.
For production forecasting, log the returned usage data instead of estimating solely from prompt length. Perplexity notes that completed responses may expose the calculated total through usage.cost.total_cost.
How to Get a Perplexity AI API Key
Perplexity's current API key process is:
Open the Perplexity API Console.
Add a payment method under Billing.
Select Buy more credits.
Open the API Keys tab.
Select Generate API Key.
Copy the key and store it in a secret manager or environment variable.
On macOS or Linux, the official documentation uses:
export PERPLEXITY_API_KEY="your_api_key_here"
Do not place the key in browser-side JavaScript or commit it to a repository. Requests should originate from a trusted server environment.
Perplexity also notes that API credits are separate from its other product credits. A consumer subscription balance should not be treated as an API budget.
How to Use the Perplexity AI API
Install the official Python SDK:
pip install perplexityai
The SDK reads PERPLEXITY_API_KEY automatically.
Make an Agent API Request in Python
This example uses an Agent API preset. Presets package the model and tool configuration, so you do not have to specify a model for a basic request.
from perplexity import Perplexity
client = Perplexity()
response = client.responses.create(
preset="low",
input="What changed in the Python release notes this week? Cite the sources."
)
print(response.output_text)
Use the native SDK when starting a new integration. It exposes Perplexity-specific parameters directly and avoids manual base URL configuration.
Use Perplexity with the OpenAI Python SDK
If an application already uses the OpenAI Responses interface, change the key and base URL:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PERPLEXITY_API_KEY"],
base_url="https://api.perplexity.ai/v1",
)
response = client.responses.create(
input="Explain the difference between keyword and vector search.",
extra_body={"preset": "low"},
)
print(response.output_text)
The /v1 suffix matters. The OpenAI SDK sends client.responses.create() requests to /v1/responses, which Perplexity accepts as an alias for its canonical /v1/agent endpoint.
Call the Search API with cURL
Use Search API when you need structured results rather than a generated answer:
curl --request POST \
--url https://api.perplexity.ai/search \
--header "Authorization: Bearer $PERPLEXITY_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"query": "Python release notes",
"max_results": 5,
"search_context_size": "low"
}'
max_results accepts values from 1 to 20. Use search_context_size: "low" when short snippets are sufficient; larger extracted passages increase the amount of content your downstream system must process, even though Search API itself has no token charge.
These examples follow the current documentation, but they have not been executed here with a live Perplexity key. Smoke-test them in the publishing environment before release.
Migrating from the Legacy Sonar API
Perplexity states that Sonar Chat Completions is now Agent API and that legacy Sonar support ends on September 27, 2026. This is why many older tutorials are misleading even when their code still works today.
For a new application, use the Agent API instead of building around the legacy Sonar Chat Completions interface.
For an existing integration, check five areas:
Endpoint: move from the legacy Chat Completions endpoint to /v1/agent, or use /v1/responses through the OpenAI SDK.
SDK method: replace chat.completions.create() with the Responses-style method where appropriate.
Request fields: Agent API uses Responses parameters such as input, instructions, and max_output_tokens.
Response parsing: read the Responses output structure rather than assuming choices[0].message.content.
Cost tracking: include tool invocations, not just tokens.
Do not treat migration as a model-name substitution. The request format, response structure, and billing model can all change.
Common Perplexity API Problems
A request returns 401
Confirm that the server received PERPLEXITY_API_KEY and that the authorization header uses the Bearer scheme. Also check that the key belongs to the intended project and has not been revoked.
A request returns 429
Rate limits depend on the account's usage tier and the API being called. A multi-query Search request counts as one billing unit but consumes one rate-limit unit per query, so a five-query request consumes five rate-limit units.
Search succeeds but returns no results
A successful Search API response can be billable even when the result set is empty. Validate narrow domain, language, country, and date filters before sending them at scale.
The OpenAI SDK calls the wrong URL
For Agent API compatibility, set the base URL to exactly:
https://api.perplexity.ai/v1
Leaving off /v1 can send the SDK to an invalid path.
A model name stops working
Available models change. Perplexity exposes the current Agent API catalog at GET /v1/models, and its documentation says this listing does not require authentication. Discover models at runtime or validate configured model IDs during deployment.
Is the Perplexity API Worth Using?
Perplexity earns its place when search is part of the product.
The Agent API is a practical choice when your application needs current information and visible supporting sources without operating its own search pipeline. Search API makes sense when you want Perplexity's result retrieval but prefer to control ranking, summarization, and presentation yourself.
The trade-off is cost and dependency. Agent requests can accumulate model and tool charges. Search results depend on Perplexity's index. A custom retrieval stack requires more engineering, but it gives you control over the corpus, ranking, caching, and failure behavior.
If your workload is ordinary drafting, classification, coding, image generation, or video generation, web search may be incidental rather than essential. Paying for an additional search layer then solves the wrong problem.
Does GPT Proto Offer the Perplexity API?
No. GPT Proto does not currently offer Perplexity or Sonar models. It does not provide an indirect Perplexity endpoint, and you should use Perplexity's official API when you specifically need its web-grounded answers or Search API.
If your application instead needs other language, image, or video models through one account, browse GPT Proto's available model catalog. Check the catalog before designing an integration; model availability should never be inferred from an article about another provider.
Final Recommendation
Choose Agent API when you need a written, web-grounded answer. Choose Search API when you need the underlying results. Router is for open-weight model access, while Embeddings is for a retrieval system you control.
For new projects, the most important decision is simpler: do not start with a legacy Sonar Chat Completions tutorial. Select the API that matches the output your application actually needs, then budget for its real billing unit—tokens, tools, or successful requests.