Learning resourcesReviewed · OpenRouter

Claude Code with OpenRouter

This guide helps developers and teams connect Claude Code to OpenRouter, but guarantees compatibility only with Anthropic's first-party provider. It covers authentication, model selection, spending visibility, fast mode and common configuration failures.

Researched 23 Nov 2026

In short.

This is a setup and troubleshooting guide for developers using Claude Code through OpenRouter, with guaranteed compatibility limited to Anthropic's first-party provider. Its strongest practical details explain credential conflicts, model overrides and how to confirm which gateway and model a session uses. OpenRouter describes provider failover, shared budget controls and usage tracking as benefits. Actual compatibility, reliability and speed were not assessed, and exact usage prices are unknown from the supplied page.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete selected page at [https://openrouter.ai/docs/cookbook/coding-agents/claude-code-integration.md], including compatibility notices, installation, authentication, model configuration, fast mode, SDK and GitHub Action connections, cost statusline and troubleshooting. Linked pages and repository files are excluded. The image's visual contents and downloaded scripts were not assessed. No installation, command, API request, failover behavior, privacy behavior, cost calculation or performance claim was tested.

The overview

identity

OpenRouter's Claude Code guide documents how to connect Anthropic's coding assistant to OpenRouter's hosted gateway. The selected resource is the documentation page at [https://openrouter.ai/docs/cookbook/coding-agents/claude-code-integration.md].

The integration changes Claude Code's API destination and credentials through configuration. The page also describes connections for the Anthropic Agent SDK and official Claude Code GitHub Action.

assessment

The guide is useful for developers who want Claude Code requests billed and monitored through OpenRouter. It provides concrete authentication settings, verification commands and explanations of failures that can otherwise look like missing-model errors.

Its reliability claims require caution: the page describes automatic failover across Anthropic providers while guaranteeing compatibility only with Anthropic's first-party provider. It recommends prioritizing that provider. Reliable operation through alternative providers remains unverified.

users

Individual developers may find it useful when they already use OpenRouter credits or want gateway usage records. Teams are the clearest audience for the described spending limits, credit allocation and centralized visibility.

Beginners need familiarity with terminal commands, environment variables and API keys. Experienced developers receive additional detail about bearer authentication, model-role overrides, automated workflows and statusline integration.

capabilities

The page describes provider failover, organizational budget controls and usage monitoring through the OpenRouter Activity Dashboard [https://openrouter.ai/activity]. It also documents separate model choices for Fable, Opus, Sonnet, Haiku and Claude Code subagents.

Optional features include a curated gateway model picker, premium fast mode and a custom statusline showing session costs and cache discounts. The guide says the gateway passes through thinking blocks and native tool use; no feature compatibility results are supplied.

Using it

requirements

The setup requires Claude Code, an OpenRouter API key, network access and OpenRouter credits for billed usage. Native installation instructions cover macOS, Linux, WSL and Windows PowerShell; the npm installation route specifies Node.js 18 or newer.

The guide specifies Claude Code v2.1.96 or newer for its /fast integration, v2.1.280 or newer for fast mode on Opus 5.5, and v2.1.321 or newer for Fable 5.2. These are documentation requirements, not independently verified compatibility results.

The optional cost statusline requires both statusline.sh and statusline.ts in the same directory. It uses Node.js and npx tsx, with network access needed to download tsx on first use.

mechanism

Setting ANTHROPIC_BASE_URL to [https://openrouter.ai/api] sends Claude Code's native Anthropic Messages API requests directly to OpenRouter. No local proxy is required. ANTHROPIC_AUTH_TOKEN supplies a bearer token; ANTHROPIC_API_KEY uses a different authentication header and must be explicitly empty in the documented local setup.

Role variables select models, while optional gateway discovery supplies a curated picker rather than the complete OpenRouter catalog. The page says OpenRouter removes the [1m] model suffix before routing; the suffix tells Claude Code what context window to assume and should be used only for a supporting model.

setup

The documented local sequence is to install Claude Code, define OPENROUTER_API_KEY, set ANTHROPIC_AUTH_TOKEN from that key, configure the base URL and explicitly empty ANTHROPIC_API_KEY. Define the key before the token assignment, then reload the shell. Configuration can live in a shell profile or the project's .claude/settings.local.json; the native installer does not read a standard project .env file.

For an existing Anthropic login, the guide instructs users to run /logout, quit and relaunch Claude Code. Verification uses /status to confirm ANTHROPIC_AUTH_TOKEN and the OpenRouter base URL, followed by checking requests in the Activity Dashboard. The page also covers stale macOS Keychain credentials.

The GitHub Action has a different credential requirement: it needs the anthropic_api_key input to launch, alongside ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN in its environment. The guide supplies the OpenRouter key through a GitHub secret and explains why the action's populated ANTHROPIC_API_KEY is acceptable in that non-interactive setup.

example

For a project using Sonnet, the guide's configuration pattern combines the OpenRouter base URL, an OpenRouter key in ANTHROPIC_AUTH_TOKEN and an empty ANTHROPIC_API_KEY. Its example model override is ANTHROPIC_DEFAULT_SONNET_MODEL=~anthropic/claude-sonnet-latest[1m]. The alias and context support are claims of the captured documentation.

After relaunching Claude Code, a user would inspect /status, confirm the intended model through /model and compare the model shown in OpenRouter's Activity Dashboard. This illustrates the documented procedure; nothing was executed and no successful request is established.

Assessment & evidence

limitations

Claude Code is optimized for Anthropic models, and the guide warns that other providers may work incorrectly. Discovery can expose non-Anthropic options despite that limitation. Fast mode is described as available only through Anthropic's first-party provider on models with an anthropic/fast endpoint.

The page warns that /fast can display as enabled while a ~latest alias causes requests to omit the speed parameter. It recommends a specific supported model ID. It also says using /fast on unsupported model classes can switch the session to the configured Opus model, changing the model being billed.

Plaintext keys in shell profiles or project settings can leak through shared files. The page recommends considering an OS keychain and rotating exposed keys. Its optional cost display replaces any existing statusLine entry unless a custom wrapper combines them.

reasoning

The practical trade-off is centralized routing, credits and usage controls in exchange for additional credential and model configuration. A reasonable inference is that teams needing shared spending oversight have the strongest reason to consider this setup.

The detailed authentication troubleshooting makes the guide actionable, but documentation alone cannot establish uninterrupted sessions, lower costs or broad model compatibility. Those outcomes remain unassessed.

alternatives

Direct Anthropic authentication is the alternative explicitly contrasted with OpenRouter in the page. The evidence does not compare their actual reliability, total prices or organizational features.

Within the documented integration, native and npm installation are alternatives, as are shell-profile and project-local configuration. Existing statuslines such as ccusage are mentioned as alternatives to the supplied cost display. Other coding assistants and gateways are not evaluated.

evidence

This analysis uses OpenRouter’s Claude Code integration guide at [https://openrouter.ai/docs/cookbook/coding-agents/claude-code-integration.md].

The page supports descriptions of configuration and advertised behavior. Linked installation scripts, repositories, model pages, pricing, privacy documents and SDK instructions were not supplied. There are no execution logs, benchmark measurements or independently observed requests.

Access & freshness

costs

Usage is billed against OpenRouter credits, including reasoning tokens, according to the page. Exact token rates, credit purchase charges and total session costs are not supplied and remain unknown.

Fast mode has premium pricing. The page advertises up to 2.5 times faster output without supplying a measured comparison. It points to pricing at [https://platform.claude.com/docs/en/build-with-claude/fast-mode#pricing], whose contents are outside the supplied evidence.

Budget controls and the optional statusline help monitor spending but do not establish savings. The statusline makes generation-endpoint requests for newly encountered generations and keeps cumulative session state in temporary files. Any charges for those lookups are unknown.

rights

The supplied page establishes no license or redistribution permission for its text, code snippets or linked scripts. Rights for the linked examples and applicable service terms are unknown from this evidence.

The troubleshooting section says OpenRouter does not log source-code prompts unless users opt in. The linked privacy policy [https://openrouter.ai/privacy] was not supplied, so detailed retention, downstream-provider handling and contractual privacy protections are not established.

freshness

The page was captured on 23 November 2026 at 21:46:46.644 UTC. A publication or last-update date is not supplied. Current model availability, package requirements, provider support and prices are unknown beyond this snapshot.

The snapshot identifies older dedicated fast-model siblings as deprecated and recommends fast-tier requests on regular models for new integrations. Its latest aliases can resolve differently over time, so the captured examples do not establish fixed underlying model versions.

actions

Before adoption, confirm current model support and pricing, prioritize the Anthropic first-party provider and configure appropriate spending limits. Choose shell-wide or project-local credentials deliberately and keep secrets out of shared files.

After configuration, verify authentication and the base URL with /status, then inspect the actual routed model and charges in the Activity Dashboard. If enabling fast mode, check the documented version requirements, pin a supported model and confirm the reported speed and service tier rather than relying only on the toggle display.

Review the applicable privacy terms before submitting work code. Treat the SDK, GitHub Action and optional statusline as separate setup decisions with their own linked instructions and dependencies.

Evidence for this report

selected-page.txtselected · checked 2026-11-23