Run Claude Code on the Crazyrouter API
One command writes the three environment variables Claude Code needs. Native Anthropic protocol, so streaming, tools, thinking and prompt caching behave exactly as they do against Anthropic — billed per token at Crazyrouter rates.

One-command setup
Claude Code reads ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN at startup. Set them to Crazyrouter and every session, sub-agent and hook call goes through your Crazyrouter key. The scripts below are the same ones published in the GitHub repo; nothing is installed beyond Claude Code itself.
- 1Run the command
Pulls the script from GitHub; nothing else is downloaded.
- 2Paste your Crazyrouter key
Pick a default model when asked; you can change it later.
- 3Tool talks to Crazyrouter
Config or env vars are written; the next launch routes through your key.
curl -fsSL https://raw.githubusercontent.com/xujfcn/crazyrouter-claude-code/main/configure.sh | bash
irm https://raw.githubusercontent.com/xujfcn/crazyrouter-claude-code/main/windows/configure.ps1 | iex
What the script does
- Asks for your Crazyrouter API key and a default model
- Writes ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN / ANTHROPIC_MODEL as user-level environment variables
- Also sets OPENAI_API_KEY / OPENAI_BASE_URL so the same key works in OpenAI-compatible tools
- Use setup.sh / setup.ps1 instead on a fresh machine: it installs Node.js and Claude Code first
Scripts are fetched from the public GitHub repo linked below. Read them before piping to a shell if that's your policy; the download-then-run form is in the README.
Manual configuration
macOS / Linux — ~/.zshrc or ~/.bashrc
export ANTHROPIC_BASE_URL="https://api.crazyrouter.com" export ANTHROPIC_AUTH_TOKEN="sk-your-crazyrouter-key" export ANTHROPIC_MODEL="claude-opus-4-8"
Root domain only — Claude Code appends /v1/messages itself. Do not add /v1.
Windows PowerShell (persistent)
[Environment]::SetEnvironmentVariable('ANTHROPIC_BASE_URL', 'https://api.crazyrouter.com', 'User')
[Environment]::SetEnvironmentVariable('ANTHROPIC_AUTH_TOKEN', 'sk-your-crazyrouter-key', 'User')
[Environment]::SetEnvironmentVariable('ANTHROPIC_MODEL', 'claude-opus-4-8', 'User')Or per-project — .claude/settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.crazyrouter.com",
"ANTHROPIC_AUTH_TOKEN": "sk-your-crazyrouter-key",
"ANTHROPIC_MODEL": "claude-opus-4-8"
}
}https://api.crazyrouter.com — This tool speaks a vendor-native protocol and appends its own path. Use the root domain exactly as shown — no /v1.
Recommended models
Live Crazyrouter prices, refreshed hourly. Any model in the catalogue works; these are the ones we'd start with.
FAQ
Do I need an Anthropic account?
No. Your Crazyrouter key replaces the Anthropic key; Claude Code never contacts api.anthropic.com.
Which base URL do I use?
https://api.crazyrouter.com — the root domain with no path. Claude Code appends /v1/messages itself; adding /v1 causes 404s.
Does /login or OAuth still work?
Skip /login. With ANTHROPIC_AUTH_TOKEN set, Claude Code authenticates with the token and never opens the browser flow.
Can I switch models mid-session?
Yes — /model inside Claude Code, or change ANTHROPIC_MODEL. Any Claude model in the Crazyrouter catalogue works; Opus for hard refactors, Sonnet for daily work, Haiku for cheap sub-agents.
Is prompt caching and extended thinking supported?
Yes. Requests are relayed on the native Messages API, so cache_control breakpoints and thinking budgets pass through unchanged and cached reads are billed at the cache rate.
Guides and comparisons
TutorialClaude Code Base URL, API Key, and Native Tool Calls: Tested Setup
Configure Claude Code with a native Messages gateway, verify API authentication and a real file-read tool loop, and diagnose base URL and model errors.
GuideClaude Code Pricing Guide for Agency Retainers: Budgeting AI Coding Work in 2026
A developer-focused claude code pricing guide article with comparisons, code examples, pricing tradeoffs, FAQ, and a Crazyrouter workflow for production teams.
GuideAI Coding Tools ROI Calculator: Claude Code vs Codex CLI vs Gemini CLI Cost Analysis 2026
A comprehensive ROI framework for evaluating AI coding tools in 2026. Compare Claude Code, Codex CLI, and Gemini CLI on cost per task, productivity gains, and total cost of ownersh
Podcast
AI Dev Tools: The Crazyrouter Podcast
Short episodes for developers on AI APIs, gateways, cost control and coding tools.
Latest episodes
EP196 · Oct 29, 2026 · 6:53
AI API Security Posture — Turn Controls Into Continuous Evidence
A practical guide to AI API security posture: inventory exposure, verify controls continuously, protect keys and data, constrain tools, and turn security assumptions into evidence that operators can act on.
EP195 · Oct 28, 2026 · 7:21
AI API Policy Drift — Detect When Production Rules Stop Matching Intent
A practical guide to policy drift in AI APIs: version routing and safety rules, detect stale enforcement, compare intended and observed behavior, and restore control before small gaps become incidents.