Home › Developers › API
1M free tokens per modelOpenAI-compatibleAnthropic-compatible

Qwen API guide

Call Qwen4-Max and other Qwen models from your own apps through QwenCloud, Alibaba's model platform. If you've used the OpenAI SDK, you already know how: change the base URL, the key and the model name.

Quick start

Your first call in four steps

Create an account

Sign in at qwencloud.com with GitHub or an email code. New accounts get about 1M free tokens per model for 90 days (Singapore region).

Create an API key

Open API Keys in the console and select Create API key. Keys only work in the region where you created them.

Save it safely

Put it in an environment variable: export DASHSCOPE_API_KEY="sk-…". Never commit it or ship it in front-end code.

Run the code

Install the OpenAI SDK (pip install openai or npm i openai) and run the example below.

Free tool

Qwen API code generator

Pick your language and options to get working code.

Uses the Singapore endpoint. For other regions, swap in that region's base URL and key.

Endpoints

Base URLs and API formats

WhatValueNotes
OpenAI-compatible base URL (Singapore)https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1Use with any OpenAI SDK. Don't add /chat/completions to the base URL.
Other regionsReplace ap-southeast-1Each region needs a key created in that region.
China (Beijing) keyshttps://dashscope.aliyuncs.com/compatible-mode/v1China and international keys only work on their own endpoints.
API formatsChat Completions Ā· Responses Ā· Anthropic MessagesUse OpenAI or Anthropic client libraries, or Alibaba's DashScope SDK.
Auth headerAuthorization: Bearer $DASHSCOPE_API_KEYSame as OpenAI.
Features

What you can do with the API

🧠

Thinking mode

Turn on step-by-step reasoning for hard problems with enable_thinking. Thinking tokens bill as output.

šŸ› ļø

Function calling

Let the model call your tools and APIs, using the standard OpenAI tools format.

🧾

Structured output

Get JSON that matches your schema, ready to parse.

🌐

Web search

Let supported models search the web for current information.

šŸ’¾

Context caching

Repeated input is billed cheaply. Qwen4-Max cache hits cost $0.075 per 1M tokens.

šŸ‘ļø

Images & video

Send images and video to vision models such as Qwen4-Max and Qwen3.7-Plus.

Models & prices

Popular API models

Model IDBest forContextInput / 1MOutput / 1M
qwen4-maxBest quality, agents, coding1M$1.50$4.50
qwen3.8-maxPrevious flagship1M$2.00$6.00
qwen3.7-plusBalanced multimodal1M$0.40*$1.60*
qwen3.8-flashFast, flat price1M$0.15$0.47
qwen3.7-flashCheapest, high volume1M$0.03*$0.13*
qwen-image-3.0-proImage generation—From ~$0.03 per image
wan3.0-videoVideo with sound—$0.20 per second (1080p)

International (Singapore) list prices, 3 Dec 2026. *Lowest tier; longer inputs cost more. Estimate your bill with the cost calculator, or see all models.

Coding tools

Use Qwen in Cline, Cursor and others

  • Choose an OpenAI-compatible provider.
  • Base URL: https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1
  • Model: qwen4-max
  • Or subscribe to a Token Plan (from $6/month) for steady use in coding tools.
  • In Qwen Code, run /auth and choose QwenCloud.
Security

Keep your key safe

  • Store keys in environment variables or a secrets manager.
  • Never put a key in browser or mobile app code; call the API from your server.
  • Use separate keys per project, and delete keys you no longer use.
  • Set spending alerts in the QwenCloud console.
Troubleshooting

Common errors and fixes

ErrorLikely causeFix
401 InvalidApiKeyKey is wrong, revoked, or has a stray space or newlineCopy the key again carefully, or create a new one.
401 with a correct keyKey created in a different regionUse the base URL for the region where the key was made.
404 on every requestBase URL includes /chat/completionsThe SDK adds that path; use the base URL only.
Model not foundTypo in the model ID, or model not in your regionCheck the model list for your region.
429 Too many requestsRate limit reachedRetry with backoff, or request higher limits.
Unexpected chargesFree quota used up or expiredFree tokens last 90 days; check usage in the console.
FAQ

Qwen API questions

Is the Qwen API free?

New QwenCloud accounts get about 1M free tokens per model for 90 days in the Singapore region. After that you pay per token, from $0.03 per 1M input tokens.

Is the Qwen API compatible with OpenAI?

Yes. QwenCloud supports OpenAI Chat Completions and Responses, plus Anthropic Messages. Point your existing SDK at the QwenCloud base URL and change the model name.

Where do I get a Qwen API key?

In the QwenCloud console under API Keys. See our login guide if you need help signing in.

What's the difference between QwenCloud and Model Studio?

Both are Alibaba Cloud's ways to use Qwen models through an API. QwenCloud is the newer, Qwen-focused platform; Model Studio is part of the wider Alibaba Cloud console. Accounts and keys are region-specific on both.

Can I still use Qwen Code's free OAuth tier?

No. It ended on 15 April 2026. Use an API key or a Token Plan instead.