Skip to main content
Clients & tools

Claude Code

Anthropic's CLI coding assistant

Claude Code is Anthropic's official CLI tool for AI-powered coding assistance. Connect it to Qwen Cloud's pay-as-you-go API for cost-effective access to powerful Qwen models through the Anthropic-compatible endpoint.

Quick start

Get running in a few minutes:
# 1. Install
npm install -g @anthropic-ai/claude-code

# 2. Configure (set environment variables)
export ANTHROPIC_BASE_URL=https://dashscope-intl.aliyuncs.com/apps/anthropic
export ANTHROPIC_API_KEY=sk-xxx
export ANTHROPIC_MODEL=qwen3.5-plus

# 3. Test (start Claude Code and type a message)
claude
# Then type: Write a hello world in Python
You should see: Claude Code responds with Python code for hello world

Configuration

Basic setup

Claude Code connects to Qwen Cloud using these environment variables:
  • API endpoint: https://dashscope-intl.aliyuncs.com/apps/anthropic
  • Authentication: API key required (get yours here)
  • Model selection: Any Qwen model via the Anthropic-compatible API
Free quota and billing:
  • First-time users get a free quota (valid for 90 days)
  • Exceeding the quota or validity period will incur fees
  • Enable Free quota only to prevent unexpected charges
  • Actual costs based on real-time pricing and your final bill
For Coding Plan users: Use your exclusive base URL and API key instead. See Coding Plan for Claude Code.

Model configuration

Configure models for different task types by priority:
  1. During conversation: Use /model <model_name> for temporary changes
/model qwen3.5-plus
  1. At startup: Use --model flag for single session
claude --model qwen3.5-plus
  1. Environment variables: Set different models for task complexity
export ANTHROPIC_DEFAULT_OPUS_MODEL="qwen3.5-plus"     # Complex tasks
export ANTHROPIC_DEFAULT_SONNET_MODEL="qwen3.5-plus"   # Daily tasks
export ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen3-coder-next" # Simple tasks
  1. Settings file: Create settings.json in project root
{
  "env": {
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.5-plus",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.5-plus",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3-coder-next"
  }
}

Platform-specific setup

  • macOS/Linux
  • Windows
Set environment variables in your shell profile:
# Add to ~/.zshrc (zsh) or ~/.bash_profile (bash)
export ANTHROPIC_BASE_URL="https://dashscope-intl.aliyuncs.com/apps/anthropic"
export ANTHROPIC_API_KEY="YOUR_DASHSCOPE_API_KEY"
export ANTHROPIC_MODEL="qwen3.5-plus"

# Apply changes
source ~/.zshrc  # or source ~/.bash_profile

First launch setup

On first launch, skip the Anthropic login prompt:
  1. Open ~/.claude.json (macOS/Linux) or C:\Users\%USERNAME%\.claude.json (Windows)
  2. Set hasCompletedOnboarding to true:
{
  "hasCompletedOnboarding": true
}
  1. Restart Claude Code

Limitations

  • Does not support: Direct file uploads (use file paths in conversation)
  • Requires: Node.js v18.0 or later

Examples

Basic code generation

claude> Write a Python function to validate email addresses

claude> Refactor this code for better performance: [paste code]

Project-level assistance

# Start in your project directory
cd /path/to/project
claude

# Claude Code automatically scans and understands your codebase
claude> Add error handling to all API endpoints

claude> Create unit tests for the auth module

Model switching

# Use faster model for simple tasks
/model qwen3-coder-flash
claude> Format this JSON file

# Switch to powerful model for complex tasks
/model qwen3.5-plus
claude> Design a scalable microservices architecture for this app

Troubleshooting

Cannot connect to Anthropic services
Solution: Verify environment variables are set correctly. Run echo $ANTHROPIC_BASE_URL to check.
High token usage
Solution:
  • Start Claude Code from specific project directories
  • Use /compact to summarize long conversations
  • Use /clear before starting new tasks
  • Be specific in your requests to avoid unnecessary file scans
"You have not completed onboarding" message
Solution: Edit ~/.claude.json and set "hasCompletedOnboarding": true
Model not found error
Solution: Check model name spelling. Use models from the supported list.

Token optimization tips

Claude Code consumes more tokens than standard chat due to:
  • Project directory scanning
  • Code file analysis
  • Conversation history maintenance
Reduce usage by:
  1. Focused directories: Start from your specific project folder
  2. Manual summarization: Type /compact at 95% context limit
  3. Clear instructions: Specific requests minimize file scanning
  4. Context resets: Type /clear between unrelated tasks
  5. Smaller tasks: Break complex work into steps
See Bill query and cost management for usage details.