OpenRouter Provider Settings
Configure Claude Code to use OpenRouter as a unified API gateway, providing access to Claude and other models through a single endpoint. Useful for cost optimization, model comparison, and accessing multiple providers with one API key.
Provider Configuration
# Required: OpenRouter settings export ANTHROPIC_BASE_URL=https://openrouter.ai/api/v1 export ANTHROPIC_API_KEY=sk-or-v1-your-openrouter-key
Settings File
{ "env": { "ANTHROPIC_BASE_URL": "https://openrouter.ai/api/v1", "ANTHROPIC_API_KEY": "sk-or-v1-your-openrouter-key" }, "preferences": { "model": "anthropic/claude-sonnet-4-20250514" } }
Available Models via OpenRouter
| Model | ID | Cost (per 1M tokens) |
|---|---|---|
| Claude Opus 4 | anthropic/claude-opus-4-20250514 | $15 / $75 |
| Claude Sonnet 4 | anthropic/claude-sonnet-4-20250514 | $3 / $15 |
| Claude Haiku 4 | anthropic/claude-haiku-4-20250514 | $0.25 / $1.25 |
Prices shown as input/output per 1M tokens. Check openrouter.ai for current pricing.
Setup
- Create an account at https://openrouter.ai
- Generate an API key from the dashboard
- Add credits to your account
- Replace
sk-or-v1-your-openrouter-keywith your actual key
Why OpenRouter?
- Unified billing: One account for multiple model providers
- Automatic fallback: Routes to available providers if one is down
- Usage tracking: Detailed per-model cost breakdown
- Rate limit pooling: Aggregated rate limits across providers
- Model comparison: Easily switch between models for benchmarking
Cost Controls
# Set a spending limit (in your OpenRouter dashboard) # Or use per-request limits: export OPENROUTER_MAX_PRICE=0.01 # Max cost per request
Troubleshooting
| Issue | Solution |
|---|---|
Invalid API key | Ensure key starts with sk-or-v1- |
Insufficient credits | Add credits at openrouter.ai/credits |
Model not available | Check model status at openrouter.ai/models |
| Slow responses | Try a different provider route in settings |
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Project Standards Config
Claude Code settings preset that enforces consistent coding standards. Configures TypeScript strict mode, ESLint rules, Prettier formatting, and naming conventions.
Bedrock Configuration Blueprint
All-in-one setting covering configure, claude, code, amazon. Includes structured workflows, validation checks, and reusable patterns for api.
Refined Corporate Preset
Production-ready setting that handles configure, proxy, settings, corporate. Includes structured workflows, validation checks, and reusable patterns for api.