The developer tool ecosystem just got a significant shakeup. OpenRouter, the popular API aggregator that lets developers access hundreds of large language models (LLMs) through a single endpoint, has officially integrated with Anthropic's agentic coding tool, Claude Code. This move effectively decouples Claude Code’s powerful reasoning engine from Anthropic’s specific model lineup, offering users unprecedented flexibility in model selection for complex coding tasks.
For developers already leveraging OpenRouter for its massive catalog—over 320 models, including 39 free options—this integration means they can now route their agentic workflows through the familiar OpenRouter infrastructure. The setup is surprisingly straightforward, requiring users to install the native Claude Code CLI and then redirect the `ANTHROPIC_BASE_URL` to OpenRouter’s API endpoint while explicitly blanking out the native Anthropic API key. This clever redirection leverages OpenRouter’s existing "Anthropic Skin," ensuring that agentic features like tool use and structured output are preserved.
The real power move here is the ability to swap out Anthropic’s flagship models—Sonnet, Opus, and Haiku—for alternatives. By setting environment variables like `ANTHROPIC_DEFAULT_SONNET_MODEL`, users can force Claude Code to run its complex reasoning steps using models from OpenAI, Google, or specialized open-source variants. For instance, swapping the default Sonnet alias for a high-performance model like OpenAI’s GPT-5.1 Codex Max transforms the tool’s underlying intelligence without changing the user interface.
While the flexibility is welcome, the documentation wisely cautions that complex coding demands high-fidelity reasoning. Sticking to top-tier models like Claude 4.5 Sonnet or GPT-5.2 is recommended for reliable agentic performance. OpenRouter also nudges users toward its own specialized coding model, Exacto, suggesting it’s optimized for the precise tool use and formatting Claude Code relies upon.
This integration signals a growing trend: the abstraction of the LLM provider layer. Developers are increasingly prioritizing the *agent* or the *workflow* (in this case, Claude Code) over the specific foundational model powering it. OpenRouter is positioning itself as the essential middleware layer that enables this provider agnosticism, even within tools that were initially designed to be tightly coupled to a single vendor. It’s a win for developer choice and a clear challenge to vendor lock-in, allowing teams to optimize for cost, performance, or specific model capabilities on a per-task basis within a single coding environment. Billing shifts entirely to OpenRouter credits, simplifying the monitoring of usage across diverse model calls.
Model Agnosticism for Agentic Workflows
The core technical maneuver involves setting the `ANTHROPIC_BASE_URL` to `https://openrouter.ai/api` and ensuring the native `ANTHROPIC_API_KEY` is empty. This forces Claude Code to communicate via OpenRouter’s compatible endpoint, which then handles the routing and billing. The ability to override default model aliases via environment variables is the key differentiator. This isn't just about accessing more models; it’s about fine-tuning the specific reasoning tier used for the agent's internal monologue and execution steps. If a task is simple, a cheaper, faster model can be swapped in; for deep refactoring, a premium model can be activated, all while maintaining the familiar Claude Code interface. This level of granular control over the execution engine within a specialized tool is a significant step toward truly customizable AI development environments.
No. If you follow the OpenRouter setup, you use your OpenRouter credits and API key instead of an Anthropic subscription.
Ensure your ANTHROPIC_API_KEY environment variable is explicitly set to an empty string (""). If it is null or missing, the tool may try to find an Anthropic account instead of using the OpenRouter gateway.
Yes! You can override the default models by setting: export ANTHROPIC_DEFAULT_SONNET_MODEL="openai/gpt-4o" Note: We recommend using highly capable models (Claude 3.5+, GPT-4o) as coding agents require strong tool-use abilities.
OpenRouter uses a "pay-as-you-go" credit system. You purchase credits in USD, and they are deducted based on the specific token rates of the model you use.



