← All prompt collections

The full post, ready to copy

Run Qwen4-Max Inside Claude Code

Slide 1

Claude Code can talk to any model that offers an Anthropic-compatible API. Alibaba Cloud Model Studio has one, so you keep the Claude Code app, commands and workflow and run Qwen4-Max underneath. Qwen4-Max: $1.50 per 1M input tokens and $4.50 per 1M output tokens (Singapore region), and new accounts get a free quota of 1M tokens. Source: Alibaba Cloud's official guide, alibabacloud.com/help/en/model-studio/claude-code

Slide 2

1. Sign in to Alibaba Cloud Model Studio (international / Singapore region). 2. Open the API Key page and create a key. A standard key starts with sk-. 3. Copy it and keep it private.

Slide 3

Paste into your terminal, replacing YOUR_API_KEY: export ANTHROPIC_BASE_URL="https://dashscope-intl.aliyuncs.com/apps/anthropic" export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY" export ANTHROPIC_MODEL="qwen4-max" export ANTHROPIC_DEFAULT_OPUS_MODEL="qwen4-max" export ANTHROPIC_DEFAULT_SONNET_MODEL="qwen3.7-max" export ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen3.6-flash" export CLAUDE_CODE_SUBAGENT_MODEL="qwen3.7-max" export CLAUDE_CODE_MAX_CONTEXT_TOKENS="983616" Then start Claude Code as usual: claude

Slide 4

Put the same values in ~/.claude/settings.json: { "env": { "ANTHROPIC_BASE_URL": "https://dashscope-intl.aliyuncs.com/apps/anthropic", "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY", "ANTHROPIC_MODEL": "qwen4-max", "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen4-max", "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.7-max", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.6-flash", "CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.7-max", "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "983616" } }

Slide 5

- 401 invalid_api_key: the key type has to match the URL. A standard sk- key goes with https://dashscope-intl.aliyuncs.com/apps/anthropic. Workspace keys, the Token Plan and the Coding Plan each use their own base URL (see the official guide). - Long answers get cut off: also set CLAUDE_CODE_MAX_OUTPUT_TOKENS="131072". - Back to Claude: remove the variables (or the env block) and restart Claude Code.