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