Relay  //  reliable LLM API delivery

Your AI calls keepworking when providers don't.

I rewrote retry-and-failover for LLM APIs in four projects, each time with a new bug. Relay is the version you import instead — same SDK shape, plus auto-retry, provider failover, and a cache that stops you paying twice.

relay.dev / logslive
14:03:21relay POST /v1/messages model=claude-sonnet-4-6

Live stream from a relay account — same shape you see in your dashboard. Newest event types in at the top, older ones fade out of the bottom of the window.

edge proxy · ~30ms overhead · BYOKanthropic · openai · gemini · failover chain
AnthropicOpenAIMistralGeminiCohereDeepSeekGroqTogetherAnthropicOpenAIMistralGeminiCohereDeepSeekGroqTogetherAnthropicOpenAIMistralGeminiCohereDeepSeekGroqTogether

— The reality

Every AI builder ships the same reliability problems from scratch.

  1. 01  ·  Outage

    99.5%

    Anthropic real uptime vs 99.9% SLA, 2026 YTD

    Provider goes down — your product goes with it.

    Anthropic drops thirty minutes. Your agent stops mid-task. Your user closes the tab. Your churn ticks up. Repeat next month when OpenAI has its own bad day.

  2. 02  ·  Rate limit

    529

    the status code you see during every demo

    Overloaded, right when traffic spikes.

    Peak hours are exactly when you can't afford retries you don't have. Every 529 you don't catch is a request that quietly dies and a user who quietly leaves.

  3. 03  ·  Boilerplate

    times the average AI dev rewrites their retry loop

    You wrote exponential backoff again. And again.

    Every project ships its own retry loop. Half of them get the jitter wrong. None of them failover to a backup provider — the model id wouldn't even match.

  4. 04  ·  Cost

    38%

    of prompts repeated within the same hour, observed

    You paid twice for the same answer.

    Same system prompt, same user input — different request id. Without caching, every duplicate burns tokens you'll never see again on a bill that grows linearly.

scroll →01 / 04

— The fix

Delete the retry file. Keep shipping.

Replace @anthropic-ai/sdk with @relay-api/sdk. Same method signatures, same streaming. Retry, failover and caching become someone else's problem.

Before
without-relay.ts
01// 47 lines of retry boilerplate, written badly.
02async function callLLM(body) {
03 let attempt = 0;
04 while (attempt < 3) {
05 try {
06 return await anthropic.messages.create(body);
07 } catch (e) {
08 attempt++;
09 await sleep(2 ** attempt * 1000);
10 }
11 }
12 throw new Error('Gave up');
13}
14// Still no failover. No cache. No metrics.
After
with-relay.ts
01// One line. Reliability handled.
02const reply = await llm.messages.create(body);
03
04// What Relay just did for you:
05// ✓ exponential backoff with jitter
06// ✓ failover Anthropic → OpenAI on 5xx
07// ✓ exact + semantic cache lookup
08// ✓ streaming preserved end-to-end
09// ✓ live metrics in your dashboard
April 12, 2026 · 14:03 UTC
anthropicOKrelayOK

OnApril 12,Anthropicwentdarkfortwenty-nineminutes.FourthousandsevenhundredandeighteenRelaycallsfloweduninterrupted.

— elapsed14:03start 14:03 · recover 14:32
00min

minutes Anthropic returned 5xx

0reqs

Relay calls succeeded via failover to OpenAI

— What you get

Six features. One install.

  • 01/Failover

    Automatic provider failover, no model mapping required.

    When Anthropic returns 5xx, Relay routes the next attempt to OpenAI — or any chain you configure per request. Model ids are translated on the way out, so you keep writing claude-sonnet-4-6 either way.

    claude-sonnet-4-6 → gpt-4o on 529
  • 02/Retry

    Exponential backoff with decorrelated jitter.

    Decorrelated jitter (the algorithm AWS uses internally) prevents retry storms when a whole region 429s at once. Configurable per request, surfaced on every response.

    attempt 1 → 250ms → 612ms → 1.4s
  • 03/Cache

    Smart caching for repeat prompts.

    Exact-match on day one. Semantic caching with embeddings on Hobby and up. Stop paying twice for prompts that arrive twice — most agent loops hit the same system message four times a session.

    cache hit · 4ms · $0
  • 04/Telemetry

    Every request lands in your dashboard.

    Latency, cost, cache hit rate, retries, failover events — searchable, filterable, streaming as it happens. The data layer is open: read it through Supabase if you'd rather build your own.

    msg_8adac369 200 p95=487ms
  • 05/BYOK

    Bring your own keys, encrypted at rest.

    You keep paying Anthropic and OpenAI directly — Relay never sees the invoice. Your provider keys live encrypted in Cloudflare KV and only decrypt inside the edge worker at request time. They are never written to logs.

    keys encrypted · never logged
  • 06/Edge

    Global edge proxy, under thirty milliseconds.

    Runs on Cloudflare Workers across 300+ cities. The proxy executes in the region geographically closest to your user, so we add ~28ms p95 — less than most Postgres connections.

    ~28ms p95 · 300+ cities · workers

— How it works

From npm i to first reliable call in four steps.

  1. 01

    Drop in the SDK.

    Swap @anthropic-ai/sdk for @relay-api/sdk. Same method signatures, same streaming. Your existing code keeps working — only the import line moves.

    npm i @relay-api/sdk

  2. 02

    Plug in your providers.

    Paste your Anthropic, OpenAI or Gemini keys at /signup. We encrypt them in Cloudflare KV at rest and never log plaintext. You can revoke any time.

    anthropic ✓ openai ✓ gemini ✓

  3. 03

    Ship through the edge.

    Every call hits a Cloudflare Worker in 300+ cities. Cache lookup, retry policy and failover happen before bytes leave the region nearest the user.

    POST /v1/messages → ~28ms

  4. 04

    Watch it stay up.

    Open the dashboard. Filter requests by status, model, latency or cost. The next outage shows as a green failover row, not a red incident.

    uptime 99.99% failovers handled 137

— Pricing

Free until you ship. Then small.

You only pay for the proxy. Provider charges (Anthropic, OpenAI, Gemini) stay on your own card under BYOK.

Free

Hack on a side project.

$0/ month
  • 1,000 requests / month
  • Exact-match cache
  • Anthropic + OpenAI failover
  • Community support
Start free
Hobby

Indie devs shipping to real users.

$19/ month
  • 50,000 requests / month
  • Exact + semantic cache
  • Streaming & SSE proxy
  • Email support · 48h
Choose Hobby
most chosen
Prorecommended

Small teams in production.

$49/ month
  • 250,000 requests / month
  • Custom retry policies
  • Multi-key routing
  • Email support · 24h
  • All Hobby features
Choose Pro
Scale

When downtime costs real money.

$199/ month
  • 1,000,000 requests / month
  • Custom cache rules
  • Bring-your-own providers
  • Priority support · 4h
  • Dedicated Slack channel
Talk to us

Need more than 1M requests, on-prem, audit logs, SOC 2 questions? Email me directly — I'll write a quote inside 24h.

— FAQ

Honest answers, upfront.

— Waitlist

Be the first to ship on a reliable LLM stack.

I'm Alikhan. I'm hand-onboarding the first hundred builders myself — pairing on the integration, listening to the bugs that ate your evening, shipping fixes the same day.

Drop your email. You'll hear from me when access opens — usually within a week — with six months of Pro on the house and a short ask: what reliability pain do you wish would vanish first?

— Alikhan

— Join the waitlist

Get an early-access invite.

487builders waiting
$0setup cost
<5 minto first call