Setup
- Create an account at OpenRouter
- Go to API Keys and create a key
- Add to
.env.local:
- Set the gateway in your config:
chat.config.ts
Authentication
| Variable | Description |
|---|---|
OPENROUTER_API_KEY | Required. Your OpenRouter API key |
Available Models
Hundreds of models from OpenAI, Anthropic, Google, Meta, Mistral, and many others. The full list is fetched at runtime and cached for 1 hour. The OpenRouter response format is automatically normalized to match the internal model schema.Model IDs
Model IDs use the sameprovider/model format as other gateways. For example:
openai/gpt-4oanthropic/claude-sonnet-4google/gemini-2.5-flashmeta-llama/llama-4-maverick
chat.config.ts works across gateways as long as the model IDs match. Check OpenRouter Models for the full list of available IDs.
Image Generation
OpenRouter routes image generation through multimodal language models rather than dedicated image APIs.createImageModel() returns null for this gateway.
Models with the image-generation tag (those with image in their output modalities) can still generate images inline through createLanguageModel(). The existing Image Generation feature handles this automatically.
Pricing
OpenRouter charges per-token based on the underlying model’s pricing. Check OpenRouter Pricing for current rates. You can set spending limits in your OpenRouter dashboard.Related
- Gateways Overview for the full gateway comparison
- Vercel Gateway for the default gateway