O

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.

SettingCommunityinfrastructurev1.0.0MIT
0 views0 copies

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

ModelIDCost (per 1M tokens)
Claude Opus 4anthropic/claude-opus-4-20250514$15 / $75
Claude Sonnet 4anthropic/claude-sonnet-4-20250514$3 / $15
Claude Haiku 4anthropic/claude-haiku-4-20250514$0.25 / $1.25

Prices shown as input/output per 1M tokens. Check openrouter.ai for current pricing.

Setup

  1. Create an account at https://openrouter.ai
  2. Generate an API key from the dashboard
  3. Add credits to your account
  4. Replace sk-or-v1-your-openrouter-key with 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

IssueSolution
Invalid API keyEnsure key starts with sk-or-v1-
Insufficient creditsAdd credits at openrouter.ai/credits
Model not availableCheck model status at openrouter.ai/models
Slow responsesTry a different provider route in settings
Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates