Content updated: 2026-06-16Claude Code is currently one of the terminal coding tools most recommended for priority integration with Crazyrouter. It directly uses the Anthropic Messages API, making it suitable for reading code, modifying, refactoring, executing commands, tool invocation, and long-context repository analysis.
Overview
By using environment variables, Claude Code can send Anthropic requests directly to Crazyrouter:- Recommended protocol:
Anthropic Messages API - Base URL:
https://api.crazyrouter.com - Default international API Base URL:
https://api.crazyrouter.com - Authentication variable:
ANTHROPIC_API_KEY - Recommended default model:
claude-opus-4-8
View the one-click configuration repository for Claude Code
If you want to directly install Claude Code via script and write Crazyrouter environment variables, you can refer to the crazyrouter-claude-code repository.
Who is this for
- Developers who want to use Crazyrouter as the backend for Claude Code
- People who want stable tool invocation, long context support, and terminal coding workflows
- Users who want to separately bill Claude Code and Cursor / Codex / Aider
- Teams who want unified CLI configuration across Linux, macOS, and Windows
Usage protocol
Recommended protocol:Anthropic Messages API
When integrating Claude Code with Crazyrouter, use:
https://api.crazyrouter.com/v1https://api.crazyrouter.com/v1/messageshttps://api.crazyrouter.com/v1/completehttps://api.crazyrouter.com/v1https://api.crazyrouter.com/v1/messages
System requirements and prerequisites
Suggested initial whitelist:
claude-opus-4-8claude-opus-4-8
Full installation paths by operating system
Recommended path for Windows
The most reliable path for Claude Code on Windows is:Git + Node.js + Global installation of Claude Code using npm + PowerShell written into the environment variables.
Recommended steps:
- Install Git
- Install Node.js LTS
- Use npm to install Claude Code
- Use PowerShell for writing temporary variables
- Use PowerShell for writing user-level persistent variables
claude --version cannot find the command, close and reopen PowerShell before trying again.
Recommended path for macOS
For macOS, the smoothest path for Claude Code is usually:Xcode Command Line Tools + Homebrew + Git + Node.js + Global installation of Claude Code using npm + ~/.zshrc for persistent environment variables.
Recommended steps:
- Install Xcode Command Line Tools
- Install Homebrew (if you don’t have it yet)
- Install Git and Node.js
- Use npm to install Claude Code
- Write
~/.zshrc - Open a new terminal to verify the command path
Why manual API path entry is not recommended here
Claude Code uses the native Anthropic protocol. You only need to provide the root site address:/v1, /v1/messages, or other specific API paths as you would for an OpenAI-compatible client.
If you want to script Claude Code installation and write related Crazyrouter environment variables automatically, you can check crazyrouter-claude-code. This repository provides one-click setup scripts for Windows, macOS, and Linux; this document still includes a full manual setup for you to review each configuration item.
Complete installation from scratch
1
Step 1: Install Git
If your machine doesn’t have Git yet, install Git before continuing with Claude Code setup.After installation, it’s recommended to add global identity information:
- Windows PowerShell
- macOS
- Ubuntu / Debian
2
Step 2: Install Node.js 18 or above
Claude Code depends on Node.js. Confirm the version before continuing to install Claude Code.If after installation
- Windows PowerShell
- macOS
- Ubuntu / Debian
node -v is still below 18, it is recommended to upgrade using nvm or the official Node installer before continuing.3
Step 3: Install Claude Code
- Windows PowerShell
- macOS
4
Step 4: Create a dedicated token for Claude Code in Crazyrouter
After logging into the Crazyrouter dashboard, create a dedicated token, and it’s recommended to name it
claude-code.Initially, it’s only recommended to allow:claude-opus-4-8claude-opus-4-8
5
Step 5: First set temporary environment variables in the current terminal
First set up a temporary configuration; after confirming it works, then write the persistent configuration.Write
- macOS / Linux
- Windows PowerShell
ANTHROPIC_BASE_URL as the root domain https://api.crazyrouter.com, do not write it as https://api.crazyrouter.com/v1.6
Step 6: Write environment variables into the persistent configuration
Temporary variables are only valid for the current terminal. For daily use, write them into your shell configuration file.The
- Linux Bash
- macOS / Zsh
- Windows PowerShell
ANTHROPIC_BASE_URL in the persistent variables should also be written as https://api.crazyrouter.com.After finishing, it’s recommended to open a new terminal, then run:- macOS / Linux
- Windows PowerShell
7
Step 7: Prepare your Git repository
Claude Code will read and write files and execute commands. For first integration, it’s recommended to test in a small, familiar repository.If the current directory is not a Git repository:If it is already an existing repository, at least make sure the working tree is in a state you can accept:
8
Step 8: Launch Claude Code and complete the first verification
After entering the project directory, run:For first-time verification, it’s recommended to follow these steps in order:
- First send:
Please reply with OK only - Then send:
Only read the current repository structure, do not modify any files - Finally, perform a low-risk task, such as:
Please identify obvious typos in the README before directly editing the file
Recommended model configuration
It’s recommended to first stabilize your default workflow using
claude-opus-4-8, and only switch to claude-opus-4-8 for genuinely complex tasks.
Using non-Claude models in Claude Code
In addition to the native Claude series, Crazyrouter also provides native Anthropic Messages access to a selection of domestic models. The following list contains only the models that passed live client retesting on 2026-05-15; untested legacy versions are no longer included.List of models proven to work in real-world tests
The above tests are based on the real Claude Code client and are verified via originalPOST /v1/messagesprotocol throughhttps://api.crazyrouter.comroot domain name.
The scope of this table is “currently retested and available”, not “all theoretically transferable third-party models for Anthropic protocol”. If a model is not listed here, it means the current Chinese documentation does not include it as a validated and recommended item for Claude Code.
How to Switch Models
Claude Code selects models using either theANTHROPIC_MODEL environment variable or the /model command within a session. Just replace the model name with any from the table above.
- macOS / Linux
- Windows PowerShell
Recommendations and Known Differences
- Preferred Order: If you wish to prioritize domestic models in Claude Code, currently recommended to start with
kimi-k2.5,kimi-k2.6, then considerdeepseek-v4-pro. For the Qwen series, please confirm available model IDs via/v1/modelsfirst, then verify individually. - MiniMax Known Differences:
MiniMax-M2.7, although protocol is available, outputs its thinking process as plain text with<think>...</think>tags at start and end. For strict tasks like “output only one sentence”, it’s not recommended to pick this first. - DeepSeek / GLM Boundaries:
deepseek-v4-proandglm-5.1are available in Claude Code, but this does not mean they are also suitable for native Codex Responses configuration. These two are separate protocols—do not mix compatibility conclusions. - Token Whitelist: If your Claude Code-specific token enables a model whitelist, be sure to add the domestic models you want to use; otherwise,
403 model not allowedwill be returned. - Recommend Real Client Validation First: Run a round of
Reply only OKfirst, then perform the “read a file and only return the title” task, as this is closer to the real usage scenario of Claude Code than just testing the bare API.
One Command to Quickly Check If a Model is Available
content[].text mean Claude Code can use the model normally.
Best Practices for Token Settings
Verification Checklist
-
git --versionis normal -
node -vis not less than 18 -
claude --versionis normal -
ANTHROPIC_BASE_URLis set tohttps://api.crazyrouter.comorhttps://api.crazyrouter.com -
ANTHROPIC_API_KEYis correctly set - Claude Code can start normally
- First plain text request returns successfully
- Read-only repository analysis works
- Claude Code requests visible in Crazyrouter logs
- Token quota and model whitelist meet expectations
Common Errors and Fixes
Performance and Cost Suggestions
- Default to using
claude-opus-4-8first - Only switch to
claude-opus-4-8for complex architecture analysis or long chain refactoring - First integration, validate with a small repository, do not operate on large production repo directly
- Check
git statusbefore each new task - For frequent tool calls, watch Crazyrouter logs and token consumption more closely
FAQ
What should the Base URL be in Claude Code?
Just use root domain:https://api.crazyrouter.com
Default international API entry: use root domain https://api.crazyrouter.com
Why can’t /v1 be used here?
Because Claude Code will itself append the Anthropic Messages API path. Just provide the site root address.
What’s recommended for Windows?
If you mainly develop in command line, prioritize PowerShell or WSL2. Make sure Git, Node.js, and Claude Code are properly installed, whichever method you choose.PowerShell or Git Bash for Windows?
For initial setup, use PowerShell: environment variable writing,where.exe validation, and user-level variable persistence are more straightforward.
Why take a Git snapshot first?
Because Claude Code will change files and run commands. Snapshots make review and rollback easier if issues occur.Which model is recommended first?
Start withclaude-opus-4-8, which is usually the most stable baseline model.
If you prioritize Claude series models + terminal coding experience, Claude Code should be at the top of the integration order in Crazyrouter code tools.
View the crazyrouter-claude-code repository
Check one-click config scripts, README, and latest usage instructions.