Skip to main content
Last updated: 2026-06-06
Claude Code is one of the best terminal coding tools to connect to Crazyrouter. It speaks the Anthropic Messages API directly and works especially well for code reading, editing, refactoring, command execution, tool use, and long-context repository analysis.

Overview

With a few 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
  • auth variable: ANTHROPIC_API_KEY
  • recommended default model: claude-opus-4-8
Claude Code appends the Anthropic request path itself, so the base URL must stay at the site root: https://api.crazyrouter.com. Do not append /v1 or /v1/messages.

View the Claude Code one-click setup repository

If you want a script to install Claude Code and write the Crazyrouter environment variables for you, review the crazyrouter-claude-code repository.

Best For

  • developers who want Crazyrouter as the backend for Claude Code
  • users who want stable tool use, long context, and terminal-first coding workflows
  • teams that want Claude Code billed separately from Cursor, Codex, or Aider
  • cross-platform setups that need one consistent CLI configuration

Protocol Used

Recommended protocol: Anthropic Messages API Use:
For the default international API entry, use:
Do not use:
  • 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 starter allowlist:
  • claude-opus-4-8
  • claude-opus-4-8

Full Install Paths By OS

On Windows, the safest path is: Git + Node.js + npm global install for Claude Code + PowerShell for environment variables. Recommended order:
  1. Install Git
  2. Install Node.js LTS
  3. Install Claude Code with npm
  4. Set temporary variables in PowerShell
  5. Persist user-level variables in PowerShell
Recommended verification:
If claude --version is still not found, close and reopen PowerShell before retrying. On macOS, the smoothest path is usually: Xcode Command Line Tools + Homebrew + Git + Node.js + npm global install for Claude Code + ~/.zshrc for persistent environment variables. Recommended order:
  1. Install Xcode Command Line Tools
  2. Install Homebrew if needed
  3. Install Git and Node.js
  4. Install Claude Code with npm
  5. Persist variables in ~/.zshrc
  6. Open a fresh terminal and verify the binary path
Recommended verification:

Why you should not append API paths manually

Claude Code uses the Anthropic-native protocol. You only provide the site root:
The default international API entry also uses only the site root:
Do not append /v1, /v1/messages, or any specific API path the way you would with an OpenAI-compatible client. If you prefer a script that installs Claude Code and writes the Crazyrouter-related environment variables automatically, see crazyrouter-claude-code. That repository provides one-click setup scripts for Windows, macOS, and Linux; this guide keeps the full manual path so you can audit each setting.

Full Setup From Scratch

1

Step 1: Install Git

If Git is not installed yet, install it first before touching Claude Code.
After installation, set your global identity once:
2

Step 2: Install Node.js 18+

Claude Code depends on Node.js. Verify the installed version before going further.
If node -v is still below 18 after installation, upgrade through 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 global npm permissions are broken, fix the npm/Node environment first instead of forcing a privileged install.
4

Step 4: Create a dedicated Crazyrouter token for Claude Code

Log in to Crazyrouter and create a separate token named something obvious like claude-code.For the first pass, allow only:
  • claude-opus-4-8
  • claude-opus-4-8
Give it its own budget so it does not share spend with Cursor, Codex, or OpenClaw.
5

Step 5: Set temporary environment variables in the current terminal

Start with a temporary setup first. Once validation succeeds, make it persistent.
Set ANTHROPIC_BASE_URL to the root domain https://api.crazyrouter.com, not https://api.crazyrouter.com/v1.
6

Step 6: Persist the environment variables

Temporary variables disappear after the shell closes. For regular use, write them to your shell profile.
Persist ANTHROPIC_BASE_URL as https://api.crazyrouter.com.Then open a fresh terminal and re-check:
7

Step 7: Prepare your Git repository

Claude Code can edit files and run commands. For the first validation, use a repo you know well.If the current folder is not a Git repo yet:
If it is already an existing repo, at least confirm the current state first:
8

Step 8: Launch Claude Code and complete the first validation

Enter the project directory and run:
For the first validation, use this order:
  1. Reply with only OK
  2. Read the current repository structure only. Do not modify any files.
  3. Find obvious typos in the README, but do not edit files yet.
If all three work and Crazyrouter logs show matching requests, the setup is good.
Recommended rollout: stabilize normal work on claude-opus-4-8, then switch to claude-opus-4-8 only for genuinely heavier tasks.

Using Non-Claude Models in Claude Code

Beyond the native Claude family, Crazyrouter exposes several third-party models through the Anthropic Messages protocol. You can use them in Claude Code simply by switching the model name. The list below has been end-to-end verified (text / system / tool use / streaming SSE all pass).

Verified working models

Tested against https://api.crazyrouter.com/v1/messages with anthropic-version: 2023-06-01 using a standard Anthropic Messages payload.
The following models currently return get_channel_failed on the Anthropic protocol (an upstream channel availability issue, not a protocol incompatibility). Use them via /v1/chat/completions (OpenAI protocol) for now:
  • moonshot-v1-8k / moonshot-v1-32k / moonshot-v1-128k
  • kimi-k2-0905 (without the -preview suffix)
Channels such as grok-*, coze, jimeng, baidu, zhipu, tencent, xunfei, mistral, cohere, and palm do not implement Anthropic protocol conversion and cannot be used in Claude Code.

How to switch models

Claude Code picks the model from the ANTHROPIC_MODEL environment variable, or via the in-session /model command. Replace the value with any model ID from the table above.
You can also switch inside a running Claude Code session:

Usage notes and known differences

  • DeepSeek family: highest protocol fidelity. Tool calls, streaming, and stop_reason=tool_use all match Anthropic’s spec; deepseek-v4-flash returns native thinking blocks that Claude Code renders as a thinking pane. Recommended default: deepseek-v4-pro.
  • Kimi family: strong long-context behavior, tool calls work normally. kimi-k2-thinking includes a reasoning trace, useful for hard tasks.
  • MiniMax family: use the current public MiniMax-M2.7 ID for new examples. If an older MiniMax snapshot is still allowed on your token, verify it through /v1/models before putting it in a Claude Code profile.
  • Token allowlist: if your Claude Code-dedicated token has model allowlisting enabled, add the models above to it in the Crazyrouter dashboard, otherwise you will get 403 model not allowed.
  • Thinking and billing: thinking-enabled models (-thinking, -flash, reasoner, MiniMax-M2.7) consume extra output tokens. Set a separate budget cap on the Claude Code token.

One-line check that a model works

A 200 response with non-empty content[].text means Claude Code can use this model.

Token Setup Best Practices

Verification Checklist

  • git --version works
  • node -v is at least 18
  • claude --version works
  • ANTHROPIC_BASE_URL is set to https://api.crazyrouter.com
  • ANTHROPIC_API_KEY is set correctly
  • Claude Code launches successfully
  • the first plain-text request succeeds
  • repository read-only inspection works
  • Crazyrouter logs show the Claude Code traffic
  • token quota and model allowlist match your intended setup

Common Errors And Fixes

Performance And Cost Tips

  • start with claude-opus-4-8
  • switch to claude-opus-4-8 only for hard architecture analysis or heavy refactors
  • validate first in a small repo, not a large production repo
  • check git status before each new task
  • watch Crazyrouter logs and quota more closely when tool use becomes frequent

FAQ

Which base URL should I use for Claude Code?

Use the site root: https://api.crazyrouter.com For the default international API entry, use the site root: https://api.crazyrouter.com

Why should I not include /v1 here?

Because Claude Code appends the Anthropic Messages path itself. You only provide the site root.

What should I use on Windows?

If you mainly develop from the command line, prefer PowerShell or WSL2. In either case, make sure Git, Node.js, and Claude Code itself are installed correctly first.

On Windows, should I use PowerShell or Git Bash?

For first-time setup, prefer PowerShell. Environment-variable persistence, where.exe checks, and user-level configuration are all more direct there.

Why should I create a Git snapshot before the first real task?

Because Claude Code can edit files and run commands. A clean snapshot makes review and rollback much easier.

Which model should I try first?

Start with claude-opus-4-8. It is usually the safest baseline.
If your first priority is Claude-family models plus a terminal-first coding workflow, Claude Code should be near the front of your Crazyrouter integration order.

View the crazyrouter-claude-code repository

Review the one-click setup scripts, README, and latest usage notes.