Skip to content
roguelite labsAnthony Spezzano ↗

OpenRouter

OpenRouter is a unified API proxy that routes requests to 200+ models across providers (Anthropic, OpenAI, Google, Meta, Mistral, and others) through a single OpenAI-compatible endpoint. You send one API format; OpenRouter handles provider-specific authentication, request translation, and billing.

What It Does

OpenRouter exposes all models via https://openrouter.ai/api/v1 with the standard OpenAI Chat Completions format. Any library that supports OpenAI (including the Vercel AI SDK, LangChain, and others) works with OpenRouter by changing the base URL and API key.

from openai import OpenAI

client = OpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key="sk-or-...",
)

response = client.chat.completions.create(
    model="anthropic/claude-opus-4-5",
    messages=[{"role": "user", "content": "Explain HNSW indexing."}]
)

Model names follow the pattern <provider>/<model-id>. The same request body works for any model on the platform.

Use Cases

Model fallback — specify fallback models in order of preference. If the primary model is unavailable or rate-limited, OpenRouter automatically retries with the next model in the list. No custom retry logic required.

response = client.chat.completions.create(
    model="anthropic/claude-opus-4-5",
    extra_body={"models": ["anthropic/claude-opus-4-5", "openai/gpt-4o"]},
    messages=[...]
)

Cost arbitrage — compare per-token costs across providers for a given capability level. For low-stakes summarization tasks, an open-source model routed through OpenRouter may cost 10–50x less than frontier models.

Provider redundancy — single API key and billing relationship. If a provider has an outage, route traffic elsewhere without changing application code.

Model evaluation — quickly test a prompt against multiple models with the same interface before committing to a provider.

Pricing Model

OpenRouter charges a markup over the provider's published token prices. The markup varies by model, typically 0–20% above list price. High-traffic scenarios with direct provider access will be cheaper; OpenRouter's value proposition is convenience and routing, not cost leadership.

Check openrouter.ai/models for current prices. For any model where cost matters at scale, compare the OpenRouter price against the direct provider API price and factor in the engineering cost of managing multiple provider integrations.

When to Use vs. Direct Provider API

Use OpenRouter when:

  • Prototyping and you want access to many models without setting up multiple accounts
  • You need automatic model fallback with no custom code
  • Evaluating multiple models on the same task
  • Your codebase already uses the OpenAI API format and you want to add Anthropic or other models with minimal changes

Use the direct provider API when:

  • You're in production with a single settled provider and cost per token matters
  • You need provider-specific features that OpenRouter doesn't expose (Anthropic's extended thinking, prompt caching headers, batch API)
  • Your throughput is high enough that the markup adds meaningful cost
  • Data privacy requirements prohibit routing through a third-party proxy

Sources