Core Concepts
Aliases, resolution pipeline, provider priority, and key format reference for completely free ($0 cost) model routing.
Aliases
Aliases map capability requirements to provider models. Pass any free:${string} alias to languageModel().
| Alias | Filter | Use case |
|---|---|---|
free:auto | none | Catch-all, anything that works |
free:fast | fast | Chat, low-latency Q&A |
free:reasoning | reasoning | Math, logic, complex analysis |
free:long-context | long-context | Document analysis, large context |
free:vision | vision | Image inputs |
free:tool-use | tool-use | Function/tool calling |
freerouter.languageModel("free:auto", keys)
freerouter.languageModel("free:fast", keys)
freerouter.languageModel("free:reasoning", keys)Unknown aliases
Any free:${string} that doesn't match a known capability resolves as free:auto (all models).
Resolution pipeline
alias → filter by capability
→ exclude deprecated models
→ exclude providers without key
→ exclude down providers (unless cooldown expired)
→ sort by priority
→ try each until one succeedsStep by step
- Capability filter - maps alias to capability tag, queries registry
- Deprecation filter - removes models marked
deprecated: true - Key filter - removes providers where caller has no key
- Health filter - removes providers in
"down"state (unless 10s cooldown expired) - Priority sort - orders remaining candidates by provider priority
- Failover loop - tries each candidate until one succeeds or all fail
Provider priority
Providers are tried in this order (all else equal):
| Priority | Provider | Models |
|---|---|---|
| 1 | Groq | 4 |
| 2 | Google Gemini | 5 |
| 3 | NVIDIA NIM | 7 |
| 4 | OpenRouter (free) | 9 |
| 5 | Together AI | 4 |
| 6 | Fireworks AI | 4 |
| 7 | Mistral AI | 4 |
| 8 | Cloudflare Workers AI | 19 |
| 9 | Cerebras | 4 |
| 10 | SambaNova | 4 |
| 11 | DeepSeek | 2 |
| 12 | DeepInfra | 8 |
| 13 | Cohere | 5 |
Rate-limited providers are deprioritized but still included. Down providers are excluded entirely.
Key Format Reference
| Provider | Key format | Get one |
|---|---|---|
| Groq | gsk_... | console.groq.com |
| Google Gemini | AIza... | aistudio.google.com |
| NVIDIA NIM | nvapi-... | build.nvidia.com |
| OpenRouter | sk-or-... | openrouter.ai |
| Cloudflare | account_id:api_token | dash.cloudflare.com |
| Together AI | Standard key | together.ai |
| Fireworks AI | Standard key | fireworks.ai |
| Mistral AI | api_... | console.mistral.ai |
| Cerebras | Standard key | cloud.cerebras.ai |
| SambaNova | Standard key | sambanova.ai |
| DeepSeek | Standard key | platform.deepseek.com |
| DeepInfra | Standard key | deepinfra.com |
| Cohere | Standard key | dashboard.cohere.com |
Security
Keys are SHA-256 fingerprinted on receipt. Raw keys never appear in logs, error messages, or health state.
Usage Guide
Real-world examples - streaming, structured output, multi-user BYOK servers, and diagnostics. All completely free ($0 cost).
API Reference
Complete API surface for @freerouter/sdk - createFreeRouter, FreeRouter methods, types, error handling, health tracking, and key fingerprinting. All free models, $0 cost.