swoosh

Point at a task. swoosh.

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.

npm i @swoosh-dev/sdk then await createRouter()
providers wired from your keys
01

How it works

three moves, no model ids
declare intent

Say what it needs

Requirements, not model names — modalities, features, token estimates.

await router.generateObject({
  task: "recipe.extract",
  inputModalities: ["text","image"],
  requiresFeatures: ["structured_output"],
})
set policy

Make the rules

Cost ceilings, latency, benchmarks, or an LLM judge — enforced at plan time.

preference: "cheapest",
constraints: {
  maxCostUsd: 0.01,
  maxLatencyClass: "standard",
}
execute

Fallback is free

It walks the ranked routes until one succeeds, with the attempt log.

// attempts
[{ model: "gemini", ok: true }]
// or → next route on fail
02

Every decision, on record

plan() — inspect before you spend
№ModelProviderStatusReason
01gemini-2.5-flashgoogleselectedLowest cost among text+image candidates.
02claude-haiku-4-5anthropicfallbackNext-cheapest; tried on failure.
03claude-opus-4-8anthropicrejectedEstimated cost exceeds policy.
04qwen3.6openrouterrejectedMissing input modality: image.
03

One install, or compose

@swoosh-dev/sdk = the lot, wired
@swoosh-dev/sdkdrop-in

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.

Read the docs →
04

Recipes

runnable offline — no keys
cost

Hard budgets

Set a ceiling; over-budget models are rejected before a token is spent.

benchmark

Route by score

byBenchmark("swe_bench") — a name or a composite scoring function.

dynamic

LLM judge

Classify the prompt, route by verdict — coding → best, chat → cheapest.

⌖

Live catalogs

Pull pricing & limits from models.dev, or bring your own DB.

Policies as code

Built-ins, benchmark ranking, or any function you write.

≡

Explainable

Every rejection carries a human-readable reason.

⇄

Auto fallback

Walks ranked routes; returns the attempt history.

◫

BYO keys

Pass a user's keys; it wires whatever they brought.

λ

Zero-dep core

Plain Promises, fully typed, no framework to adopt.

Just give me a model.

Point at a task. Set the rules. swoosh does the rest.

npm i @swoosh-dev/sdk