Skip to content
OfferSign up and get $10 of credit for any model in Chat and the API. Top up from $1, with no processing fees. See free models →·Some free models are at the daily cap — refills 05:30 IST; requests auto-route to a live backup. Status →
One AI API Key
Blog

Use Qwen4 Max Preview in Claude Code, Cursor, Codex and Cline

Qwen4 Max Preview speaks OpenAI and Anthropic protocols, so Claude Code, Cursor, Codex, Cline and Qwen Code can all point at it. Base URL, key and model id.

One AI API Key TeamPublished 7 min read
On this page
Qwen4 Max Preview free API key poster from One AI API Key: Qwen4-Max Preview Free at One AI API Key
Qwen4 Max Preview speaks both the OpenAI and Anthropic protocols, which is why it drops into the coding tools you already use.

The interesting thing about Qwen4 Max Preview is not that Alibaba launched it. It is that Alibaba launched it speaking both protocol dialects the agentic coding world already uses. The Token Plan supports OpenAI-compatible and Anthropic-compatible endpoints, which means Claude Code, Cursor, Codex, Cline, OpenCode, Kilo CLI and Qwen Code can all point at it with a base URL and a key. No new client, no new extension.

This is the setup post. It covers getting a key, the exact base URL and model id, how to wire each major tool to it over whichever protocol it speaks, a curl and Python smoke test, and the two base-URL traps that cause most of the 401s. If you just want to point your editor at Qwen4 and start coding, this is the one to follow.

Step 1: get a Token Plan key

The official route takes about five minutes. You need a Token Plan subscription; Qwen4 Max Preview is not on the pay-as-you-go table.

  1. Subscribe to the Token Plan. Lite at $3 a month is enough to start and includes qwen4-max-preview.
  2. Open the API Keys page in your Qwen Cloud account.
  3. Copy the base URL and the key exactly as shown in your own console.

Keep the key in an environment variable, never in the repo. If you are unsure whether your tool speaks OpenAI or Anthropic format, read OpenAI-compatible vs Anthropic-compatible APIs first; it decides which base URL path you use below.

Step 2: the base URL and model id

Two values drive everything: the base URL and the model id.

Value Official
Model id qwen4-max-preview
Base URL (OpenAI-style) https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1
Protocols OpenAI-compatible and Anthropic-compatible

A warning on the base URL, because this is where sources disagree and where most integrations break. The host above is the one the live playground’s Call API panel handed us on November 11. apidog documents a different host, token-plan.maas.qwencloudapi.com, with an Anthropic-style path at /apps/anthropic and keys prefixed sb-sp- issued in Singapore. Both circulate. The base URL that matters is the one in your own Qwen Cloud console. Copy it exactly rather than trusting any blog, including this one.

Symptom Likely cause
401 Unauthorized Key is wrong, or the account is not on a Token Plan
404 on the model Misspelled id, or the base URL path does not match the protocol
Model not found in list The endpoint is pay-as-you-go, which excludes this preview

Step 3: point your tool at it

Every tool below takes the same three inputs: base URL, key, model id. The only difference is where the fields live.

Claude Code

Claude Code speaks the Anthropic protocol, so it uses the Anthropic-compatible path on the Qwen endpoint. Set the base URL environment variable and the model, then launch:

Claude Code → Qwen4 Max Preview
export ANTHROPIC_BASE_URL="https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1"
export ANTHROPIC_API_KEY="your-qwen-token-plan-key"
claude --model qwen4-max-preview

The full walk-through, including config file fields and verification, is in our Claude Code setup guide. If you are pointing Claude Code at a custom backend for the first time, the same pattern applies to any OpenAI-compatible or Anthropic-compatible gateway.

Cursor

Cursor takes a custom OpenAI-compatible base URL in its model settings. Add a custom provider with:

  • Base URL: your Qwen console base URL
  • API key: your Token Plan key
  • Model: qwen4-max-preview

Our Cursor guide shows the exact settings pane and how to verify the model appears in the picker.

Cline and Kilo Code

Both Cline and Kilo Code support custom OpenAI-compatible providers. Enter the base URL, key and model id in the provider settings and select the custom provider. We keep separate guides for Cline and Kilo Code, and the config generator writes the config file for you if you would rather not edit JSON.

Codex CLI

Codex CLI reads a custom OpenAI-compatible base URL from its config. Point it at the Qwen endpoint with the model set to qwen4-max-preview. The Codex CLI guide covers the config location and the verification step.

OpenCode

OpenCode uses the OpenAI-compatible protocol. Same three fields: base URL, key, model. See the OpenCode guide for the config file and a working example.

Step 4: smoke test before you commit a workflow

Before wiring a whole agent to a new backend, prove the endpoint works with two lines. This hits the endpoint directly, so a failure here is the endpoint, not your editor’s settings:

curl smoke test
curl https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $QWEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "model": "qwen4-max-preview",
  "messages": [{"role": "user", "content": "Refactor this function for readability."}]
}'

If that returns a completion, your base URL, key and model id are all correct, and any remaining problem is in the tool’s config. If it 401s, fix the key or the plan first. A 404 on the model usually means the id is misspelled or the path does not match the protocol your client is speaking.

Enable streaming in your tool so long reasoning traces arrive token by token, and keep the error codes reference handy. A 429 on a subscription endpoint usually means you hit the plan’s concurrency or quota ceiling, not a bug.

What to watch when you switch tools over

Two things trip people up moving an existing agent onto a new model id.

Concurrency limits are real on the cheap tiers. Lite runs one or two concurrent agents. If you run a swarm of parallel agents on a $3 plan, you will get 429s, not savings. Match your concurrency to the tier, or move up.

Preview is a moving target. Alibaba can change rate limits, swap the snapshot or rename the id without notice during the preview window. Pin the exact id, and re-run your evals after any announcement. Our quickstart and authentication docs cover the header and base-URL mechanics that stay the same even when the model id changes.

Switch tools, keep the gateway

Point Claude Code, Cursor, Cline or Codex at One AI API Key instead and get metered, published per-token pricing with the same OpenAI and Anthropic compatibility. The config generator writes the file.

Mistakes to avoid

  • Trusting a blog’s base URL over your console’s. Hosts differ between sources and protocols. The console value is the one that works; a 401 almost always traces to a wrong base URL or a non-Token-Plan key.
  • Using a pay-as-you-go endpoint. Qwen4 Max Preview is Token Plan only. It is absent from the pay-as-you-go pricing table, so a standard Qwen key will not reach it.
  • Running a swarm on Lite. One or two concurrent agents is the Lite ceiling. Parallel agents beyond that produce 429s, not a faster run.
  • Skipping the curl smoke test. Two lines prove the endpoint before you debug an editor’s settings. Test the endpoint directly first.
  • Pasting the key into a repo. Keep it in an environment variable and read API key security for AI apps before wiring any third-party tool.

FAQ

Can Claude Code use Qwen4 Max Preview?

Yes. Qwen4 Max Preview exposes an Anthropic-compatible endpoint, so Claude Code can point at it by setting ANTHROPIC_BASE_URL to the Qwen base URL, ANTHROPIC_API_KEY to your Token Plan key, and the model to qwen4-max-preview. See the Claude Code guide.

Which tools does the Token Plan support?

Alibaba lists Qwen Code, Cline, Claude Code, Cursor, OpenCode, Codex, Kilo CLI and OpenClaw, over both OpenAI and Anthropic protocols. Any tool that speaks either protocol can point at the endpoint with a base URL, key and model id.

What base URL and model id do I use?

Model id: qwen4-max-preview. Base URL: copy it from your own Qwen Cloud console. The playground gave us https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1; apidog documents token-plan.maas.qwencloudapi.com. Use the console value.

Why do I get a 401?

The key is wrong or the account is not on a Token Plan. Qwen4 Max Preview is not on the pay-as-you-go table, so a standard Qwen key will not reach it. Confirm the subscription, then confirm the key was copied exactly.

Why do I get a 404 on the model?

Usually a misspelled model id or a base URL path that does not match the protocol your client speaks. Confirm the id is qwen4-max-preview and that an OpenAI client uses the OpenAI-compatible path while an Anthropic client uses the Anthropic-compatible path.

The bottom line

Qwen4 Max Preview’s dual-protocol support is the practical reason to care: it drops into Claude Code, Cursor, Codex, Cline, OpenCode and Qwen Code with nothing but a base URL, a key and the model id qwen4-max-preview. Get a Token Plan key, copy the base URL from your own console, smoke-test it with curl, and match your agent concurrency to your tier. If you would rather have published, metered per-token pricing on the same tools, point them at One AI API Key instead; the config generator writes the config either way.

More in Blog

Try it

One API key for Claude, GPT, Grok, DeepSeek, Kimi, Qwen, GLM, MiniMax, Step, Gemini, Muse, MiMo and Mistral.

One AI API Key speaks the OpenAI and Anthropic formats, so you change the base URL and the key, not your code. Top-ups start at $1, credit packs at $10, and every model has a published per-token rate.