Cohere API Failover: Keep Serving When Cohere Goes Down

Checking whether Cohere 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.

10 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

Cohere is unusual in that most production dependencies on it are not chat. Embed and Rerank sit inside retrieval pipelines, and those have a failover constraint generation does not: you cannot swap an embedding model mid-flight without invalidating the vectors already in your index.

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 Cohere Fails

These need different responses, and a failover path that treats them identically will either flap constantly or never fire at all.

Failure modeWhat you seeCorrect response
Hard outage500, 502, 503 across unrelated requests; connection refusedTrip the breaker after 2–3 failures and send everything to the fallback
Quota / rate limit429 with a retry-after header, often only on one model or keyBack off and queue first; fail over only when backoff is exhausted — this one is usually you, not Cohere
Silent degradationHTTP 200, but time-to-first-token is 10–50x baseline; streams that stall mid-responseTreat 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. Cohere 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 trial

Stop checking — get alerted instantly

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

  • Email alerts for Cohere + 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 Cohere key on the same account is not one.

FallbackWhy it worksWhat it costs you
A second embedding provider with a parallel indexThe only real failover for Embed. Dual-write vectors at ingest so a second index is already warm when Cohere is unavailable.Roughly doubles embedding cost and storage
Cross-encoder or BM25 rerank fallbackFor Rerank outages: a local cross-encoder, or plain lexical scoring. Worse ordering, but retrieval keeps working.Measurable relevance drop; acceptable, not invisible
OpenAI or Anthropic for CommandStraightforward for the generation half of the stack, where nothing is persisted.Different tool-call and citation formats

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

Cohere exposes Command for generation, plus Embed and Rerank at https://api.cohere.com/v2. 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: Cohere 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('cohere', 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 Cohere 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 Cohere:

  • Embeddings are not interchangeableCohere embed-v4 vectors and OpenAI vectors are not in the same space. You cannot query a Cohere-built index with an OpenAI query vector — the results are noise, not degraded results, and nothing in the response says so.
  • Rerank failure degrades quality, not availabilityIf Rerank fails and you return unranked retrieval results, the request succeeds and the answers get quietly worse. This never shows up in an error-rate dashboard; it shows up in user complaints two weeks later.
  • v1 and v2 response shapes differCohere's own API versions changed the chat response format. Pin the version explicitly in the client and in the fallback path so a library upgrade does not become an incident.

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:

  1. Break the key. Point the primary client at an invalid Cohere 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.
  2. Break the clock. Set PRIMARY_TIMEOUT_MS to 1ms and confirm the latency path trips too. Most implementations handle errors and quietly ignore slowness.
  3. 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.cohere.com tells you after Cohere 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 Cohere 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 Cohere's.

Is a second Cohere 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 Cohere capacity in a genuinely separate deployment.

How do I know Cohere is down before my users tell me?

Not from status.cohere.com. 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 Cohere 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.

How do I fail over Cohere embeddings without rebuilding my index?

You do not — that is why this one is planned at ingest rather than at incident. The workable pattern is dual-write: embed with two providers when a document is ingested, store both vectors, and flip the query side to the secondary index when Cohere is unavailable. It costs roughly double on embedding and storage. The alternative is accepting that retrieval is down for the duration, which for a RAG product usually means the product is down.

Related Guides

Know Before Your Users Do

A failover path is only as fast as the signal that triggers it. API Status Check probes Cohere 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

Better StackBest for API Teams

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.

Free tier · Paid from $24/moStart Free Monitoring
1PasswordBest for Credential Security

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.

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