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-strands

v0.1.1

Published

Styrr multi-model fallback as a Strands Agents SDK Model provider.

Downloads

301

Readme

@carloscortezcloud/styrr-strands

Multi-model fallback as a Strands Agents SDK Model provider.

Never crash because a single model is rate-limited or down — Styrr chains models in order and falls through automatically.

Install

npm install @carloscortezcloud/styrr-llm @carloscortezcloud/styrr-strands

Requires @strands-agents/sdk >=1.11.0 as a peer dependency.

Quick Start

import { Agent } from '@strands-agents/sdk';
import { StyrModelProvider } from '@carloscortezcloud/styrr-strands';

const agent = new Agent({
  model: new StyrModelProvider({
    models: [
      { id: 'anthropic/claude-sonnet-4-20250514' },
      { id: 'openai/gpt-4o-mini' },
    ],
    apiKey: process.env.OPENROUTER_API_KEY!,
  }),
  systemPrompt: 'You are a helpful assistant.',
});

Configuration

interface StyrModelProviderConfig {
  models:      { id: string; baseUrl?: string; apiKey?: string }[];
  apiKey:      string;
  baseUrl?:    string;                        // default: https://openrouter.ai/api/v1
  onFallback?: (from: string, error: string, next: string) => void;
}

Fallback chain

Models are tried in order. If the first returns 429, 5xx, or times out, the next is tried automatically.

const model = new StyrModelProvider({
  models: [
    { id: 'anthropic.claude-sonnet-4-5-v1:0' },    // Bedrock primary
    { id: 'openai/gpt-4o-mini' },                   // OpenRouter fallback
    { id: 'nvidia/nemotron-3-super-120b:free' },    // Free fallback
  ],
  apiKey: process.env.OPENROUTER_API_KEY!,
  onFallback: (from, error, next) => {
    console.warn(`Fell back from ${from} to ${next}: ${error}`);
  },
});

Tools (function calling)

Pass tools via the Agent config — tool schemas are forwarded to the LLM automatically.

const agent = new Agent({
  model: new StyrModelProvider({
    models: [{ id: 'openai/gpt-4o-mini' }],
    apiKey: process.env.OPENROUTER_API_KEY!,
  }),
  tools: [{
    name: 'get_weather',
    description: 'Get current weather for a location',
    inputSchema: {
      type: 'object',
      properties: { location: { type: 'string' } },
      required: ['location'],
    },
  }],
  systemPrompt: 'You are a helpful assistant.',
});

Stream Lifecycle

StyrModelProvider.stream() maps Styrr stream events to the Strands ModelStreamEvent lifecycle:

| Styrr event | Strands event(s) | |---|---| | text_delta | modelContentBlockStartEvent → 1+ modelContentBlockDeltaEventmodelContentBlockStopEvent | | tool_call_start / tool_call_done | modelContentBlockStartEvent(toolUseStart)modelContentBlockDeltaEvent(toolUseInputDelta)modelContentBlockStopEvent | | done | modelMessageStopEvent + modelMetadataEvent | | error | modelMessageStopEvent (graceful close) |

API

StyrModelProvider

Extends Model<StyrModelProviderConfig>. Implements stream() for Strands Agent compatibility.

| Method | Returns | Description | |---|---|---| | stream(messages, options?) | AsyncIterable<ModelStreamEvent> | Streaming model call | | updateConfig(config) | void | Merge new config, recreate router | | getConfig() | StyrModelProviderConfig | Return current config | | modelId | string \| undefined | First model ID |

Why styrr-strands instead of Strands SDK directly?

The Strands SDK lets you configure a single model provider (OpenAI, Anthropic, etc.). If that provider returns a 429 (rate-limited) or 5xx, the whole request fails.

StyrModelProvider wraps Styrr's multi-model fallback behind the same Model interface:

| Capability | Strands SDK (direct) | Styrr + Strands | |---|---|---| | Single provider | ✅ Uses one model | ✅ Uses one model | | Fallback on 429/5xx | ❌ Request fails | ✅ Auto-retries next model in chain | | Cross-provider fallback | ❌ Tied to one API | ✅ Bedrock → OpenRouter → local in one config | | Retry logic | ❌ Manual | ✅ Built-in with configurable retries | | Observable fallbacks | ❌ | ✅ onFallback hook | | Stream lifecycle | ✅ Native | ✅ Full ModelStreamEvent mapping | | Tool calling | ✅ Native | ✅ Forwarded through Styrr |

Concrete example: You deploy with Claude Sonnet on Bedrock as primary, GPT-4o-mini on OpenRouter as fallback, and a free model as third resort. If Bedrock is down, the request transparently falls through — your Strands Agent never knows.

Architecture

Strands Agent
  └─ StyrModelProvider  (@carloscortezcloud/styrr-strands)
       └─ StyrRouter    (@carloscortezcloud/styrr-llm)
            ├─ OpenAI-compatible provider
            ├─ AWS Bedrock provider
            └─ HuggingFace provider (via Inference Endpoints)

styrr-strands is a thin adapter layer: it converts Strands Message[] → Styrr format, calls StyrRouter.stream(), and maps events back to ModelStreamEvent.

Running Tests

Tests are in examples/strands-agent/:

cd examples/strands-agent
pnpm install
pnpm test

License

Apache-2.0