Skip to content

Claude Code Configuration Tutorial

Claude Code is the official command-line tool released by Anthropic, providing developers with a powerful AI-assisted coding experience. It supports intelligent code generation, code analysis, debugging assistance, and more.

  • Intelligent code generation - Quickly generate high-quality code
  • Code analysis - Deeply understand and analyze code structure
  • Debugging assistant - Smartly detect and fix code issues
  • Documentation generation - Automatically generate code documentation
  • CLI integration - Seamlessly integrate into your development workflow

All LLM models on this site can be used in Claude Code If Claude Code cannot change the calling model, refer to the Token tutorial and set up model forwarding

Configuration Notes (Core Section — Must Read)

Section titled “Configuration Notes (Core Section — Must Read)”

This must be configured. If you do not set it, requests will be sent to Anthropic’s official Claude service endpoint, resulting in a 401 error.

  • ANTHROPIC_AUTH_TOKEN - Your API token, starting with sk-
  • ANTHROPIC_BASE_URL - API endpoint URL, important: do not include v1 in the URL! Do not include v1! Do not include v1! https://api.4allapi.com for general use

The following variables usually do not need to be configured and can be left at their defaults, but you may also set them manually if needed:

  • ANTHROPIC_MODEL - Custom model
  • ANTHROPIC_SMALL_FAST_MODEL - Fast model for background tasks
  • ANTHROPIC_DEFAULT_OPUS_MODEL - Default Opus model
  • ANTHROPIC_DEFAULT_SONNET_MODEL - Default Sonnet model
  • ANTHROPIC_DEFAULT_HAIKU_MODEL - Default Haiku model
  • ANTHROPIC_MAX_THINKING_TOKENS - Maximum thinking token limit (optional)
  • API_TIMEOUT_MS - API timeout in milliseconds (optional)
  • CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC - Flag to disable non-essential traffic (optional)

Make sure Node.js 18+ is installed on your system.

If Homebrew is not installed yet:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Using Homebrew:

brew install node
npm install -g @anthropic-ai/claude-code
Get the Auth Token (refer to the Add Token documentation)
Section titled “Get the Auth Token (refer to the Add Token documentation)”
echo 'export ANTHROPIC_AUTH_TOKEN="sk-xxx"' >> ~/.bash_profile
echo 'export ANTHROPIC_BASE_URL="https://api.4allapi.com"' >> ~/.bash_profile
echo 'export ANTHROPIC_MODEL="claude-opus-4-6"' >> ~/.bash_profile
echo 'export ANTHROPIC_SMALL_FAST_MODEL="claude-haiku-4-5-20251001"' >> ~/.bash_profile
source ~/.bash_profile
Method 2: Using Zsh (if you use Oh My Zsh)
Section titled “Method 2: Using Zsh (if you use Oh My Zsh)”
echo 'export ANTHROPIC_AUTH_TOKEN="sk-xxx"' >> ~/.zshrc
echo 'export ANTHROPIC_BASE_URL="https://api.4allapi.com"' >> ~/.zshrc
echo 'export ANTHROPIC_MODEL="claude-opus-4-6"' >> ~/.bash_profile
echo 'export ANTHROPIC_SMALL_FAST_MODEL="claude-haiku-4-5-20251001"' >> ~/.bash_profile
source ~/.zshrc

Note: After setting environment variables permanently, you need to restart the terminal for the changes to take effect.

# Go to the project directory
cd your-project-folder
# Start Claude Code
claude

After the first launch, you need to complete the initial setup such as theme selection:

  • • Choose your preferred theme (press Enter)
  • • Confirm the security notice (press Enter)
  • • Use the default Terminal configuration (press Enter)
  • • Trust the working directory (press Enter)
  • • Start coding! :rocket:

Visit https://nodejs.cn/download/current,进入 the Node.js official website, click the latest version, and download the installer for your operating system and architecture.

After downloading, double-click the installer and keep clicking Next. Once installation is complete, open a CMD window and run the following command to verify the installation:

node -v

Tell npm to ignore scripts inside packages when installing packages, such as preinstall and postinstall. After setting this, restart CMD.

setx NPM_CONFIG_IGNORE_SCRIPTS true
npm install -g @anthropic-ai/claude-code

Method 1: GUI configuration (recommended, permanent) a. Right-click “This PC” → select “Properties” b. Click “Advanced system settings” c. In the “System Properties” window, click “Environment Variables” Important: in the “System variables” section, click “New” (for shared computers, you may choose “User variables”) d. Add the following two variables: Variable name: ANTHROPIC_AUTH_TOKEN, variable value: sk-xxx Variable name: ANTHROPIC_BASE_URL, variable value: https://api.4allapi.com e. Click “OK” to save

Method 2: PowerShell (permanent)

Terminal window
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk-xxx", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.4allapi.com", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "claude-opus-4-6", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_SMALL_FAST_MODEL", "claude-haiku-4-5-20251001", "User")

Method 3: Command Prompt (permanent)

setx ANTHROPIC_AUTH_TOKEN "sk-xxx"
setx ANTHROPIC_BASE_URL "https://api.4allapi.com"
setx ANTHROPIC_MODEL "claude-opus-4-6"
setx ANTHROPIC_SMALL_FAST_MODEL "claude-haiku-4-5-20251001"

Note: After setting environment variables permanently, you need to restart the terminal for the changes to take effect. Permanent configuration is recommended.

Method 4: Configure via settings.json Find the settings.json file, or create it if it does not exist:

C:\Users\{user}\.claude\settings.json

Set the API information and save:

{
"env": {
"ANTHROPIC_MODEL": "claude-opus-4-6", // or claude-sonnet-4-6, etc.
"ANTHROPIC_SMALL_FAST_MODEL": "claude-haiku-4-5-20251001",
"ANTHROPIC_BASE_URL": "https://api.4allapi.com",
"ANTHROPIC_AUTH_TOKEN": "sk-xxx"
}
}
setx SHELL "C:\Program Files\Git\bin\bash.exe" # replace this with your own path
# If you are not sure, run where git to find it

Restart your terminal, or even restart your desktop or your computer (especially on Windows). Some operating systems require a restart before environment variable changes take effect. If you still cannot connect or requests are still going to the official URL after completing the configuration above, try restarting.

# Go to the project directory
cd your-project-folder
# Start Claude Code
claude

ccswitch simplified setup and quick switching

Section titled “ccswitch simplified setup and quick switching”

ccswitch only takes over configuration. If Claude is not installed locally, you still need to install Claude first according to your operating system’s installation method.

  1. Quick import configuration
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "the key you redeemed on 4All API",
"ANTHROPIC_BASE_URL": "https://api.4allapi.com",
"ANTHROPIC_MODEL": "claude-opus-4-6",
"ANTHROPIC_SMALL_FAST_MODEL": "claude-haiku-4-5-20251001"
}
}
  1. Fill in the form to configure

After configuring the CLI, no additional setup is needed, and the plugin’s previous requirement to log in with an official account is automatically removed.

  • claude - Start interactive mode
  • claude "task" - Run a one-off task
  • claude commit - Create a Git commit
  • /help - Show available commands
  • /clear - Clear conversation history
  • /review - Request a code review
# Code generation
> Please help me write a Python function to calculate the Fibonacci sequence
# Code review
claude "review this code for potential bugs"
# Auto commit
claude commit

Use the Claude Code command:

[model id]

The default model is Sonnet 4. You can switch to the better-performing Opus 4: opus

/model opus

Or switch to another Claude model: sonnet 3.7 sonnet 3.5

/model claude-3-7-sonnet-20250219

After starting Claude Code, just run:

/model moonshotai/kimi-k2-instruct

Other LLM models are also supported, such as OpenAI, Gemini, Qwen, and Doubao


4All API · One-stop AI large model API aggregation platform | Pricing | Contact Us

© 2025 4All API. All rights reserved.