🧭
Styrr
@carloscortezcloud/styrr-llm
Multi-model LLM router with automatic ordered fallback. If your primary model rate-limits, crashes, or returns 402 — Styrr silently switches to the next model in your chain. Zero config. Zero dependencies.
Install
npm install @carloscortezcloud/styrr-llmFeatures
Ordered Fallback
Try models in sequence. Skip 429 (rate limit), 404 (removed), 402 (no credits). Fail fast on 401 (auth).
Tool Calling
Pass tool schemas, get structured tool_calls back. Normalizes camelCase ↔ snake_case automatically.
Any Provider
OpenRouter, OpenAI, Bedrock, NVIDIA, Ollama — anything with an OpenAI-compatible API.
Hooks
onFallback, onAllFailed callbacks for observability and logging.
Usage
import { StyrRouter } from '@carloscortezcloud/styrr-llm';
const router = new StyrRouter({
apiKey: process.env.OPENROUTER_API_KEY,
models: [
{ id: 'nvidia/nemotron-3-ultra-550b:free' },
{ id: 'google/gemma-4-31b-it:free' },
{ id: 'meta-llama/llama-3.3-70b-instruct:free' },
],
onFallback: (model, error, next) => console.log(`${model} failed → ${next}`),
});
const result = await router.call([
{ role: 'user', content: 'Explain FinOps in 2 sentences' }
]);
console.log(result.text); // "FinOps is..."
console.log(result.modelUsed); // which model responded
console.log(result.latencyMs); // total timeWhen to Use Styrr
- ✓ You use free models that get rate-limited (429) randomly
- ✓ You want paid model first, free fallback if credits run out
- ✓ You build agents that need tool_use across multiple providers
- ✓ You want auto-discovery of available models (cron-refreshed)
- ✗ You need streaming (coming in v0.2)
- ✗ You need multi-agent orchestration (use Strands/LangGraph for that)
vs Other Approaches
| Styrr | Manual try/catch | LiteLLM | |
|---|---|---|---|
| Fallback logic | Built-in | You write it | Built-in |
| Dependencies | 0 | 0 | Many |
| Edge-compatible | ✓ | ✓ | ✗ (Python) |
| Tool normalization | ✓ auto | Manual | ✓ |
| Bundle size | ~250 lines | ~50 lines | Large |
Works With
Tinkuy AgentStrands Agents (via adapter)LangChain (via ChatModel)CF WorkersDenoBunNode.js