Full access is free during Beta. A paid subscription will be offered after Beta.

OpenRouter — User Guide

One API for many models.

Visit website
Freemium
Strengths
  • One API Key to access 200+ AI models
  • Automatic routing to the cheapest or fastest available provider
  • Real-time price comparison, transparent fee display
  • Support OpenAI compatible API format
  • Some models are completely free
Best for
  • Unified management of API calls for multiple AI models
  • Automatically select the cheapest model provider
  • Test and compare the output of different models
  • Build applications that support multi-model switching
  • Access models that cannot be called directly in China

quick start

OpenRouter uses an OpenAI compatible format, requiring little modification to existing code.

Scenario

Call any model

Prompt example
from openai import OpenAI

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

# You can call any model, just modify the model parameters
response = client.chat.completions.create(
    model="anthropic/claude-3.5-sonnet", # or any other model
    messages=[{"role": "user", "content": "Hello"}],
    extra_headers={
        "HTTP-Referer": "https://your-site.com",
        "X-Title": "Your App Name"
    }
)
print(response.choices[0].message.content)

# Just change one line to switch models
# model="openai/gpt-4o"
# model="google/gemini-pro-1.5"
# model="meta-llama/llama-3.1-70b-instruct"
Output / what to expect
One API Key to access all models, To switch models, just modify the model parameters. Billing is managed in OpenRouter.
Tips

At openrouter.ai/models you can view real-time prices for all models and choose the one that suits you best.

Scenario

Use free models

Prompt example
Free model on #OpenRouter (2025)
free_models = [
    "google/gemini-flash-1.5-8b", # Google Free
    "meta-llama/llama-3.2-3b-instruct:free", # Meta free
    "mistralai/mistral-7b-instruct:free", #Mistral free
    "deepseek/deepseek-r1:free", # DeepSeek free
]

# Use free models
response = client.chat.completions.create(
    model="deepseek/deepseek-r1:free",
    messages=[{"role": "user", "content": "Explaining Machine Learning"}]
)
Output / what to expect
Free models have rate limits, But it is completely sufficient for testing and low-frequency use. DeepSeek R1 free version is of high quality.
Tips

Free models usually have stricter rate limits, and paid models are recommended for production applications.

Starter & above

The rest of this guide

Additional scenarios and the full comparison table are included with Starter and above. Sign in with an eligible account to load them.

You're on the Free plan. Upgrade to Starter or higher to unlock the rest of this guide—additional scenarios and the full comparison table.

Loading full guide…