Use OpenRouter in Claude Code

Prices and modelsEndpoint verified 2026-11-09

Generate a Claude Code config from the Anthropic-compatible endpoint in OpenRouter's docs. The API key in the config is a placeholder; replace it with a key you create at OpenRouter.

Endpoints

  • Pay as you gohttps://openrouter.ai/apiOpenRouter only guarantees it works when routed through the Anthropic provider.Docs · verified 2026-11-09

Generate the config

Pick from the 65 models this provider sells, or type another model name.

Save to ~/.claude/settings.json; merge it in if the file already exists
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://openrouter.ai/api",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_API_KEY": "",
    "ANTHROPIC_MODEL": "anthropic/claude-fable-5.2",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "anthropic/claude-fable-5.2",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "anthropic/claude-fable-5.2",
    "ANTHROPIC_DEFAULT_FABLE_MODEL": "anthropic/claude-fable-5.2",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "anthropic/claude-fable-5.2"
  }
}

Models and prices

ModelInputOutputRatio
Claude Fable 5.2anthropic/claude-fable-5.2$8.00$40.001.00×
Hy4tencent/hy4$0.417$1.250.46×
GPT-6.1 Terraopenai/gpt-6.1-terra$1.00$5.001.00×
Kimi K3.1 Promoonshotai/kimi-k3.1-pro$2.00$10.000.98×
MiniMax-M3.1-Flashminimax/minimax-m3.1-flash$0.15$0.601.00×
Gemini 4 Argongoogle/gemini-4-argon$2.00$10.001.00×
Claude Haiku 5.5anthropic/claude-haiku-5.5$0.10$0.501.00×
GPT-6.1 Solopenai/gpt-6.1-sol$2.00$10.001.00×
Claude Sonnet 5.5anthropic/claude-sonnet-5.5$2.00$10.001.00×
Claude Opus 5.5anthropic/claude-opus-5.5$4.00$20.001.00×
GPT-6 Lunaopenai/gpt-6-luna$0.10$0.501.00×
GPT-6 Solopenai/gpt-6-sol$2.00$10.001.00×
Grok 4.7x-ai/grok-4.7$2.00$6.001.00×
GLM-5.3-FlashXz-ai/glm-5.3-flashx$0.37$1.251.19×
DeepSeek V4.1 Flashdeepseek/deepseek-v4-flash-vision-exp$0.44$1.322.20×
DeepSeek V4.1 Flashdeepseek/deepseek-v4.1-flash$0.051$0.5670.94×
DeepSeek V4.1 Flashdeepseek/deepseek-v4.1-flash-1017$0.0060$0.500.83×
GPT-6 Astraopenai/gpt-6-astra$10.00$50.001.00×
Gemini 3.8 Flashgoogle/gemini-3.8-flash$0.75$3.751.00×
Claude Fable 5.1anthropic/claude-fable-5.1$10.00$50.001.00×
Qwen3.8 Flashqwen/qwen3.8-flash$0.15$0.471.16×
GLM-5.3-Flashz-ai/glm-5.3-flash$0.15$0.501.19×
GLM-5.3z-ai/glm-5.3$0.070$1.400.33×
DeepSeek V4 Prodeepseek/deepseek-v4-pro$0.955$1.910.96×
DeepSeek V4 Prodeepseek/deepseek-v4-pro-0813$0.111$4.442.24×
Gemini 3.7 Flashgoogle/gemini-3.7-flash$0.75$3.751.00×
Grok 4.6x-ai/grok-4.6$2.00$6.001.00×
Qwen3.8 Maxqwen/qwen3.8-max-0902$2.00$6.001.11×
DeepSeek V4 Flashdeepseek/deepseek-v4-flash$0.091$0.182—
DeepSeek V4 Flashdeepseek/deepseek-v4-flash-0731$0.043$0.30—
Claude Opus 5anthropic/claude-opus-5$5.00$25.001.00×
Gemini 3.5 Flash Litegoogle/gemini-3.5-flash-lite$0.30$2.501.00×
Gemini 3.6 Flashgoogle/gemini-3.6-flash$0.75$3.751.00×
Kimi K3moonshotai/kimi-k3$0.192$16.001.07×
GPT-5.6 Lunaopenai/gpt-5.6-luna$0.20$1.201.00×
GPT-5.6 Lunaopenai/gpt-5.6-luna-pro$0.20$1.201.00×
GPT-5.6 Solopenai/gpt-5.6-sol$4.00$20.001.00×
GPT-5.6 Solopenai/gpt-5.6-sol-pro$4.00$20.001.00×
GPT-5.6 Terraopenai/gpt-5.6-terra$2.00$12.001.00×
GPT-5.6 Terraopenai/gpt-5.6-terra-pro$2.00$12.001.00×
Grok 4.5x-ai/grok-4.5$2.00$6.001.00×
Hy3tencent/hy3$0.132$0.5280.88×
Claude Sonnet 5anthropic/claude-sonnet-5$2.00$10.001.00×
Doubao Seed 2.1 Turbobytedance-seed/seed-2-1-turbo$0.50$2.501.11×
GLM-5.2z-ai/glm-5.2$0.0060$6.801.62×
Kimi K2.7 Codemoonshotai/kimi-k2.7-code$0.60$3.500.86×
Claude Fable 5anthropic/claude-fable-5$10.00$50.001.00×
Qwen3.7 Plusqwen/qwen3.7-plus$0.32$1.281.07×
MiniMax-M3minimax/minimax-m3$0.30$1.200.95×
Claude Opus 4.8anthropic/claude-opus-4.8$5.00$25.001.00×
Qwen3.7 Maxqwen/qwen3.7-max$1.48$4.43—
Gemini 3.5 Flashgoogle/gemini-3.5-flash$1.50$9.001.00×
Doubao Seed 2.0 Minibytedance-seed/seed-2.0-mini$0.10$0.401.33×
GPT-5.5openai/gpt-5.5$5.00$30.001.00×
Kimi K2.6moonshotai/kimi-k2.6$0.65$3.410.84×
Grok 4.3x-ai/grok-4.3$1.25$2.501.00×
Claude Opus 4.7anthropic/claude-opus-4.7$5.00$25.001.00×
GLM-5.1z-ai/glm-5.1$1.40$4.401.22×
MiniMax-M2.7minimax/minimax-m2.7$0.21$0.84—
Gemini 3.1 Pro Previewgoogle/gemini-3.1-pro-preview$2.00$12.001.00×
Claude Sonnet 4.6anthropic/claude-sonnet-4.6$3.00$15.001.00×
MiniMax-M2.5minimax/minimax-m2.5$0.30$1.20—
Claude Opus 4.6anthropic/claude-opus-4.6$5.00$25.001.00×
Kimi K2.5moonshotai/kimi-k2.5$0.532$3.33—
GPT-4.1openai/gpt-4.1$2.00$8.001.00×
$ per 1M tokens. Each model uses the provider's cheapest group; the ratio uses the output price

How to check it works

Restart Claude Code and send a message. If it replies and the request shows up in OpenRouter's console, it is using this endpoint.

FAQ

settings.json or environment variables?

settings.json applies every time Claude Code starts, for long-term use; the environment variables apply to the current terminal only, for a quick try.

How do I switch back to Anthropic?

Remove these variables from settings.json (or close the terminal where you set them), then restart Claude Code.

Does my key pass through this site?

No. The page only generates config text and never asks for your key; the key only goes into the config file or terminal on your own machine.

Claude Code configs for other providers