Perplexity API Failover: Keep Serving When Perplexity Goes Down
Checking whether Perplexity is down takes ten seconds. Having somewhere for the traffic to go while it is down is the part that has to be built before the incident — this guide is that build.
📡 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.
Affiliate link — we may earn a commission at no extra cost to you
Perplexity's Sonar API is bought for one thing other LLM APIs do not do out of the box: live web grounding with citations. That makes a naive failover actively dangerous — swapping to a non-grounded model returns fluent text with no sources, and your users cannot tell the difference.
The short version
A failover path is three decisions, not one: what counts as a failure, where the traffic goes, and what the user sees while it is there. Most teams build the second one, skip the first and third, and discover during the outage that the breaker never tripped because a 40-second response is still an HTTP 200.
The Three Ways Perplexity Fails
These need different responses, and a failover path that treats them identically will either flap constantly or never fire at all.
| Failure mode | What you see | Correct response |
|---|---|---|
| Hard outage | 500, 502, 503 across unrelated requests; connection refused | Trip the breaker after 2–3 failures and send everything to the fallback |
| Quota / rate limit | 429 with a retry-after header, often only on one model or key | Back off and queue first; fail over only when backoff is exhausted — this one is usually you, not Perplexity |
| Silent degradation | HTTP 200, but time-to-first-token is 10–50x baseline; streams that stall mid-response | Treat a latency-budget breach as a failure. Without this rule, the most common real outage never triggers failover at all |
The third row is where most incidents actually live. Perplexity rarely returns a clean 503 for an hour; it gets slow, requests pile up behind it, and the errors your users see are your own timeouts several layers up the stack.
Alert Pro
14-day free trialStop 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
Where the Traffic Should Go
A fallback is only useful if it is a genuinely independent failure domain. A second Perplexity key on the same account is not one.
| Fallback | Why it works | What it costs you |
|---|---|---|
| Brave / Bing / Exa search plus any LLM | Rebuilds the grounding yourself: retrieve, then summarise. More moving parts, but it preserves the citation guarantee your product makes. | You own the retrieval quality and the extra latency |
| Gemini or OpenAI with search tooling | Provider-native grounded search. Closest single-call replacement for Sonar. | Different citation format; parsing needs a variant |
| A plain LLM with an explicit 'no live data' disclosure | Last resort. Acceptable only if the UI clearly degrades — no citation panel, a stale-data notice. | Silently doing this is a trust bug, not a fallback |
Pick one and configure it. A ranked list of three candidates in a design doc is not a failover path; a base URL, a model id, and a tested credential is.
A Circuit Breaker You Can Paste In
Perplexity exposes the Sonar family, including the online search-grounded models at https://api.perplexity.ai. The wrapper below is deliberately small — the parts that matter are the timeout on the primary call and the half-open probe, both of which get dropped from most hand-rolled versions.
// Failover wrapper: Perplexity primary, second provider on trip.
// Key idea — a slow response is a failure too, so the timeout is part of the check.
const BREAKER = { failures: 0, openedAt: 0 };
const TRIP_AFTER = 3; // consecutive failures before we stop trying
const COOLDOWN_MS = 60_000; // how long to stay on the fallback
const PRIMARY_TIMEOUT_MS = 8_000;
const FALLBACK_TIMEOUT_MS = 30_000; // fallbacks are legitimately slower
function breakerOpen() {
if (BREAKER.failures < TRIP_AFTER) return false;
if (Date.now() - BREAKER.openedAt > COOLDOWN_MS) {
BREAKER.failures = 0; // half-open: let one probe through
return false;
}
return true;
}
export async function complete(messages) {
if (!breakerOpen()) {
try {
const res = await withTimeout(
primary.chat.completions.create({ model: PRIMARY_MODEL, messages }),
PRIMARY_TIMEOUT_MS,
);
BREAKER.failures = 0;
return res;
} catch (err) {
if (!isRetryable(err)) throw err; // 400s are your bug, not an outage
BREAKER.failures += 1;
if (BREAKER.failures >= TRIP_AFTER) BREAKER.openedAt = Date.now();
logFailover('perplexity', err);
}
}
return withTimeout(
fallback.chat.completions.create({ model: FALLBACK_MODEL, messages }),
FALLBACK_TIMEOUT_MS,
);
}Two things to keep when you adapt it. Do not fail over on 4xx — a 400 or 401 is your bug, and sending it to a second provider just produces the same error twice at double the cost. And keep the cooldown: without it, every request retries a dead provider and pays the full timeout before falling back, which turns a Perplexity outage into a latency outage of your own.
What Breaks the First Time It Fires
Failover paths fail on their first real invocation more often than they succeed, and the reasons are specific to Perplexity:
- Citations disappear silently — Sonar returns a
citationsarray; most fallbacks do not. If your renderer treats an empty array as 'no sources found' rather than 'grounding unavailable', you will publish unsourced claims under a UI that implies sourcing. - Search recency parameters do not port —
search_recency_filterand domain filters are Perplexity-specific. A fallback path that drops them will answer a 'this week' question with three-year-old context. - Grounded calls are slow by nature — Sonar latency includes a retrieval step, so a timeout tuned for a plain chat completion will fire constantly and trip your breaker on a healthy provider. Time the grounded path separately.
Test It Before You Need It
Untested failover is worse than none, because it converts a known outage into an unknown one. Three tests, in order of how much they are worth:
- Break the key. Point the primary client at an invalid Perplexity credential in staging and confirm traffic lands on the fallback with the output your parser expects. This catches the model-id and response-shape bugs, which are the majority.
- Break the clock. Set
PRIMARY_TIMEOUT_MSto 1ms and confirm the latency path trips too. Most implementations handle errors and quietly ignore slowness. - Run it on a schedule. Send a small share of production traffic through the fallback weekly. A path exercised once a quarter is a path that has drifted — the model was deprecated, the key expired, the parser changed.
The Hard Part Is Detection, Not Routing
Every piece of code above is downstream of one question: how fast do you know? status.perplexity.ai tells you after Perplexity has confirmed an incident, which is routinely twenty minutes into it and sometimes never for regional degradations. Your own error rate tells you once enough users have already hit it.
Independent probing from outside your stack closes that gap. It is also the only evidence you will have when you need to explain the incident to a customer — or claim credits against a contract that requires you to prove the failure was theirs.
Frequently Asked Questions
When should my app fail over from Perplexity instead of retrying?
Retry when the failure is likely transient and cheap to repeat: a single 5xx, a connection reset, a 429 with a short retry-after. Fail over when the signal says the provider itself is unhealthy — repeated 5xx across different requests, a retry-after measured in minutes, or latency that has moved an order of magnitude off baseline. The practical rule is two retries with exponential backoff and jitter, then trip. Retrying past that point does not recover the request, it just makes your outage longer than Perplexity's.
Is a second Perplexity API key a valid failover?
No, and this is the most common mistake in a first failover design. A second key on the same account shares the same infrastructure, the same region, and usually the same organisation-level quota. It protects you against exactly one failure mode — a key being revoked or exhausted — and against none of the ones that cause real incidents. Genuine failover means a different provider, or at minimum Perplexity capacity in a genuinely separate deployment.
How do I know Perplexity is down before my users tell me?
Not from status.perplexity.ai. Provider status pages are updated by the provider, after the provider has confirmed an incident, and short regional degradations frequently never appear at all. The signal that arrives first is your own: error rate and time-to-first-token on the calls you are actually making, from the region you are actually in. Independent probing is what turns 'users are complaining' into an alert that fires ten minutes earlier.
Will failing over from Perplexity change my output quality?
Almost always, and you should measure how much before the incident rather than during it. Different model families phrase things differently, follow instructions differently, and refuse different things. Keep a small evaluation set — twenty or so real requests with known-good outputs — and run it against the fallback path on a schedule. A fallback whose quality you have never checked is a guess.
Can I fall back from Perplexity to a normal LLM?
Only if the user can tell. Sonar's value is the live citations, and a plain model will happily answer the same question with confident, unsourced, possibly stale text. If you take that path, degrade the interface too: hide the citation panel, show a 'live search unavailable' notice, and prefer returning a clear error for anything where currency actually matters, like pricing or news.
Related Guides
Know Before Your Users Do
A failover path is only as fast as the signal that triggers it. API Status Check probes Perplexity and every other provider in your stack independently, so the breaker trips on measured reality instead of on a status page someone else updates.
Start Your Free Trial →🛠 Tools We Use & Recommend
Tested across our own infrastructure monitoring 200+ APIs daily
Uptime Monitoring & Incident Management
Used by 100,000+ websites
Monitors your APIs every 30 seconds. Instant alerts via Slack, email, SMS, and phone calls when something goes down.
“We use Better Stack to monitor every API on this site. It caught 23 outages last month before users reported them.”
Secrets Management & Developer Security
Trusted by 150,000+ businesses
Manage API keys, database passwords, and service tokens with CLI integration and automatic rotation.
“After covering dozens of outages caused by leaked credentials, we recommend every team use a secrets manager.”
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.”