Skip to main content
OpenRouter is an AI model aggregator that provides unified access to 200+ models from OpenAI, Anthropic, Google, Meta, Mistral, and many others.

Configuration

string
required
Set to "openrouter"
string
required
OpenRouter API key. Get yours at openrouter.ai/keys
string
required
Fully qualified model name in format provider/organization/model-name
number
Sampling temperature (0.0-2.0). Defaults to 0.7.
number
Maximum output tokens.

Example Configuration

Model Selection

OpenRouter uses fully qualified model names:
  • openrouter/anthropic/claude-sonnet-4
  • openrouter/openai/gpt-4o
  • openrouter/google/gemini-2.0-flash
  • openrouter/meta-llama/llama-3.2-90b-vision
  • openrouter/mistralai/mistral-large-2411
Browse available models at openrouter.ai/models

Authentication

OpenRouter uses Bearer token authentication with additional headers:
The HTTP-Referer and X-Title headers are automatically added by the provider.

Capabilities

Reasoning Models

OpenRouter supports OpenAI reasoning models (o1, o3, gpt-5):
  • Temperature is automatically omitted for reasoning models
  • Uses max_completion_tokens field
  • Supports reasoning_effort parameter

Warmup

OpenRouter provider includes a warmup feature to pre-establish TLS connections:
The warmup hits https://openrouter.ai/api/v1/auth/key to establish a connection.

Code Example

From src/providers/openrouter.zig:

Multi-Turn Conversations

OpenRouter supports full conversation history:

Error Handling

The provider classifies common OpenRouter API errors:
  • error.RateLimited — 429 rate limit exceeded
  • error.ContextLengthExceeded — Context window too large
  • error.InvalidApiKey — Authentication failed
  • error.ApiError — Generic API error
  • error.NoResponseContent — Empty response

Pricing

OpenRouter charges based on the model you use. Pricing varies by model: