Claude Code + OpenRouter: The Real Setup Guide
The entire integration comes down to three environment variables and one deliberately empty string. The problem is that the step people actually fail at is the boring shell-file part — not the API key or install script. So let's slow down on the boring part.
Claude Code is Anthropic's terminal coding agent: it reads your project, edits files, runs commands, all from the CLI. By default it talks directly to Anthropic. OpenRouter is the switchboard in the middle — one API key, one dashboard, one billing page, and access to a pile of different models. One honesty caveat straight from OpenRouter's own docs: this combo is only officially guaranteed to work well with Anthropic's models. You aren't swapping out Claude's brain, you're just rerouting the network pipe it talks through.
Why does it work? Because Claude Code speaks Anthropic's API format, and OpenRouter happens to expose an endpoint that speaks that same format natively. No translation proxy required. Point it at an OpenAI-only endpoint and you get errors that read like French mail sent to a Spanish-only reader.
Here's the part that actually stops beginners:
echo $SHELL
If it prints /bin/zsh, you're editing ~/.zshrc. If /bin/bash, it's ~/.bashrc. That single command saves you fifteen minutes of guessing.
From there:
1. Install Claude Code: curl -fsSL https://claude.ai/install.sh | bash
2. Grab an OpenRouter API key and load some credits.
3. Append these lines at the end of your shell file, then fully restart your terminal:
export OPENROUTER_API_KEY="your-openrouter-api-key"
export ANTHROPAll Replies (4)
Streaming feels slower on OpenRouter compared to direct. Are you seeing any latency spikes with function calling?
That empty string in .zshrc caused a silent crash for me. Anyone else struggle with that specific bug?