Open sourceZero runtime depsYour keysYour process
Open sourceRoute · Fallback · Ship

LLM calls that never go down.

Automatic fallbacks across OpenAI, Anthropic, Groq and local models — with attempts, cost and cache on every response.

Get started
$npm i llm-sdk-js
Live failoverawait llm.complete("Summarise this.")
01 · REQUEST
llm.complete()"Summarise this."
02 · PRIMARY✕ 503
openai/gpt-4oUnavailable — moving on
03 · FALLBACK✓ 200
anthropic/claude-sonnet-4-5Answered
04 · RESPONSE
2 attempts$0.0042412ms

Your user never sees step 02.

Works with
OpenAI
Anthropic
Groq
Ollama
Mock
OpenAI-compat.
01 / Features

Everything a model call needs. Nothing it doesn’t.

Routes, fallbacks, cache, cost and test doubles — one function, in your own code.

llm-sdkyour appopenai · 503groq · timeoutanthropic200request
01.1 / Failover

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.

your keysk-••••directmodel providerno hopgateway
01.2 / Your keys

Not a gateway. Not a proxy.

Runs in your process with your API keys, over fetch. No hop. No signup. Nobody else sees your prompts.

keyttl 24hresponsecall 1 · missprovidercall 2 · hit · $0/cache
01.3 / Cache

Pay for the same prompt once

Deterministic key from model plus messages. Set cache: { ttl: "24h" } and repeats come back at zero cost.

llm.route("fast")
→ groq/llama-3.3-70b
01.4 / Routes

Name the tradeoff once

fast / smart / cheap in one config. Route names are typed, so a typo fails at compile time.

0RUNTIME DEPS
01.5 / Library

Zero runtime dependencies

"dependencies": {} — nothing to audit but the router itself.

RES.COST$0.0042
usagelatencyMscachedattempts
01.6 / Observability

Every response is priced

Usage, cost, latency and the full attempts trace — no wrapper, no vendor dashboard.

$ npm test
✓falls back to mock/ok
✓records both attempts
0 NETWORK CALLS
01.7 / Testing

Tests without a network

The mock provider answers from a queue you control — failures included.

01.8 / Providers5 + any

Bring the models you already use.

Start with one, add fallbacks later. Any OpenAI-compatible endpoint works with a baseURL, and local models never leave your machine.

OpenAI
Anthropic
Groq
Ollama · local
Mock
Compatible
02 / Quickstart

One import.
One function.

createRouter is the whole entry point. Model strings, not classes.

Read the guide
BASIC.TSTYPESCRIPT
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)

Ship the call.
Survive the outage.

Routes, fallbacks, cache and cost — without an agent framework.

Get started
$npm i llm-sdk-js