Just give me a model. swoosh routes each task by intent and policy — declare what it needs, it picks the model, explains every rejection, and falls back automatically.
await createRouter()Requirements, not model names — modalities, features, token estimates.
await router.generateObject({
task: "recipe.extract",
inputModalities: ["text","image"],
requiresFeatures: ["structured_output"],
})
Cost ceilings, latency, benchmarks, or an LLM judge — enforced at plan time.
preference: "cheapest",
constraints: {
maxCostUsd: 0.01,
maxLatencyClass: "standard",
}
It walks the ranked routes until one succeeds, with the attempt log.
// attempts
[{ model: "gemini", ok: true }]
// or → next route on fail
The batteries-included front door. createRouter() gives you the enriched default catalog and AI-SDK providers auto-wired from your API keys — and re-exports the whole toolkit, so one install is all most apps need.
Zero-dependency core — intent + policy routing, inspectable plans, fallback.
Docs → @swoosh-dev/capabilitiesEnriched model dataset — models.dev plus web_search, latency, quality, benchmarks.
Docs → @swoosh-dev/judgeDynamic policies — classify the prompt with an LLM judge, route by verdict.
Docs → @swoosh-dev/ai-sdkThe Vercel AI SDK adapter, separate so the core stays dependency-free.
Docs →Set a ceiling; over-budget models are rejected before a token is spent.
byBenchmark("swe_bench") — a name or a composite scoring function.
Classify the prompt, route by verdict — coding → best, chat → cheapest.
Pull pricing & limits from models.dev, or bring your own DB.
Built-ins, benchmark ranking, or any function you write.
Every rejection carries a human-readable reason.
Walks ranked routes; returns the attempt history.
Pass a user's keys; it wires whatever they brought.
Plain Promises, fully typed, no framework to adopt.