🤖 AI Tools
· 4 min read

OpenRouter Complete Guide — One API for Every AI Model (2026)


OpenRouter is a unified API gateway that gives you access to 300+ AI models from 60+ providers through a single endpoint. One API key, one credit balance, one integration — and you can switch between Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM-5.1, Llama, Mistral, and hundreds more.

Why OpenRouter?

Without OpenRouter, using multiple AI models means:

  • Managing separate API keys for each provider
  • Handling different billing systems
  • Dealing with slightly different API formats
  • No easy way to compare models

OpenRouter solves all of this with an OpenAI-compatible API. If your code works with OpenAI’s API, it works with OpenRouter — just change the base URL and model name.

Quick start

1. Get an API key

Sign up at openrouter.ai and create an API key.

2. Make your first request

from openai import OpenAI

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

response = client.chat.completions.create(
    model="anthropic/claude-opus-4.6",
    messages=[{"role": "user", "content": "Write a Python web scraper"}]
)

print(response.choices[0].message.content)

That’s it. Change the model string to use any of 300+ models.

3. JavaScript/TypeScript

import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://openrouter.ai/api/v1',
  apiKey: 'your-openrouter-key',
});

const response = await client.chat.completions.create({
  model: 'google/gemini-3.1-pro',
  messages: [{ role: 'user', content: 'Explain WebSockets' }],
});

4. cURL

curl https://openrouter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-chat",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Pricing

OpenRouter charges a 5.5% platform fee on credit purchases. After that, you pay the provider’s rate for each model. Some highlights:

Free models (25+ available)

ModelQualityRate limit
Qwen 3.6 Plus PreviewExcellent20 req/min
DeepSeek V3 (free)Very good20 req/min
Gemma 4 27BGood20 req/min
Llama 4 ScoutGood20 req/min

Free models are capped at 20 requests/minute and 50/day for accounts with <10 credits.

Budget models (<$1/1M tokens)

ModelInputOutput
DeepSeek Chat$0.27$1.10
Qwen 3.5 Flash$0.065$0.26
Qwen 3.5 Plus$0.26$1.56
GLM-5.1~$1.00~$2.30

Premium models

ModelInputOutput
Claude Opus 4.6$15.00$75.00
GPT-5.4$10.00$30.00
Gemini 3.1 Pro$3.50$10.50

Using OpenRouter with coding tools

With Aider

export OPENROUTER_API_KEY="your-key"
aider --model openrouter/anthropic/claude-opus-4.6

See our Aider guide for full setup.

With Claude Code

export ANTHROPIC_BASE_URL="https://openrouter.ai/api/v1"
export ANTHROPIC_API_KEY="your-openrouter-key"
claude

With Continue.dev

In your Continue config:

{
  "models": [{
    "provider": "openrouter",
    "model": "anthropic/claude-opus-4.6",
    "apiKey": "your-openrouter-key"
  }]
}

See our Continue.dev guide for details.

With Kimi CLI

export OPENROUTER_API_KEY="your-key"
kimi --provider openrouter --model anthropic/claude-opus-4.6

Model selection strategy

With 300+ models, choosing can be overwhelming. Here’s a practical framework:

For coding

NeedModelCost
Best qualityanthropic/claude-opus-4.6$$$
Best valuedeepseek/deepseek-chat$
Best open-sourcez-ai/glm-5.1$$
Best freeqwen/qwen-3.6-plus-previewFree
Best local alternativeRun Ollama insteadFree

For general tasks

NeedModelCost
Best overallanthropic/claude-opus-4.6$$$
Best reasoningdeepseek/deepseek-reasoner$$
Best multimodalgoogle/gemini-3.1-pro$$
Best cheapqwen/qwen-3.5-flash¢

Advanced features

Fallback routing

response = client.chat.completions.create(
    model="anthropic/claude-opus-4.6",
    messages=[...],
    extra_body={
        "route": "fallback",
        "models": [
            "anthropic/claude-opus-4.6",
            "openai/gpt-5.4",
            "google/gemini-3.1-pro"
        ]
    }
)

If Claude is down, OpenRouter automatically falls back to GPT-5.4, then Gemini.

Reasoning mode

response = client.chat.completions.create(
    model="deepseek/deepseek-reasoner",
    messages=[...],
    extra_body={"reasoning": {"effort": "high"}}
)
# Access reasoning in response.choices[0].message.reasoning_details

Provider preferences

extra_body={
    "provider": {
        "order": ["Anthropic", "AWS Bedrock"],  # Prefer direct Anthropic
        "allow_fallbacks": True
    }
}

Cost management

OpenRouter makes it easy to overspend. Tips:

  1. Set credit limits — Configure max spend per day/month in the dashboard
  2. Use free models for testing — Switch to paid only for production
  3. Monitor usage — The dashboard shows per-model spending
  4. Use cheap models for simple tasks — Qwen Flash at $0.065/1M is 230x cheaper than Claude Opus
  5. Cache responses — OpenRouter doesn’t cache for you; implement it client-side

BYOK (Bring Your Own Key)

If you already have API keys from providers, you can use them through OpenRouter to get unified routing without the 5.5% markup:

extra_body={
    "provider": {
        "anthropic": {"api_key": "your-anthropic-key"}
    }
}

Bottom line

OpenRouter is the best way to access multiple AI models without managing multiple integrations. The 5.5% fee is worth it for the convenience, fallback routing, and model flexibility. If you’re building anything that uses AI APIs, start with OpenRouter — you can always switch to direct provider APIs later if the fee matters at scale.

Related: Best Free AI APIs 2026 · GLM-5.1 API Guide · How to Choose an AI Coding Agent