ConfigsApr 6, 2026·2 min read

OpenRouter — Unified LLM API with Smart Routing

Single API endpoint for 200+ LLM models with automatic fallbacks, price comparison, and usage tracking. Route to the cheapest or fastest model that fits your needs. 3,000+ stars.

AI
AI Open Source · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

# Works with any OpenAI SDK — just change the base URL
export OPENROUTER_API_KEY=sk-or-...
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-sonnet-4-20250514",
    messages=[{"role": "user", "content": "Hello!"}]
)

Get your free API key at openrouter.ai.


Intro

OpenRouter is a unified API gateway for 200+ LLM models from every major provider with 3,000+ GitHub stars. One API key, one endpoint, access to Claude, GPT-4, Gemini, Llama, Mistral, and hundreds more. It offers automatic fallbacks, real-time price comparison, and usage dashboards — letting you route requests to the cheapest or fastest model that meets your requirements. Best for developers who want multi-model access without managing 10 different API keys. Works with: any OpenAI-compatible client, LangChain, LiteLLM, Cursor, Continue. Setup time: under 1 minute.


Key Features

200+ Models, One API Key

Provider Example Models
Anthropic Claude Opus 4, Sonnet 4, Haiku
OpenAI GPT-4o, GPT-4, o1
Google Gemini 2.5 Pro, Flash
Meta Llama 3.1 70B, 405B
Mistral Mistral Large, Codestral
Open-source DeepSeek, Qwen, Phi

Smart Routing

# Auto-select the cheapest model that passes your requirements
response = client.chat.completions.create(
    model="openrouter/auto",  # Smart routing
    messages=[...],
    route="lowest-cost"  # or "lowest-latency"
)

Fallback Chains

# If primary model is down, auto-fallback
response = client.chat.completions.create(
    model="anthropic/claude-sonnet-4-20250514",
    extra_body={
        "fallbacks": ["openai/gpt-4o", "google/gemini-pro"]
    },
    messages=[...]
)

Price Comparison

Real-time pricing dashboard shows cost per million tokens:

Model Input $/M Output $/M
Claude Sonnet $3.00 $15.00
GPT-4o $2.50 $10.00
Llama 3.1 70B $0.60 $0.60
Gemini Flash $0.075 $0.30

Usage Dashboard

Track spending, requests, and token usage per model, per day, per API key.

Use with Popular Tools

Cursor: Settings > Models > OpenAI Base URL: https://openrouter.ai/api/v1

Continue:

{"models": [{"provider": "openrouter", "model": "anthropic/claude-sonnet-4-20250514"}]}

Key Stats

  • 3,000+ GitHub stars
  • 200+ LLM models
  • OpenAI-compatible API
  • Smart routing and fallbacks
  • Real-time price comparison

FAQ

Q: What is OpenRouter? A: OpenRouter is a unified API gateway for 200+ LLM models with one API key, automatic fallbacks, price comparison, and smart routing.

Q: Is OpenRouter free? A: Free tier with limited credits. Pay-as-you-go with no markup on many models.

Q: How does pricing compare to direct API access? A: Most models are at or near provider pricing. Some open-source models are free.


🙏

Source & Thanks

Created by OpenRouter. Licensed under MIT.

openrouter — ⭐ 3,000+

Thanks for making multi-model LLM access simple.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets