Perplexity API Error Codes Explained: 400, 401, 429, 5xx and Fixes

Every status code the Perplexity API returns, what actually causes it, whether it is safe to retry, and how to tell a bug in your request from an outage on Perplexity's side.

9 min read
Staff Pick

📡 Monitor your APIs — know when they go down before your users do

Better Stack checks uptime every 30 seconds with instant Slack, email & SMS alerts. Free tier available.

Start Free →

Affiliate link — we may earn a commission at no extra cost to you

Perplexity's API is prepaid and search-backed, and both facts leak into its error codes: the two failures teams actually hit are an empty credit balance and a model name that was renamed out from under them.

The single most expensive mistake in Perplexity integrations is treating every non-200 the same way: one generic catch block, one blind retry loop. Half of Perplexity's error codes are deterministic — retrying them cannot succeed, it only burns quota and hides the real cause. This guide splits them into the ones you fix, the ones you wait out, and the ones you fail over on.

Quick triage: 4xx is your request or your account. 5xx is Perplexity. If you are seeing 5xx across more than one API key, check live Perplexity status before you change a line of code.

Every Perplexity API Error Code

Codes below are what Perplexity returns in production today. Response shapes drift as APIs version, so log the full body — the message text usually names the failing field, and that detail is what turns a 20-minute debug into a 20-second one.

CodeTypeWhat causes itFix
400Bad RequestMalformed body, or a search filter parameter Perplexity does not accept on that model.Validate the payload; search-specific params are model-dependent. Do not retry.
401UnauthorizedInvalid, revoked, or unactivated key — and in practice, frequently a key with no credits behind it.Confirm the key, then confirm the credit balance. A funded, valid key is required for either check to pass.
402Insufficient creditsPrepaid balance is exhausted. Perplexity does not run negative.Top up in API settings and enable auto-reload. Backoff cannot clear a 402.
404Not FoundModel name retired or renamed — the sonar family has been renamed more than once.Move to a current model name; retired identifiers 404 permanently.
422Unprocessable EntityParameter out of range or an unsupported combination such as conflicting recency and domain filters.Simplify the filters and resend.
429Too Many RequestsPer-minute request ceiling for your tier exceeded.Backoff with jitter and cap concurrency. Tiers rise with cumulative spend.
500Internal Server ErrorPerplexity-side fault, sometimes in the search layer rather than the model.Retry twice with backoff, then degrade to a non-search model elsewhere.
503Service UnavailableCapacity saturated or maintenance.Fail over; check the status page before editing code.
504Gateway TimeoutDeep-research and heavy-search requests can exceed the gateway window.Stream, narrow the query, or use a lighter sonar tier for latency-sensitive paths.
529OverloadedUpstream capacity pressure surfaced during traffic spikes.Treat like a 503: back off briefly and fail over if it persists.
📡
Recommended

Catch Error-Rate Spikes Before Support Tickets Do

Track status-code distribution and latency on your Perplexity endpoint continuously, so a shift from 200s to 429s or 503s shows up on a dashboard instead of in a customer email.

Try Better Stack Free →

The Perplexity Error That Wastes the Most Time

Perplexity is credit-metered rather than invoice-billed, so the error that stops most integrations is a 401 or 402 caused by a zero balance on an otherwise valid key. It looks identical to an authentication bug from the client side, which sends people rotating keys for an hour. Check the credit balance in API settings before you touch the key — and set a top-up alert, because unlike a rate limit, this failure never clears on its own.

Retry or Don't: The Decision Table

This is the part most error handling gets wrong. Retrying a deterministic error is strictly worse than failing fast — it delays the real signal and, on paid tiers, multiplies the bill.

BehaviourCodesWhat to do
Never retry400, 401, 402, 404Deterministic. Fix the request, the key, the model name, or the account state. Surface the error immediately.
Retry with backoff422, 429Transient. Exponential backoff with jitter, honor retry-after, cap at four or five attempts.
Fail over500, 503, 504, 529Perplexity-side. Route to your backup provider on the second consecutive failure rather than queueing requests behind an outage.

Error Handling That Distinguishes All Three

One handler, three behaviours. The important line is the one that does not retry.

const FATAL = new Set([400, 401, 402, 404]);

async function callPerplexity(body, attempt = 0) {
  const res = await fetch('https://api.perplexity.ai/chat/completions', {
    method: 'POST',
    headers: { 'Authorization': `Bearer ${process.env.PERPLEXITY_API_KEY}`, 'Content-Type': 'application/json' },
    body: JSON.stringify(body),
  });

  if (res.ok) return res.json();

  // Log the body once — it names the failing field on every 4xx
  const detail = await res.text();

  if (FATAL.has(res.status)) {
    throw new Error(`Perplexity error ${res.status} (not retryable): ${detail}`);
  }

  if (res.status >= 500) {
    // Perplexity-side: fail over rather than queue behind an outage
    if (attempt >= 1) return callFallbackProvider(body);
  }

  if (attempt >= 4) throw new Error(`Perplexity failed after retries: ${detail}`);

  const retryAfter = Number(res.headers.get('retry-after')) || 0;
  const backoff = retryAfter * 1000 || (2 ** attempt) * 500 + Math.random() * 500;
  await new Promise((r) => setTimeout(r, backoff));
  return callPerplexity(body, attempt + 1);
}

Note the fallback triggers on the second 5xx, not the first. A single 500 is often a one-off on a single host; two in a row is an incident, and that is the point where switching providers beats waiting.

🔐
Recommended

Keep Provider Keys Rotatable

Testing a second key is the fastest way to prove a 401 or 429 is yours rather than theirs. Store and rotate provider credentials properly instead of pasting them into env files.

Try 1Password Free →

Your Error or Theirs? A 60-Second Check

  1. Read the status class. 4xx is you, 5xx is Perplexity. Nothing else in this list matters if you skip this step.
  2. Log the response body. Perplexity names the offending field or model in the message — the status code alone is rarely enough.
  3. Try a second API key. If a different key on a different account works, the problem is your account state or quota.
  4. Try a different model. A working sibling model rules out an infrastructure-wide incident and points at naming, context length, or per-model capacity.
  5. Check status.perplexity.com and live Perplexity monitoring for a confirmed incident before rolling back your own deploy.

For the outage-side playbook, see our Is Perplexity Down? guide. For quota specifically, the Perplexity rate limit guide covers headers and tier ceilings in depth.

Where to Send Traffic When Perplexity Returns 5xx

Fallbacks only help if they are configured before the incident. Each of these runs on independent infrastructure and an independent quota pool, so a Perplexity 503 does not follow you there.

OpenAI

Independent infrastructure and quota pool. Route overflow here when Perplexity returns 5xx.

Check OpenAI status →

Groq

Independent infrastructure and quota pool. Route overflow here when Perplexity returns 5xx.

Check Groq status →

Together AI

Independent infrastructure and quota pool. Route overflow here when Perplexity returns 5xx.

Check Together AI status →

Frequently Asked Questions

What do Perplexity API error codes mean?

Perplexity returns 400 for malformed requests, 401 for an invalid or unfunded key, 402 when the prepaid credit balance is empty, 404 for a retired model name, 422 for invalid parameter combinations, 429 for rate limits, and 5xx including 529 for Perplexity-side capacity problems. Only 429, 5xx and 529 are candidates for automatic retry.

Why does my valid Perplexity API key return 401?

Because a Perplexity key is only usable while credits sit behind it. A correctly formatted, non-revoked key can still be rejected when the prepaid balance hits zero, which looks exactly like an authentication failure from the client. Check the credit balance in API settings before rotating the key.

How do I fix insufficient credits on the Perplexity API?

Top up the prepaid balance in API settings and turn on automatic reload so the balance never reaches zero silently. This error is account state rather than a rate window, so retries and exponential backoff will never clear it — every attempt fails identically until credits are added.

Why did my Perplexity sonar model stop working?

Perplexity has renamed and retired members of the sonar family more than once, and retired identifiers return 404 permanently rather than falling back to a successor. Keep the model name in configuration instead of hardcoded in application code so a rename is a config change, not a redeploy.

Is a Perplexity 500 error my fault?

No. A 500 is a Perplexity-side fault, and because the API is search-backed it can originate in the retrieval layer rather than the model itself. Retry twice with backoff, and if it persists across keys check status.perplexity.com before changing any of your own code.

Related Perplexity Guides

Stop Guessing Which Side the Error Is On

API Status Check monitors Perplexity and every other provider in your stack, so a bad deploy and a provider incident never look the same again.

Start Your Free Trial →

Alert Pro

14-day free trial

Stop checking — get alerted instantly

Next time Perplexity goes down, you'll know in under 60 seconds — not when your users start complaining.

  • Email alerts for Perplexity + 9 more APIs
  • $0 due today for trial
  • Cancel anytime — $9/mo after trial

🌐 Can't Access Perplexity?

If Perplexity is working for others but not for you, it might be an ISP or regional issue. A VPN can help bypass network-level blocks and routing problems.

🔒

Troubleshoot with a VPN

Connect from a different region to test if the issue is local to your network. Also protects your connection on public Wi-Fi.

Try NordVPN — 30-Day Money-Back Guarantee
🔑

Secure Your Perplexity Account

Service outages are a common time for phishing attacks. Use a password manager to keep unique, strong passwords for every account.

Try NordPass — Free Password Manager
Quick ISP test: Try accessing Perplexity on mobile data (Wi-Fi off). If it works, the issue is with your ISP or local network.

⏳ While You Wait — Try These Alternatives

🛠 Tools We Use & Recommend

Tested across our own infrastructure monitoring 200+ APIs daily

SEMrushBest for SEO

SEO & Site Performance Monitoring

Used by 10M+ marketers

Track your site health, uptime, search rankings, and competitor movements from one dashboard.

We use SEMrush to track how our API status pages rank and catch site health issues early.

From $129.95/moTry SEMrush Free
View full comparison & more tools →Affiliate links — we earn a commission at no extra cost to you