Perplexity API Key in 2026: How to Get One, Pricing, and What Replaced Sonar
Guide

Perplexity API Key in 2026: How to Get One, Pricing, and What Replaced Sonar

How to generate a Perplexity API key in the API Console, make a first call, what the API costs per token and per search, usage tiers, and the move from Sonar.

To get a Perplexity API key, sign in at console.perplexity.ai, create or select a project, open API Keys and click Generate API Key. Copy the key before you leave the page, because the console shows it in full only once. The key is free, but the API is prepaid, and a Perplexity Pro subscription does not include API credits. This guide covers the setup, a first request, what the API costs, the usage tiers, common errors, and what happened to the Sonar API.

How to Get a Perplexity API Key

Step 1: Open the API Console. Go to console.perplexity.ai and sign in. The console is separate from the Perplexity chat app and has its own billing.

Step 2: Create or select a project. A project is your workspace in the console. It holds the API keys, the payment method, team members and usage reports. You have to create one before you can generate a key.

Step 3: Add credits. Billing is prepaid. Open Billing, add a card (payments run through Stripe, and adding a card does not charge it), then buy credits. You need purchased credits before you can call the Agent API. Turn on auto reload so the balance tops up when it falls below a threshold you set.

Step 4: Generate the key. Open API Keys and click Generate API Key. Keys start with pplx-. Copy it before you leave the page, since the full key is shown only once.

Step 5: Store it as an environment variable. The Perplexity SDK reads PERPLEXITY_API_KEY automatically.

export PERPLEXITY_API_KEY="your_api_key_here"

Five steps to get a Perplexity API key: open console.perplexity.ai, create a project, buy prepaid credits and turn on auto reload, generate a key on the API Keys page, and set PERPLEXITY_API_KEY

Perplexity suggests rotating keys about every 90 days: generate the new key, update your apps, confirm it works, then revoke the old one. A revoked key cannot be recovered.

This short video shows the key being created. Perplexity has reorganized its developer pages this year, so if the screens differ, follow the steps above.

Your First Perplexity API Call

Perplexity's main API is now the Agent API at https://api.perplexity.ai/v1/agent. You send an input and an effort level, and it searches the web and returns an answer with citations. The key goes in a standard Bearer header:

curl https://api.perplexity.ai/v1/agent \
  -H "Authorization: Bearer $PERPLEXITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "effort": "low",
    "input": "What changed in the EU AI Act this year?"
  }'

And the same request with the official Python SDK, installed with pip install perplexityai:

from perplexity import Perplexity

# Reads PERPLEXITY_API_KEY from the environment
client = Perplexity()

response = client.responses.create(
    effort="low",
    input="What changed in the EU AI Act this year?",
)

print(response.output_text)

The Agent API also supports the OpenAI Responses interface. Perplexity's docs say POST /v1/responses is an alias for /v1/agent, so the OpenAI SDK works with the base URL set to https://api.perplexity.ai/v1, though some defaults differ.

The effort level picks the model, tools and depth for you:

EffortBuilt forMax steps
fastQuick factual lookups with minimal latency1
lowBalanced research with search and URL fetching5
mediumIn-depth, multi-step research15
highMaximum-depth research40
xhighOpen-ended agentic work with a code sandbox300

Your key also works on the other APIs in the console, including the Search API (raw ranked results from POST /search) and the Orchestrator API, which routes requests to OpenAI, Anthropic, Google and other models through one key.

What Happened to the Sonar API

Most older tutorials tell you to call a model named sonar or sonar-pro through chat completions. That is out of date. Perplexity's docs say Sonar Chat Completions support ended on September 27, 2026.

Existing code has not all stopped. According to the migration guide, synchronous and streaming Sonar requests keep working because they are being reformulated as Agent API requests, rolling out gradually by model. Asynchronous Sonar requests are no longer supported. Perplexity recommends the Agent API for every new project.

Mapping from old Sonar models to Agent API effort levels: sonar and sonar-pro map to effort fast, sonar-reasoning-pro maps to effort low, and sonar-deep-research maps to effort high

Migrating is a small change. The endpoint becomes /v1/agent, messages becomes input, model is replaced by effort, and max_tokens is renamed max_output_tokens. Sources come back as a separate search_results item, with numbered markers in the answer text.

Perplexity API Pricing

An Agent API request has two costs: the tokens the model reads and writes, and a fee for each tool call. These are Perplexity's listed tool and search fees as of November 2026:

ItemListed price
Web search tool$2.50 per 1,000 calls
Web search tool, Fast Search$1.00 per 1,000 calls
Fetch URL tool$0.50 per 1,000 calls
People search and finance search tools$5.00 per 1,000 calls
Code sandbox$0.03 per started 20-minute block
Search API$5.00 per 1,000 requests
Search API, Fast Search$1.00 per 1,000 requests

Token rates depend on the model. A selection from the Agent API model list, per million tokens:

ModelInput / 1MOutput / 1M
openai/gpt-6-luna$0.10$0.50
perplexity/glm-5.3-flash$0.15$0.50
perplexity/sonar$0.25$2.50
perplexity/glm-5.3$1.40$4.40
openai/gpt-6.2-sol$2.00$10.00
anthropic/claude-sonnet-5-5$2.00$10.00
xai/grok-4.7$2.00$6.00

The OpenAI and Grok rates shown are for standard-length prompts; both rise on very long ones. Supported OpenAI models can also run on a flex tier at half the token price or a priority tier at double.

A worked example. The fast effort level runs on openai/gpt-6-luna with one Fast Search. If a lookup uses 2,000 input tokens and 300 output tokens, that is about $0.0004 in tokens plus $0.001 for the search, or roughly $1.40 per 1,000 lookups. Higher effort levels take more steps and more tool calls, so cost per request climbs quickly. Perplexity does not publish a fixed price per effort level.

The Search API is simpler: 10,000 standard requests in a month cost $50. It bills per successful request, even when a request carries several queries.

Rate Limits and Usage Tiers

Your tier depends on the total credits you have ever purchased, not your current balance. Tiers go up automatically and never go back down.

TierCredits purchasedAgent API requests / secondTokens / minute, per model
Tier 0$015 million
Tier 1$5036 million
Tier 2$25088 million
Tier 3$5001710 million
Tier 4$1,0003313 million
Tier 5$5,0003316 million

The Search API has the same limit on every tier: 50 query units per second, where each query in a request counts as one unit. On the Orchestrator API, some models require a minimum tier, and a request below it returns a 402 error.

Is the Perplexity API Free?

No. There is no ongoing free tier. Three things are worth knowing before you go looking for one:

  • Pro does not include API credits. Perplexity Pro costs $20 a month or $200 a year, and the API docs state that a subscription does not include API credits and is not required to use the API. Older guides mention a monthly API credit for Pro subscribers; the current docs do not.
  • Some new accounts get a sign-up credit. It is a one-time credit that expires 60 days after it is added. Perplexity does not publish the amount, and sign-up credit alone does not unlock the Agent API or the Orchestrator API. You need purchased credits for those.
  • Keys are blocked at zero. When the balance runs out, your API keys stop working until you add credits.

Perplexity has also run a startup program with API credits for companies referred by an approved partner. We could not find the offer on Perplexity's own site in November 2026, so check our Perplexity for Startups page for its current status before counting on it.

If you want Perplexity for your own research and not for code, the routes to a free Pro subscription are on our Perplexity Pro free page. If you need a no-cost API to prototype with, our free AI API comparison lists the providers that have one.

Common Perplexity API Errors

StatusWhat it meansFix
401 UnauthorizedThe key is missing, mistyped or deletedSend a current key as Authorization: Bearer
402 Payment RequiredThe account is out of credits, or your tier is below the model's minimumAdd credits on the Billing page and turn on auto reload
404 Not FoundOften a model ID without its provider prefixUse openai/gpt-6-luna, not gpt-6-luna
429 Too Many RequestsA rate limit was exceededWait for the Retry-After interval, then back off with jitter
5xx and timeoutsUsually temporaryRetry with backoff and log the X-Request-ID header for support

Frequently Asked Questions

How do I get a Perplexity API key?

Sign in at console.perplexity.ai, create or select a project, open API Keys and click Generate API Key. Copy it before leaving the page, because the full key is shown only once. Buy API credits before calling the Agent API.

Is the Perplexity API free?

No. The key is free to create, but usage is prepaid. Some new accounts receive a one-time sign-up credit that expires after 60 days, and it does not unlock the Agent API on its own.

Does Perplexity Pro include API access?

No. Perplexity's API docs say a Pro or Max subscription does not include API credits and is not required to use the API. API credits are bought separately in the API Console.

How much does the Perplexity API cost?

As of November 2026, the Agent API bills model tokens plus tool fees, such as $2.50 per 1,000 web searches or $1.00 with Fast Search. The Search API costs $5.00 per 1,000 requests. Token rates start at $0.10 per million input tokens on openai/gpt-6-luna.

Is the Sonar API still available?

Perplexity says Sonar Chat Completions support ended on September 27, 2026. Synchronous and streaming Sonar requests still work because they are being reformulated as Agent API requests, but asynchronous ones are no longer supported. New projects should use the Agent API.

Can I use the OpenAI SDK with the Perplexity API?

Yes. The Agent API supports the OpenAI Responses interface at https://api.perplexity.ai/v1, and the Orchestrator API accepts OpenAI Chat Completions, OpenAI Responses and Anthropic Messages formats. Some defaults differ from OpenAI.

What happens when my Perplexity API credits run out?

Your API keys are blocked until you add credits, and requests return a 402 error. Turn on auto reload in the Billing page so the balance tops up at a threshold you choose.

What are the Perplexity API rate limits?

They depend on your usage tier. A new account at Tier 0 gets 1 Agent API request per second. Tier 1, after $50 in credit purchases, gets 3, rising to 33 at Tier 4 after $1,000. The Search API allows 50 query units per second on every tier.

Next Steps

Create a project, buy a small amount of credit, generate a key and run the curl example at the fast or low effort level. Check the Billing page afterwards to see what a real request cost you before you raise the effort. If you are comparing providers, see our guides to the OpenAI API key and the Grok API, which has its own web search tool. For the voice side of a product, see the ElevenLabs pricing page and the ElevenLabs startup grant.

Brady Heinrich Written by Brady Heinrich, Founder of Credit for Startups

Related Articles

Join 7,000+ startup founders

Get monthly updates on new credits, perks, and funding opportunities. Join founders who've already discovered over $10M in startup resources.

Monthly Refreshes
Get curated updates on new funding opportunities, exclusive deals, and early access to upcoming startup resources.
No spam
Just valuable funding opportunities and resources. One email per month, and you can unsubscribe anytime.

Takes 10 seconds

We ask once and remember your answers.