Skip to main content
OpenRouter provides access to models from multiple providers through a single API, with automatic fallbacks and load balancing.

Overview

OpenRouter aggregates models from:
  • OpenAI (GPT-4, GPT-3.5)
  • Anthropic (Claude)
  • Google (Gemini)
  • Meta (Llama)
  • Mistral, Cohere, and more
Supports:
  • 200+ models
  • Automatic failover
  • Usage-based pricing
  • No commitment

Configuration

Environment Variable

Config File

Selecting Models

OpenRouter uses slash-separated model IDs:
Browse available models at: https://openrouter.ai/models

Features

Tool Calling

Native tool calling for compatible models:
Models with tool support:
  • anthropic/claude-3.5-sonnet
  • openai/gpt-4-turbo
  • google/gemini-pro

Automatic Fallbacks

OpenRouter automatically retries with alternative models if primary fails:

Cost Tracking

Monitor spending:

Request Format

OpenRouter uses OpenAI-compatible request format:

Rate Limits

Varies by model and plan:
  • Free tier: 10 requests/minute
  • Pay-as-you-go: 60 requests/minute
  • Higher tiers: Contact OpenRouter

Pricing

Pay only for what you use. Prices vary by model: Check current pricing at: https://openrouter.ai/models

Troubleshooting

Solution:Get your API key from https://openrouter.ai/keys
Solution:Check model ID format (should be provider/model-name):
Solution:Add rate limiting:

Example Usage