Keep your AI agent working even when Claude goes down

Automatic fallbacks, cheaper calls and organized prompts, across Claude, Gemini and OpenAI

Splendid AI is a JavaScript package that sends your agent’s calls to Claude, Gemini or OpenAI through one function. When the provider you named is down, the call moves to the next one on your list.

It also covers what I kept writing around every call: the cost of each call in dollars, prompts kept in markdown, a cache lifetime for each half of the prompt, and handlers that act on what the model returns.

const answer = await ai({
provider: 'claude',
model: 'claude-sonnet-5',
systemPrompt: prompts.job,
prompt: renderPrompt(prompts.turn, { name, chat }),
providerOptions: { cache: { system: '1h', rounds: '5m' } },
fallbacks: [{ provider: 'gemini', model: 'gemini-3.6-flash' }],
})
answer.cost_usd

Keep answering when Claude is down

List the backups, and the call moves to the next one

I built this package while running an AI agent of my own, and fallbacks came first — Claude had an outage, and the agent still needed to work.

Any AI can go on an outage. A retry against a provider that’s out fails the same way, and the people waiting on your agent still need an answer.

fallbacks tries each backup in order:

const answer = await ai({
provider: 'claude',
model: 'claude-sonnet-5',
systemPrompt,
prompt,
fallbacks: [
{ provider: 'gemini', model: 'gemini-3.6-flash' },
{ provider: 'openai', model: 'gpt-5.6-sol' },
],
})
answer.meta.provider // 'gemini'

Only an outage moves the call on: a 429, a 5xx, a timeout or a dropped connection. A 400 means the call itself is wrong, so it throws instead of burning a second provider.

Every hop prints a line when it happens, so you know when your agent has been answering from a backup.

One call for Claude, Gemini and OpenAI

Name the provider, and the rest of the call stays the same

A backup only helps if it can take the same call. So every provider goes through ai(), and every answer comes back in one shape — text, parsed_output, usage and cost_usd.

const call = { systemPrompt, prompt, schema }
await ai({ provider: 'claude', model: 'claude-sonnet-5', ...call })
await ai({ provider: 'gemini', model: 'gemini-3.6-flash', ...call })
await ai({ provider: 'openai', model: 'gpt-5.6-sol', ...call })

When an option only works on one provider, switching throws and names the option. A swap never quietly sends a different call.

claudep is in there too. It runs Claude Code on your own subscription for your own automation, so those calls draw on your plan instead of API tokens.

Keep every call cheap and every prompt in order

The parts you write once the agent is doing real work

Each of these came out of a question my own agent raised. Click through them to see the code with Splendid AI, and without it.

cost_usd is on every result, in dollars. Turn on logUsage and each call prints a line:

const answer = await claudep({
model: 'sonnet',
prompt,
logUsage: true,
})
answer.cost_usd
[claudep] 0 cached, 0 written, 511 fresh, ~$0.0011 list, 2.4s

That call cost about a tenth of a cent. Once every call shows a number, you know what a test run burns before the invoice does.

Get Splendid AI

Take Splendid AI if this package is the one you need. Take Splendid Pro for every Splendid Labz library on one key.

Splendid AI

$99 only
Four providers behind one call, with the prompt, cache and cost engineering already done.
  • Prompts as markdown files on disk
  • A fallback chain across providers when the one you named is out
  • Tool parameters built from a schema
  • Output handlers that act on what came back
  • Cache control past a boolean, and Gemini caches you hold yourself
  • Per-call cost in USD at list rates

Splendid Pro

$199 only
Artfully crafted tools to speed up your web development workflow — includes components, layouts, styles, and utilities.
  • Everything in Splendid AI
  • All other Splendid libraries
    • Splendid Astro
    • Splendid Svelte
    • Splendid Layouts
    • Splendid Styles
    • Splendid Utils
    • Splendid Tracking

Want to try it first? Start a free 14-day trial. No card needed.

Frequently Asked Questions

Keep your agent answering when Claude doesn’t

And keep every call cheap and every prompt in order

I built this because I was running all four providers across my own projects and kept writing the same four things again in every one — the prompt loading, the fallback, the cache split, the cost line.

Try it for 30 days. If it’s not for you, ask and you get every cent back. Or start with the 14-day trial, with no card needed.

Splendid AI

$99 only
Four providers behind one call, with the prompt, cache and cost engineering already done.
  • Prompts as markdown files on disk
  • A fallback chain across providers when the one you named is out
  • Tool parameters built from a schema
  • Output handlers that act on what came back
  • Cache control past a boolean, and Gemini caches you hold yourself
  • Per-call cost in USD at list rates

Splendid Pro

$199 only
Artfully crafted tools to speed up your web development workflow — includes components, layouts, styles, and utilities.
  • Everything in Splendid AI
  • All other Splendid libraries
    • Splendid Astro
    • Splendid Svelte
    • Splendid Layouts
    • Splendid Styles
    • Splendid Utils
    • Splendid Tracking

Stay awesome,
Zell