npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@carloscortezcloud/styrr-llm

v0.5.0

Published

Minimal LLM router with multi-model fallback chain. Zero dependencies. Works in CF Workers, Lambda, Node.js.

Readme

🧭 Styrr — Minimal LLM Router

Multi-model fallback chain for LLM calls. Zero dependencies. Works in Cloudflare Workers, AWS Lambda, Node.js, Deno.

Install

npm install styrr

Quick Start

import { StyrRouter } from 'styrr';

const router = new StyrRouter({
  apiKey: process.env.OPENROUTER_API_KEY!,
  models: [
    { id: 'nvidia/nemotron-3-super-120b:free' },
    { id: 'meta-llama/llama-3.3-70b-instruct:free' },
    { id: 'qwen/qwen3-coder:free' },
  ],
});

const result = await router.prompt('Explain what FinOps is in 2 sentences.');
console.log(result.text);          // "FinOps is..."
console.log(result.modelUsed);     // which model responded
console.log(result.latencyMs);     // how long it took
console.log(result.fallbacksTried); // 0 if primary worked

Features

  • Multi-model fallback: if model 1 returns 429/5xx, automatically tries model 2, 3, etc.
  • Fail-fast on auth errors: 401/400 throws immediately (don't retry with different model)
  • Structured JSON output: auto-parses JSON responses, strips markdown fences
  • Tool calling: pass tool schemas, get parsed tool_calls back
  • Timeout per model: AbortSignal.timeout per call
  • Zero dependencies: just fetch() — works anywhere
  • Observable: onFallback and onAllFailed hooks for logging

Advanced Usage

With tools (function calling)

const result = await router.call(messages, {
  tools: [{
    type: 'function',
    function: {
      name: 'get_weather',
      description: 'Get current weather',
      parameters: { type: 'object', properties: { city: { type: 'string' } } }
    }
  }]
});

if (result.toolCalls) {
  console.log(result.toolCalls[0].name);      // 'get_weather'
  console.log(result.toolCalls[0].arguments); // { city: 'Lima' }
}

With observability hooks

const router = new StyrRouter({
  apiKey: '...',
  models: [...],
  onFallback: (failed, error, next) => {
    console.warn(`[Styrr] ${failed} failed (${error}), trying ${next}`);
  },
  onAllFailed: (errors) => {
    console.error('[Styrr] All models exhausted:', errors);
  },
});

Custom providers (Bedrock, Ollama, etc.)

const router = new StyrRouter({
  apiKey: 'not-used',
  models: [
    { id: 'llama3.2', baseUrl: 'http://localhost:11434/v1', provider: 'ollama' },
    { id: 'gpt-4o', baseUrl: 'https://api.openai.com/v1', apiKey: 'sk-...' },
  ],
});

Bedrock AgentCore cross-provider fallback

Pattern for using Styrr as the routing layer inside a Bedrock AgentCore deployment, with ordered fallback by budget + latency (Bedrock → external → free). Lazy-imports the AWS SDK, so the package stays zero-dependency:

const router = new StyrRouter({
  apiKey: process.env.OPENROUTER_API_KEY!,
  models: [
    { id: 'anthropic.claude-3-sonnet-20240229-v1:0', provider: 'bedrock' },
    { id: 'openai/o1', provider: 'openrouter' },
    { id: 'meta-llama/llama-3.3-70b-instruct:free', provider: 'openrouter' },
  ],
});

See docs/bedrock-agentcore.md for the full pattern (IAM auth, AgentCore tool integration, Sayay budget-aware degrade).

Why Styrr?

| Feature | Styrr | LiteLLM | OpenRouter (SaaS) | |---------|:-----:|:-------:|:-----------------:| | Zero dependencies | ✅ | ❌ (Python, httpx) | N/A | | Self-hosted | ✅ | ✅ | ❌ | | Works in CF Workers | ✅ | ❌ | N/A | | Fallback chain | ✅ | ✅ | ❌ | | Tool calling | ✅ | ✅ | ✅ | | Cost-aware routing | 🔜 (styrr-003) | ❌ | ❌ | | Budget enforcement | 🔜 (sayay) | ❌ | ❌ | | Size | ~5KB | ~500KB | — |

Name

Styrr (Old Norse) = "rudder/tiller" — the part of the ship that steers direction. Because this library steers your LLM requests to the right model.

Part of the FinOptix OSS Ecosystem

  • 🧭 Styrr — LLM Router (this package)
  • Sayay — Agent Cost Guardrails
  • 🌊 Tinkuy — Agentic Framework
  • 👁️ Qhaway — Agent Observability
  • 🗺️ Ñan — Architecture Graph

License

Apache 2.0