Skip to main content
Content updated: 2026-06-16
Claude 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
Claude Code will complete the Anthropic request path on its own, so you must write only the root domain for the Base URL, either https://api.crazyrouter.com or https://api.crazyrouter.com, and do not manually append /v1 or /v1/messages.

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:
For the default international API endpoint, also use only the root address:
Do not write it as:
  • https://api.crazyrouter.com/v1
  • https://api.crazyrouter.com/v1/messages
  • https://api.crazyrouter.com/v1/complete
  • https://api.crazyrouter.com/v1
  • https://api.crazyrouter.com/v1/messages

System requirements and prerequisites

Suggested initial whitelist:
  • claude-opus-4-8
  • claude-opus-4-8

Full installation paths by operating system

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:
  1. Install Git
  2. Install Node.js LTS
  3. Use npm to install Claude Code
  4. Use PowerShell for writing temporary variables
  5. Use PowerShell for writing user-level persistent variables
Recommended verification command:
If claude --version cannot find the command, close and reopen PowerShell before trying again. 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:
  1. Install Xcode Command Line Tools
  2. Install Homebrew (if you don’t have it yet)
  3. Install Git and Node.js
  4. Use npm to install Claude Code
  5. Write ~/.zshrc
  6. Open a new terminal to verify the command path
Recommended verification command:

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:
For the default international API endpoint, also only fill in the root address:
Do not build /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:
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 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

Do not use sudo npm install -g @anthropic-ai/claude-code. If you encounter permission issues during global installation, fix the npm/Node environment before proceeding.
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-8
  • claude-opus-4-8
It’s also recommended to set a separate quota for it to avoid sharing budget with Cursor, Codex, or OpenClaw.
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 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 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:
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:
  1. First send: Please reply with OK only
  2. Then send: Only read the current repository structure, do not modify any files
  3. Finally, perform a low-risk task, such as: Please identify obvious typos in the README before directly editing the file
If all three return normally, and request logs appear in the Crazyrouter dashboard, it means the link is now working end-to-end.
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 original POST /v1/messages protocol through https://api.crazyrouter.com root 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 the ANTHROPIC_MODEL environment variable or the /model command within a session. Just replace the model name with any from the table above.
You can also switch via session command after Claude Code starts:

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 consider deepseek-v4-pro. For the Qwen series, please confirm available model IDs via /v1/models first, 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-pro and glm-5.1 are 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 allowed will be returned.
  • Recommend Real Client Validation First: Run a round of Reply only OK first, 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

A 200 response and a non-empty content[].text mean Claude Code can use the model normally.

Best Practices for Token Settings

Verification Checklist

  • git --version is normal
  • node -v is not less than 18
  • claude --version is normal
  • ANTHROPIC_BASE_URL is set to https://api.crazyrouter.com or https://api.crazyrouter.com
  • ANTHROPIC_API_KEY is 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-8 first
  • Only switch to claude-opus-4-8 for complex architecture analysis or long chain refactoring
  • First integration, validate with a small repository, do not operate on large production repo directly
  • Check git status before 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. 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. Start with claude-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.

Relevant Pages