One outage never reaches your users
Attempts walk the chain in order and stop at the first success. If all fail, you get AllProvidersFailed with every error attached.
Automatic fallbacks across OpenAI, Anthropic, Groq and local models — with attempts, cost and cache on every response.
Your user never sees step 02.
Routes, fallbacks, cache, cost and test doubles — one function, in your own code.
Attempts walk the chain in order and stop at the first success. If all fail, you get AllProvidersFailed with every error attached.
Runs in your process with your API keys, over fetch. No hop. No signup. Nobody else sees your prompts.
Deterministic key from model plus messages. Set cache: { ttl: "24h" } and repeats come back at zero cost.
fast / smart / cheap in one config. Route names are typed, so a typo fails at compile time.
"dependencies": {} — nothing to audit but the router itself.
Usage, cost, latency and the full attempts trace — no wrapper, no vendor dashboard.
The mock provider answers from a queue you control — failures included.
Start with one, add fallbacks later. Any OpenAI-compatible endpoint works with a baseURL, and local models never leave your machine.
createRouter is the whole entry point. Model strings, not classes.
import { createRouter } from "llm-sdk-js" const llm = createRouter({ primary: "anthropic/claude-sonnet-4-5", fallbacks: ["openai/gpt-4o"], }) const res = await llm.complete("Summarise this.") console.log(res.provider, res.attempts)
Routes, fallbacks, cache and cost — without an agent framework.