Use Token Plan with Claude Code
Install Claude Code
- macOS/Linux
- Windows
Connection settings
-
ANTHROPIC_BASE_URL: Set tohttps://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic. -
ANTHROPIC_AUTH_TOKEN: Set to your Token Plan API key. -
ANTHROPIC_MODELand 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
- Create
~/.claude/settings.json:
~represents the home directory of the current system account. If the.claudedirectory does not exist, create it first by runningmkdir -p ~/.claudein the terminal.
- Replace
YOUR_API_KEYwith your Token Plan API key:
- Edit or create
~/.claude.jsonand sethasCompletedOnboardingtotrue:
hasCompletedOnboarding must be a top-level field (not nested). This prevents the Unable to connect to Anthropic services error at startup.Getting started
- Navigate to your project directory and start Claude Code:
- After startup, authorize Claude Code to execute files when prompted.
-
Run
/statusto verify model, Base URL, and API key configuration. - Start a conversation in Claude Code.
Switch models
-
At startup:
claude --model <model_name>(such asclaude --model glm-5) -
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
| Command | Description | Example |
|---|---|---|
| /init | Generate CLAUDE.md in project root for project-level instructions and context. | /init |
| /status | View current configuration (model, API key, Base URL). | /status |
| /model <model_name> | Switch models. | /model glm-5 |
| /clear | Clear conversation history. | /clear |
| /plan | Enter planning mode to analyze solutions without modifying code. | /plan |
| /compact | Compress conversation history to free context space. | /compact |
| /config | Open configuration menu for language, theme, and other settings. | /config |
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
- Configure Token Plan connection settings (Windows: install WSL or Git for Windows).
-
In VS Code marketplace, search for
Claude Code for VS Codeand install it. - Restart VS Code and click the upper-right icon to open Claude Code.
- 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:
- Wait a few minutes and try again.
- Check your network connection.
- If you are using a proxy or VPN, try disabling it before retrying.
- 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:
- Check the configuration file: Verify
ANTHROPIC_BASE_URLandANTHROPIC_AUTH_TOKENin~/.claude/settings.json:
YOUR_API_KEY with your actual API key):
- Check for environment variable conflicts: Ensure both the env var and configuration file point to the same Token Plan address:
-
Verify hasCompletedOnboarding: Ensure
hasCompletedOnboardingin~/.claude.jsonis set totrue. - Reopen the terminal: Configuration changes require a new terminal window.
Best practices
1. Manage context
- Clear regularly: Use
/clearto reset conversations and save tokens. - Compress proactively: Use
/compactto summarize key decisions and modified files, retaining core memory. - Specify files explicitly: Use
@to reference files (such aswrite 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
PreToolUsefor pre-execution validation), ensuring key validations run consistently. - Configuration methods:
- Run
/hooksfor interactive configuration. - Edit
.claude/settings.jsondirectly. - Ask Claude to write it (such as "Write a hook that runs eslint after every file edit").
- Run
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.