Skip to main content
Use in AI Tools

Claude Code

Use Token Plan with Claude Code

Install Claude Code

  • macOS/Linux
  • Windows
  1. Install Node.js v18.0+.
  2. Install Claude Code:
npm install -g @anthropic-ai/claude-code
  1. Verify installation:
claude --version

Connection settings

  1. ANTHROPIC_BASE_URL: Set to https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic.
  2. ANTHROPIC_AUTH_TOKEN: Set to your Token Plan API key.
  3. ANTHROPIC_MODEL and other model environment variables: Set to a supported model. Claude Code internally uses multiple model slots to handle different tasks. All slots must be configured with a supported model. Otherwise, unconfigured slots will attempt to call official Anthropic models, causing requests to fail.
DeepSeek V3.2 does not support the Anthropic protocol and cannot be used with Claude Code. To access it, use tools that support the OpenAI-compatible protocol, such as OpenCode. Image generation models use a separate API and must be integrated through extension mechanisms. See Integrate multimodal generation models.
  • macOS/Linux
  • Windows
  1. Create ~/.claude/settings.json:
~ represents the home directory of the current system account. If the .claude directory does not exist, create it first by running mkdir -p ~/.claude in the terminal.
nano ~/.claude/settings.json
  1. Replace YOUR_API_KEY with your Token Plan API key:
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_BASE_URL": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
    "ANTHROPIC_MODEL": "qwen3.6-plus",
    "ANTHROPIC_SMALL_FAST_MODEL": "qwen3.6-plus",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.6-plus",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.6-plus",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.6-plus",
    "CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.6-plus"
  }
}
Save the config file and open a new terminal window to apply settings.
  1. Edit or create ~/.claude.json and set hasCompletedOnboarding to true:
{
  "hasCompletedOnboarding": true
}
hasCompletedOnboarding must be a top-level field (not nested). This prevents the Unable to connect to Anthropic services error at startup.

Getting started

  1. Navigate to your project directory and start Claude Code:
cd path/to/your_project
claude
  1. After startup, authorize Claude Code to execute files when prompted.
  2. Run /status to verify model, Base URL, and API key configuration.
  3. Start a conversation in Claude Code.

Switch models

  1. At startup: claude --model <model_name> (such as claude --model glm-5)
  2. During a session: /model <model_name> (such as /model MiniMax-M2.5)
The --model and /model commands switch the primary conversation model (ANTHROPIC_MODEL). To use a different model permanently, update all model slots in settings.json.

Common commands

CommandDescriptionExample
/initGenerate CLAUDE.md in project root for project-level instructions and context./init
/statusView current configuration (model, API key, Base URL)./status
/model <model_name>Switch models./model glm-5
/clearClear conversation history./clear
/planEnter planning mode to analyze solutions without modifying code./plan
/compactCompress conversation history to free context space./compact
/configOpen configuration menu for language, theme, and other settings./config
For more commands, see the official Claude Code docs.

Claude Code IDE plugin

Claude Code IDE plugin supports VS Code, VS Code-based IDEs (Cursor, Trae), and JetBrains IDEs (IntelliJ IDEA, PyCharm).
  • VS Code
  • JetBrains
  1. Configure Token Plan connection settings (Windows: install WSL or Git for Windows).
  2. In VS Code marketplace, search for Claude Code for VS Code and install it.
  3. Restart VS Code and click the upper-right icon to open Claude Code.
If the Anthropic login interface appears, complete connection settings first.
  1. Switch models: update the connection settings, then start a new conversation in the IDE plugin to apply the change.

FAQ

Error: API Error: Unable to connect to API (ECONNRESET)

This is usually a temporary network issue. Try the following:
  1. Wait a few minutes and try again.
  2. Check your network connection.
  3. If you are using a proxy or VPN, try disabling it before retrying.
  4. Upgrade Claude Code to the latest version: npm install -g @anthropic-ai/claude-code@latest.

Error: Unable to connect to Anthropic services. Failed to connect to api.anthropic.com: ERR_BAD_REQUEST

Claude Code is connecting to Anthropic's servers instead of Token Plan. Check your configuration:
  1. Check the configuration file: Verify ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN in ~/.claude/settings.json:
cat ~/.claude/settings.json
Confirm the values match (replace YOUR_API_KEY with your actual API key):
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_BASE_URL": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
    "ANTHROPIC_MODEL": "qwen3.6-plus",
    "ANTHROPIC_SMALL_FAST_MODEL": "qwen3.6-plus",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.6-plus",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.6-plus",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.6-plus",
    "CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.6-plus"
  }
}
  1. Check for environment variable conflicts: Ensure both the env var and configuration file point to the same Token Plan address:
echo $ANTHROPIC_BASE_URL
If the output is empty or does not point to the Token Plan endpoint, clear the environment variable or set it to the correct Base URL.
  1. Verify hasCompletedOnboarding: Ensure hasCompletedOnboarding in ~/.claude.json is set to true.
  2. Reopen the terminal: Configuration changes require a new terminal window.
For more frequently asked questions, see the FAQ.

Best practices

1. Manage context

  • Clear regularly: Use /clear to reset conversations and save tokens.
  • Compress proactively: Use /compact to summarize key decisions and modified files, retaining core memory.
  • Specify files explicitly: Use @ to reference files (such as write a test for @auth.py). This prevents inefficient full-project scans.
  • Use sub-agents: For large tasks, let Claude start sub-agents. Sub-agents return concise conclusions, preserving main conversation context.

2. Plan first, then execute

  • Enable Plan mode: Analyze solutions before modifying files for complex tasks.
    • Prompt constraint: Explicitly require: "First output a detailed plan. Modify files only after I confirm."
  • Reduce trial-and-error: Ensure closed-loop logic before code changes.

3. Consolidate core project knowledge: Write CLAUDE.md

  • Include key information: CLAUDE.md loads automatically at session start. Add general rules (build commands, code specs, workflows).
  • Maintain dynamically: Keep content short and readable. Record only global conventions and add rules as needed.

4. Extend capabilities: MCP and Skills

  • MCP: Install mature MCP Servers to connect external services.
  • Skills: Write detailed skill descriptions. Claude decides whether to invoke based on purpose definitions.
  • Skills vs MCP: Skills teach workflow knowledge; MCP provides external interfaces. They are complementary and can integrate.

5. Automated guardrails: Hooks

  • Use hooks: Hooks automatically run local scripts at Claude workflow lifecycle nodes (such as PreToolUse for pre-execution validation), ensuring key validations run consistently.
  • Configuration methods:
    1. Run /hooks for interactive configuration.
    2. Edit .claude/settings.json directly.
    3. Ask Claude to write it (such as "Write a hook that runs eslint after every file edit").

6. Establish a self-check loop

  • Enforce validation: Run relevant tests (pytest, npm test) after code modifications.
  • Define success criteria: After modifications, ensure compilation passes and API returns 200 (verify with curl).
  • Visual feedback: For frontend changes, take browser screenshots to verify UI.
Claude Code - Qwen Cloud