npm install -g @anthropic-ai/claude-code
- Create an OpenRouter account.
- Generate an API key (
sk-or-v1-...
). - Add credits if you're using paid models.
Add the following environment variables to your ~/.zshrc
or ~/.bashrc
:
export OPENROUTER_API_KEY="sk-or-v1-..."
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
export ANTHROPIC_API_KEY=""
Restart your terminal after saving the changes.
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek/deepseek-v4-flash"
export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek/deepseek-v4-flash"
export ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek/deepseek-v4-flash"
(Optional) Configure Claude Code sub-agents to use the same model:
export CLAUDE_CODE_SUBAGENT_MODEL="deepseek/deepseek-v4-flash"
If you've previously logged into Claude Code using Anthropic, run:
/logout
Then restart Claude Code to avoid authentication conflicts.
Start Claude Code:
claude
Inside Claude Code, run:
/status
Verify that:
Anthropic Base URL ishttps://openrouter.ai/api
Auth Token isANTHROPIC_AUTH_TOKEN
Finally, send a prompt and open the OpenRouter Activity dashboard to confirm the request is being processed by:
deepseek/deepseek-v4-flash