Qwen API: Pricing, Base URL, Model IDs, and Self-Hosting (2026)

The Qwen API is Alibaba Cloud Model Studio's OpenAI-compatible endpoint. Singapore base URL https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1, bearer key in DASHSCOPE_API_KEY. qwen3.8-max is $2/$6 per M tokens, qwen3.7-plus $0.40/$1.60, qwen3.8-flash $0.15/$0.47, with 1M free tokens per model for 90 days. This page has every current model ID and rate, the region split, rate limits, Python and curl calls, the open-weight Qwen 3.8 and 3.6 checkpoints with vLLM and SGLang commands, Claude Code and Qwen Code config, and how the bill compares to DeepSeek, GLM-5.3, and Kimi K3.

September 1, 2026 · 2 min read

TL;DR

The Qwen API is the hosted interface to Alibaba's Qwen models, served by Alibaba Cloud Model Studio (formerly DashScope). It is OpenAI-compatible: point the OpenAI SDK at a Model Studio base URL, pass a key from DASHSCOPE_API_KEY, and set a model ID such as qwen3.8-max or qwen3.7-plus. Pricing is per million tokens, and every proprietary model starts with 1M free tokens for 90 days.

Current as of September 7, 2026. Rates were read from Alibaba Cloud Model Studio's Singapore pricing page, and the third-party rows were re-read on that date. Alibaba reprices and renames models quarterly; check the console before committing volume.

/compatible-mode/v1
the OpenAI-compatible path on every Model Studio region. Set base_url to https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1, pass your key as a bearer token, and the OpenAI SDK runs unchanged.
Alibaba Cloud Model Studio docs, September 2026

The Qwen API is Alibaba Cloud Model Studio, the platform formerly called DashScope. It has three surfaces: an OpenAI-compatible Chat Completions endpoint, an Anthropic-compatible Messages endpoint for Claude Code, and the DashScope native API. The flagship is qwen3.8-max at $2/$6 per million tokens with a 1M context. The price-performance tier is qwen3.7-plus at $0.40/$1.60. The cheap tier is qwen3.8-flash at $0.15/$0.47. Every proprietary model comes with 1M free tokens for 90 days.

$2 / $6
qwen3.8-max per 1M tokens (in / out)
$0.40 / $1.60
qwen3.7-plus per 1M tokens, up to 256K
1M tokens
Free quota per model, 90 days
Apache 2.0
Qwen3.8-27B and Qwen3.6-27B weights

Hosted: which model

qwen3.7-plus for agent loops, qwen3.8-max when the task needs the flagship, qwen3.8-flash for classification and cheap subagent turns. Avoid qwen3-coder-plus above 256K input: that tier is $6/$60.

Self-host: which checkpoint

Qwen3.8-27B (27B dense, Apache 2.0, 61.7 SWE-bench Pro) fits one 80 GB GPU at FP8. Qwen3.8-2.4T-A95B is open-weight but under the qwen3.8-max license, not Apache. Qwen3.6-27B is the Apache-licensed generation Morph runs as a dedicated endpoint.

If you arrived from a Morph Qwen link

Morph no longer serves Qwen on its public per-token API. The morph-qwen35-397b, morph-qwen36-27b, and morph-qwen38-27b names were retired on August 27, 2026 when that capacity consolidated onto GLM-5.3-Flash; existing traffic still resolves, but the models are off every public surface. Qwen 3.6 27B is still available as a dedicated single-tenant deployment, covered at the end of this page.

Where to Get a Qwen API Key

Five steps, start to first call. The order matters: Model Studio has to be activated on the account before the API Key page will issue anything.

  1. Create an Alibaba Cloud account at account.alibabacloud.com/register/intl_register.htm if you do not have one.
  2. Open modelstudio.console.alibabacloud.com. A Terms of Service dialog appears on first visit; accepting it activates Model Studio. Until you accept, there is no key to create.
  3. Pick your region from the selector in the console header. Keys are region-scoped: a Singapore key does not authenticate against the Beijing endpoint, and each region carries its own model catalog.
  4. Go to the API Key page (?tab=playground#/api-key in the console) and click Create API key. The key looks like sk-ee166797fe40xxx, and the plaintext is shown once.
  5. Export it as DASHSCOPE_API_KEY, which is the variable every Alibaba SDK and most third-party integrations read by default.

Store the key and make the first call

export DASHSCOPE_API_KEY="sk-..."   # macOS / Linux
# Windows PowerShell: $env:DASHSCOPE_API_KEY = "sk-..."
# Windows cmd:        set DASHSCOPE_API_KEY=sk-...

curl "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"qwen3.7-plus","messages":[{"role":"user","content":"ping"}]}'
Model Studio base URLs by region
RegionOpenAI-compatible base URLNotes
Singapore (international)https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1Default for non-China customers; 1M free tokens per model
China (Beijing)https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1Higher rate limits; separate console and key
US (Virginia)https://dashscope-us.aliyuncs.com/compatible-mode/v1Smaller catalog; check model availability
DashScope nativehttps://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1Alibaba-specific features (multimodal, apps)

Replace {WorkspaceId} with the workspace ID from the console. Older tutorials use dashscope-intl.aliyuncs.com/compatible-mode/v1; Alibaba now recommends the workspace-specific domains and describes the old hostnames as legacy. Source: Model Studio OpenAI-compatibility and first-call docs, September 2026.

Six regions, one free quota, one exception

Model Studio runs in six regions: China (Beijing), US (Virginia), Singapore, Japan (Tokyo), Germany (Frankfurt), and China (Hong Kong). Two details do not generalize across them. The workspace-specific domain pattern does not apply to US (Virginia), which the first-call doc calls out explicitly, so Virginia stays on the flat dashscope-us.aliyuncs.com host. And the 1M-token free quota is a Singapore benefit: the pricing page lists free quotas for the Singapore region and none for the others. A team that picks Frankfurt or Tokyo for residency reasons is on paid tokens from the first request.

The legacy hostname is worth avoiding for a second reason. Qwen Code 0.13.0 through 0.15.10 fails against dashscope-intl.aliyuncs.com with API Error: Connection error. (cause: fetch failed) while the same URL works from curl. The cause is the custom undici dispatcher that DashScopeContentGenerator.buildClient() hands the OpenAI SDK with headersTimeout: 0 and bodyTimeout: 0; it fails silently against that host, and removing the dispatcher so the SDK uses Node's native fetch restores the connection (QwenLM/qwen-code#4035).

Two subscription products sit beside pay-as-you-go. The Coding Plan Pro is $50 per month for up to 6,000 requests per 5 hours, 45,000 per week, and 90,000 per month, with its own endpoints at coding-intl.dashscope.aliyuncs.com and support for Claude Code, Cline, Qwen Code, Cursor, and others. The Lite tier closed to new subscriptions in March 2026. A Token Plan endpoint at token-plan.ap-southeast-1.maas.aliyuncs.com serves prepaid token bundles; the key type must match the endpoint or the API returns a mismatch error.

Qwen API Pricing and Model IDs

Model Studio bills per million tokens, in USD on the Singapore region, with separate input and output rates. Three families matter: Max (flagship), Plus (balanced), and Flash (cheap), plus the Coder line and the hosted open-weight 27B. Several models tier the rate by input length; the table shows the first tier and the ceiling.

Qwen API pricing on Model Studio Singapore (USD per 1M tokens)
Model IDInputOutputTieringFree quota
qwen3.8-max$2.00$6.00Flat to 1M1M tokens, 90 days
qwen3.7-max$2.50$7.50Flat1M tokens, 90 days
qwen3.7-plus$0.40$1.60$1.20 / $4.80 above 256K1M tokens, 90 days
qwen3.6-plus$0.50$3.00$2.00 / $6.00 above 256K1M tokens, 90 days
qwen3.8-flash$0.15$0.47Flat1M tokens, 90 days
qwen3.7-flash$0.03$0.13$0.20 / $0.80 above 256K1M tokens
qwen3-coder-plus$1.00$5.00$6.00 / $60.00 above 256K1M tokens, 90 days
qwen3-coder-flash$0.30$1.50$1.60 / $9.60 above 256K1M tokens
qwen3.8-27b (open weights, hosted)$0.50$3.00Flat1M tokens, 90 days

Source: Alibaba Cloud Model Studio model pricing page, Singapore region, read September 1, 2026. qwen3.7-plus showed a limited-time 20% discount on top of the list rate at that time. Context caching discounts repeated input on the models that list it (qwen3.8-max, qwen3.7-plus, qwen3.8-flash, qwen3-coder-plus, qwen3.8-27b). Batch inference is 50% off on qwen-max, qwen3.7-flash, and qwen-flash. Legacy aliases qwen-max ($1.60/$6.40), qwen-plus, and qwen-flash still resolve; new code should target a versioned ID.

The coder-plus cliff

qwen3-coder-plus is the only model here whose top tier is $6/$60. A coding agent that lets context grow past 256K pays 6x the input rate and 12x the output rate of the first tier on that request. Either cap context below 256K with compaction, or use qwen3.7-plus, whose top tier is $1.20/$4.80 at the same 1M window. See Compact for shrinking agent context 50 to 70% before it hits a tier boundary.

Free Tier, Regions, and Rate Limits

The free tier is per model, not per account: each proprietary Qwen model carries 1M free tokens, valid 90 days from the later of Model Studio activation, model release, or application approval. A fresh Singapore account therefore starts with roughly 1M tokens on each of qwen3.8-max, qwen3.7-plus, qwen3.8-flash, the coder models, and the rest. The quota excludes the Batch API, context caching, and fine-tuning.

Two different Qwen free tiers, and one of them is dead

The 1M-token Model Studio quota above is not the free tier most people mean. Qwen Code shipped an OAuth free tier that needed no Alibaba Cloud account at all, and it was discontinued on April 15, 2026. The CLI now answers a resume attempt with Qwen OAuth free tier was discontinued on 2026-04-15. Run /auth to switch to Coding Plan, OpenRouter, Fireworks AI, or another provider. The failure mode before that message appears is misleading: existing sessions return 401 invalid access token or token expired, which reads like a refresh problem rather than a shutdown, so the first instinct is to re-authenticate rather than to switch providers (Tell HN, April 2026). If you are hitting 401s on a Qwen Code session that used to work, that is the reason. The remaining paid paths are the $50 per month Coding Plan, pay-as-you-go Model Studio, or a third-party host.

Rate limits are enforced at the Alibaba Cloud account level. Usage from every RAM user, workspace, and API key under the account is combined, so adding keys adds no headroom. Two limits apply at once, requests per minute and tokens per minute, and the service may also enforce per-second ceilings of RPM/60 and TPM/60. A burst that fits the minute budget can still 429 on the second budget.

Qwen API rate limits by region (default, per account)
ModelSingapore RPM / TPMBeijing RPM / TPM
qwen3.8-max15,000 / 2,000,00030,000 / 5,000,000
qwen3.7-plus15,000 / 5,000,00030,000 / 5,000,000
qwen3-coder-plus2,400 / 2,000,0005,000 / 5,000,000
qwen3.5-flash15,000 / 5,000,00030,000 / 10,000,000

Source: Model Studio rate-limiting doc, September 2026. Dated snapshot versions carry much lower quotas (60 RPM, 100,000 TPM on some). A temporary TPM increase can be requested from the console's Increase Rate Limits page; it takes effect immediately and lasts 30 days.

Region choice is a data-residency decision as much as a latency one. Singapore is the international default and the region where the 1M free quota and the USD price list apply. Beijing has roughly double the RPM ceilings but serves from mainland China. The US (Virginia) endpoint exists for teams that need requests to stay in the United States; verify the model you want is in its catalog before building on it.

Call the Qwen API: Python and curl

Because Model Studio speaks the OpenAI wire format, the call is the OpenAI SDK with two fields changed. Streaming, tool calling, and JSON mode work as they do against OpenAI.

Qwen API with the OpenAI Python SDK (Model Studio Singapore)

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["DASHSCOPE_API_KEY"],
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

resp = client.chat.completions.create(
    model="qwen3.7-plus",  # or qwen3.8-max, qwen3.8-flash, qwen3-coder-plus
    messages=[
        {"role": "system", "content": "You are a senior engineer."},
        {"role": "user", "content": "Find the race condition in this handler and fix it."},
    ],
)
print(resp.choices[0].message.content)

Qwen API with curl

curl "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.8-max",
    "messages": [{"role": "user", "content": "Explain MoE routing in two sentences."}]
  }'

The same client works against a self-hosted vLLM or SGLang server. Only the base URL and the model name change; the key can be any non-empty string unless you started the server with --api-key.

Same call against a self-hosted vLLM endpoint

from openai import OpenAI

client = OpenAI(api_key="local", base_url="http://localhost:8000/v1")

resp = client.chat.completions.create(
    model="Qwen/Qwen3.8-27B",
    messages=[{"role": "user", "content": "Write a retry decorator with exponential backoff."}],
)
print(resp.choices[0].message.content)

Thinking Tokens and the enable_thinking Trap

The Qwen line is a thinking-model line, and that changes both the bill and the request shape. Neither effect is visible from the pricing table, and both are the most common reason a working OpenAI integration breaks the moment the base URL points at Model Studio.

Reasoning tokens are billed at the output rate

Alibaba's deep-thinking doc is direct about it: thinking content is billed per output token. On qwen3.8-max that is $6 per million, the same as the answer, for text the user never sees. The inverse is also stated: if a thinking-mode model produces no reasoning output, non-thinking pricing applies. So the real output cost of a reasoning turn is answer tokens plus reasoning tokens, and a long chain of thought on a short answer can cost several times the sticker estimate. The lever is thinking_budget, which caps reasoning tokens; when the cap is reached the model stops reasoning and answers immediately.

The wire-format trap is separate. Model Studio requires an explicit enable_thinking value on non-streaming calls to reasoning models, and the OpenAI SDK does not send one, so a request that works against OpenAI returns a 400 reading parameter.enable_thinking must be set to false for non-streaming calls (openclaw#21114). The second half of the trap is where the parameter goes. It is not an OpenAI field, so setting it as a keyword argument silently drops it and the same 400 comes back; it has to travel in extra_body (agno#4290).

Non-streaming call to a Qwen thinking model, with the parameter in the right place

resp = client.chat.completions.create(
    model="qwen3.7-plus",
    messages=[{"role": "user", "content": "Refactor this function."}],
    extra_body={
        "enable_thinking": False,   # required for non-streaming; a top-level kwarg is dropped
    },
)

# Thinking on, with a cap, streamed:
stream = client.chat.completions.create(
    model="qwen3.7-plus",
    messages=[{"role": "user", "content": "Refactor this function."}],
    stream=True,
    extra_body={"enable_thinking": True, "thinking_budget": 2048},
)
for chunk in stream:
    delta = chunk.choices[0].delta
    # reasoning arrives in reasoning_content, the answer in content
    print(getattr(delta, "reasoning_content", None) or delta.content or "", end="")

Reasoning arrives in a reasoning_content field beside content, so any client that reads only choices[0].delta.content shows nothing while the model thinks. And some open-weight models on the platform, including qwen3-235b-a22b and qwen3-32b, support streaming only: a non-streaming call to them errors regardless of what you set. Commercial models accept both, and Alibaba recommends streaming so reasoning is visible as it is produced.

The placement of the flag differs by server, which is its own source of confusion. On Model Studio it goes in extra_body. On a self-hosted llama.cpp or vLLM server the equivalent is chat_template_kwargs, because there the switch is a chat-template variable rather than a platform parameter. Code that works against one will not disable thinking on the other, and neither errors loudly when the flag is ignored; the only symptom is a bill with more output tokens than expected.

Reasoning billing plus resent context is why Qwen token consumption is hard to predict from the size of a codebase. One developer disputed a Model Studio bill after being charged for 10M tokens across two hours of testing against a roughly 3,200-line project, and Alibaba support attributed the volume to IDE autocompletion sending long context on every call and to conversation history accumulating across turns (Hacker News, August 2025). The dispute itself is one account and was never independently resolved, so treat the fraud framing as unverified. The mechanism support described is real and worth designing against: an agent loop bills the whole conversation on every turn, reasoning tokens are added at the output rate, and neither shows up in a line count. Set a spending alert before the first long run rather than estimating from source size.

Qwen Image and Vision APIs

"Qwen API" covers two surfaces that bill and route differently. Vision-language understanding, where an image goes in and text comes out, runs on the ordinary chat path and is billed per token. Image generation does not: the qwen-image family is not on /compatible-mode/v1 at all. Those models are called through the DashScope MultiModalConversation API at /services/aigc/multimodal-generation/generation, so pointing the OpenAI SDK's images.generate at Model Studio does not work.

Qwen vision-language models on Model Studio Singapore (USD per 1M tokens)
Model IDInputOutputNotes
qwen3-vl-plus$0.20 to $0.60$1.60 to $4.80Tiered by input length
qwen3-vl-flash$0.05 to $0.12$0.40 to $0.96Tiered by input length
qwen-vl-max$0.80$3.20Flat
qwen-vl-plus$0.21$0.63Flat

Source: Model Studio model pricing, Singapore region, read September 7, 2026. The 1M-token 90-day free quota applies to these models on Singapore and is not offered in other regions. The flagship text models qwen3.8-max and qwen3.7-plus accept image input themselves, so a dedicated VL model is only worth routing to when its cheaper tier matters.

On the generation side the current IDs are qwen-image-3.0-pro (flagship, with prompt rewriting), qwen-image-3.0, the qwen-image-2.0 series, and the older qwen-image-plus and qwen-image-max. Three behaviors are worth knowing before building on them. Text-to-image calls are synchronous, with asynchronous calls available on a subset. Billing is per successfully generated image, so a failed generation is not charged. And qwen-image-max and qwen-image-plus accept only five fixed resolutions, which is the reason teams needing arbitrary aspect ratios end up on the 3.0 series or on Wan. NVIDIA also publishes Qwen-Image in its NIM visual-generative-AI catalog if you would rather run it on your own NIM deployment than call Alibaba.

Third-Party Hosts: OpenRouter, DeepInfra, Fireworks, Together

Alibaba is not the only way to call Qwen. The proprietary Max, Plus, and Flash models are resold through OpenRouter, and the open-weight checkpoints are served by the usual inference providers. Prices below are the provider's list rate on September 1, 2026; routed listings blend several upstreams and can move daily.

Qwen on third-party hosts (USD per 1M tokens)
HostModelInputOutputContext
OpenRouterqwen/qwen3.8-max$2.00$6.001M
OpenRouterqwen/qwen3.7-plus$0.32$1.281M
OpenRouterqwen/qwen3.8-flash$0.15$0.471M
OpenRouterqwen/qwen3.8-27b$0.15$2.001M
OpenRouterqwen/qwen3.7-max$1.475$4.4251M
OpenRouterqwen/qwen3.7-flash$0.03$0.131M
OpenRouterqwen/qwen3-max-thinking$0.78$3.90262K
OpenRouterqwen/qwen3.6-27b$0.30$2.00262K
OpenRouterqwen/qwen3.6-35b-a3b$0.05$0.70262K
DeepInfraQwen/Qwen3.8-27B$0.40$3.00262K
FireworksQwen3.8 27BDedicated onlyDedicated only262K

Sources: OpenRouter Qwen listings re-read September 7, 2026; DeepInfra Qwen3.8-27B model page and Fireworks Qwen3.8 27B model page (serverless marked not supported), September 1, 2026. Together AI lists Qwen models on its serverless catalog but no Qwen 3.8 rate could be verified on its pricing page, so no number is quoted.

Router prices move faster than vendor prices

Between September 1 and September 7, 2026, OpenRouter's qwen/qwen3.8-27b went from $0.32/$2.50 to $0.15/$2.00 per million tokens. Alibaba's own rate for the same model did not move. That is the practical difference between a first-party price and a routed one: the router rate tracks whichever upstream is cheapest this week, in both directions. Do not hardcode a router rate into a cost model or a budget alert. The same volatility applies to what you get: a routed listing can resolve to a different quantization or a different tool-call implementation than the reference weights, which is why a Qwen agent that passes evals on one provider can fail tool calls on another.

OpenRouter's qwen3.7-plus at $0.32/$1.28 is exactly the Model Studio list rate with Alibaba's 20% promotion applied, which is a useful sanity check on whether a router is passing the upstream price through. For the open-weight 27B, hosted rates run $0.30 to $0.50 input and $2.00 to $3.00 output depending on host and quantization; a cheaper sticker often means FP8 activations rather than reference weights.

Self-Host: The Open-Weight Qwen Lineup

Alibaba publishes most Qwen generations as downloadable weights, which is the main reason Qwen shows up in every self-hosting comparison. The 2026 lineup has two generations that matter and one license change that matters more.

Open-weight Qwen checkpoints (Hugging Face, September 2026)
CheckpointParams (total / active)ContextLicenseReleased
Qwen/Qwen3.8-27B27B dense262,144 native, 1M via YaRNApache 2.0Aug 14, 2026
Qwen/Qwen3.8-2.4T-A95B2.4T / 95B (512 experts, 10 routed + 1 shared)262,144 native, 1.01M extendedqwen3.8-max licenseAug 12, 2026
Qwen/Qwen3.8-Flash-Next125B / 6B (plus 51B n-gram embedding, 4B MTP)262,144 native, 1M extendedqwen-community-1.0Aug 2026
Qwen/Qwen3.6-27B27B dense262,144 native, 1.01M extendedApache 2.0Apr 22, 2026
Qwen/Qwen3.6-35B-A3B35B / 3B262,144 nativeApache 2.0Apr 16, 2026
Qwen/Qwen3.5-397B-A17B397B / 17B262,144 nativeApache 2.0Feb 2026

Sources: the Hugging Face model cards linked in Sources. Each checkpoint ships an official FP8 variant (for example Qwen/Qwen3.8-27B-FP8). The 27B models share a 64-layer hybrid layout: 16 blocks of three Gated DeltaNet sublayers followed by one gated-attention sublayer.

Coding benchmarks reported on the model cards
CheckpointSWE-bench ProSWE-bench VerifiedLiveCodeBench v6
Qwen3.8-2.4T-A95B67.7n/a on cardn/a on card
Qwen3.8-Flash-Next62.5n/a on card91.9
Qwen3.8-27B61.7n/a on card90.3
Qwen3.6-27B53.577.2n/a on card
The license line moved with Qwen 3.8

Qwen3.6-27B, Qwen3.6-35B-A3B, and Qwen3.8-27B are Apache 2.0: commercial use with attribution and a patent grant, nothing else. Qwen3.8-2.4T-A95B is the first open-weight Max-class Qwen, and it ships under the qwen3.8-max license instead. That license allows commercial use but requires prominent model attribution in the UI once a product passes 100,000,000 monthly active users or US$20,000,000 monthly revenue, and requires a separate commercial license for model-as-a-service or AI work-assistant businesses above US$50,000,000 revenue over 12 consecutive months. Qwen3.8-Flash-Next uses qwen-community-1.0. If your legal review is scoped to Apache, the 27B dense models are the ones that pass without a second read.

For the architecture behind the 27B dense models and why they outscore the 397B MoE they replaced, see Qwen 3.6 27B and Qwen 3.5. For the broader open-weight landscape, see open source LLMs.

vLLM and SGLang Launch Commands

The commands below are the ones in the Qwen3.8 README and the vLLM recipe for Qwen3.8-27B. Both engines need the qwen3 reasoning parser to split thinking from the answer and the qwen3_coder tool-call parser for agent tool use; without them, tool calls arrive as plain text.

Adding the parsers is necessary, not sufficient

The two parser flags are where self-hosted Qwen agents actually break, and the failures are quiet: you get a well-formed response with no tool call rather than an error. Four are worth knowing before you debug your own harness.

  • Tool calls disappear when the model emits XML tool-call markup inside its <think> block. The reasoning parser moves everything before </think> into the reasoning field, and the tool parser only reads the content field, so the call never reaches it and tool_calls comes back empty. Seen on vLLM 0.19 with Qwen3.5-35B-A3B-FP8 under exactly the recommended flag pair (vllm#39056).
  • In non-think streaming mode, Qwen3ReasoningParser.is_reasoning_end can return the wrong result, so the function-call parser never runs and no tool call is emitted at all (vllm#17655).
  • The qwen3_coder parser does not stream tool-call arguments incrementally. It sends no delta until the whole argument is parsed, so a tool call carrying a few thousand tokens of code looks like a frozen stream. Closed as not planned, so plan your UI around it (vllm#30439).
  • If you reach for --tool-call-parser hermes instead, the Qwen3 tokenizer has "} as a single token, id 9207, which the Hermes streaming path truncated to " and produced tool arguments missing their closing brace. Fixed in vLLM by PR #25203, so this one is a reason to stay current rather than to avoid the parser (vllm#19056).

vLLM (0.17.0 or newer): Qwen3.8-27B at native 262K context

vllm serve Qwen/Qwen3.8-27B --port 8000 --tensor-parallel-size 4 \
  --max-model-len 262144 --reasoning-parser qwen3 \
  --enable-auto-tool-choice --tool-call-parser qwen3_coder

vLLM: FP8 weights and FP8 KV cache (largest KV budget)

vllm serve Qwen/Qwen3.8-27B-FP8 \
  --tensor-parallel-size 4 \
  --max-model-len 262144 \
  --kv-cache-dtype fp8 \
  --reasoning-parser qwen3

SGLang: same model, same parsers

sglang serve --model-path Qwen/Qwen3.8-27B --port 8000 --tp-size 4 \
  --context-length 262144 --reasoning-parser qwen3 \
  --tool-call-parser qwen3_coder

The README's --tensor-parallel-size 4 is about KV-cache headroom at 262K context, not weight capacity. The weight arithmetic for a 27B dense model is 27 GB at FP8 (one byte per parameter) and 54 GB at BF16 (two bytes), so a single 80 GB H100 or 141 GB H200 holds the FP8 weights with tens of gigabytes left for KV cache; the vLLM recipe also documents an NVFP4 build at 24.6 GiB on one Blackwell GPU. Run TP=1 for a small team at 32K to 64K context, and go to TP=4 when you need the full 262K window with real concurrency. To push past native context, the recipe passes --max-model-len 1010000 with an --hf-overrides that raises max_position_embeddings, which is YaRN scaling.

Qwen3.8-2.4T-A95B is a different class of deployment: 2.4T parameters is 2.4 TB at FP8 before KV cache, which is a multi-node rack of B200 or B300 GPUs, not a single server. Its model card recommends SGLang, vLLM, or TokenSpeed and does not publish a GPU count. If that is the model you want, the hosted API or a dedicated cluster is the realistic path. For how the serving stack itself is tuned on Morph, see LLM inference and the dedicated inference benchmarks.

Neither the vLLM recipe nor the model card publishes throughput for the 27B, so the only public measured numbers come from practitioners. The most detailed single-GPU writeup runs Qwen3.8-27B on one 24 GB RTX 3090 and reports roughly 1,035 tok/s steady-state decode at 64 concurrent requests (128 in, 512 out) and 948 tok/s end-to-end, plus about 114 tok/s for a single user at default sampling and 124 tok/s greedy. Getting there is not a stock vllm serve: it uses int8 tensor-core GEMMs with an fp16 DeltaNet recurrent state for the batch path, and MTP speculation with a calibrated int4 LM head and split-KV verify attention for the single-user path. Context reaches 150K on the standard config and 262K only with a lossy 4/2-bit KV cache, and the author notes the card must be power-limited to 250 W for the numbers to reproduce (syv-ai/qwen38-27b-rtx3090). Read it as the floor of what a consumer card does, not as a datacenter baseline.

Claude Code, Cline, and Qwen Code Setup

Model Studio runs an Anthropic-compatible Messages endpoint under /apps/anthropic. It serves only /v1/messages; there is no model-list route, so the base URL must end at /apps/anthropic. Appending /v1 makes Claude Code request /v1/models at a doubled path and fail with a 404.

Claude Code on Qwen (Model Studio Coding Plan, international)

export ANTHROPIC_BASE_URL="https://coding-intl.dashscope.aliyuncs.com/apps/anthropic"
export ANTHROPIC_AUTH_TOKEN="YOUR_MODEL_STUDIO_KEY"
export ANTHROPIC_MODEL="qwen3.8-max"
export ANTHROPIC_DEFAULT_SONNET_MODEL="qwen3.8-max"
claude

# Token Plan users swap the base URL:
# https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic

Persist the same four values under an env object in ~/.claude/settings.json to avoid exporting them each session. The key type has to match the endpoint: a pay-as-you-go key against the Coding Plan URL returns an "API key type does not match" error. The legacy dashscope.aliyuncs.com/api/v2/apps/claude-code-proxy URL still works but only serves qwen3-coder-plus. For the general pattern, see using a different LLM in Claude Code.

Qwen Code, Cline, and other OpenAI-SDK agents take the OpenAI-compatible URL instead. Qwen Code reads three environment variables, and the same three values go into ~/.qwen/settings.json under modelProviders if you prefer a file. The pattern is identical for a self-hosted vLLM server: swap the base URL for http://localhost:8000/v1.

Qwen Code (or any OpenAI-compatible CLI) on Model Studio

export OPENAI_BASE_URL="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
export OPENAI_API_KEY="$DASHSCOPE_API_KEY"
export OPENAI_MODEL="qwen3.7-plus"
qwen
# inside the CLI, pick the OpenAI-compatible provider with /auth

Coding Plan subscribers point Qwen Code at https://coding-intl.dashscope.aliyuncs.com/v1 and the CLI stores the key as BAILIAN_CODING_PLAN_API_KEY. Install and provider details are on the Qwen CLI page.

Undocumented Limits That Break Agents

The rate-limit page covers RPM and TPM. It does not cover the three ceilings that actually stop a coding agent mid-run, each of which surfaces as a 400 with wording no agent framework recognizes. All three are documented only in issue trackers.

Hard limits that return a 400, and what the error actually says
LimitReal valueVerbatim errorWhat breaks
Coding Plan input context169,984 tokensRange of input length should be [1, 169984]Clients that trust the advertised 1M window
max_tokens ceiling65,536 tokensRange of max_tokens should be [1, 65536]Retry logic that reads any 400 as context overflow
Model list routeNot served404 on /modelsAny client that enumerates models at startup

The context number is the one that costs the most time. The Coding Plan endpoint at coding-intl.dashscope.aliyuncs.com/v1 serves qwen3.5-plus with an input ceiling of 169,984 tokens, not the 1M the model family advertises and not the 128K most clients assume by default. An agent configured from the model card's context window will run fine for a while and then fail every request once the conversation crosses roughly 170K (hermes-agent#2220). Set the client's context window to the endpoint's limit, not the model's.

The max_tokens ceiling is worse than a plain rejection because of how it fails. DashScope phrases the error as a bracket range rather than in the Anthropic or OpenRouter wording that agent error parsers match on, so a framework misreads it as a context-overflow signal, compresses the conversation, resends the same oversized max_tokens, and gets the identical 400. The result is a compression death loop that reports "context too large" on a two-message conversation while the real cause is one number in the config (hermes-agent#55546). If an agent reports runaway compression against Qwen, check max_tokens before you check the context.

The missing model list is the same root cause as the /apps/anthropic path note above: Alibaba's coding endpoints serve inference routes and not discovery routes, so a /models call returns 404 and any client whose model picker enumerates the provider at startup shows an empty list or fails outright. Pin the model ID in config instead of selecting it from a fetched list.

The Coding Plan is metered in requests, not tokens

This trips up the pricing comparison more than the API. The subscription plans cap requests per 5 hours, per week, and per month, with no token accounting, which makes them impossible to compare directly against a per-token plan and is the first thing developers ask about (Hacker News discussion). Practically it favors long turns: one request that reads 100K tokens of context counts the same as one that reads 500. Agents that make many small tool calls burn the request budget fastest, and a compaction pass that turns five short turns into one long one is worth more here than on a per-token plan.

Qwen API vs DeepSeek vs GLM-5.3 and Kimi K3

The comparison that matters for a coding agent is the monthly bill at agent token shapes, not the sticker. The table prices one profile: 10,000 requests a day at 3,000 input and 1,000 output tokens each, for 30 days, which is 900M input and 300M output tokens per month. No cache hits are assumed, so every row is the ceiling; caching lowers the Qwen, DeepSeek, and Morph rows by different amounts.

Monthly cost, heavy coding-agent profile (900M input + 300M output tokens)
Model (host)Input / 1MOutput / 1MContextMonthly
qwen3.8-max (Model Studio)$2.00$6.001M$3,600
qwen3.7-plus (Model Studio, list)$0.40$1.601M$840
qwen3.8-flash (Model Studio)$0.15$0.471M$276
qwen3.8-27b (Model Studio)$0.50$3.001M$1,350
deepseek-v4-flash (DeepSeek, off-peak)$0.22$0.661M$396
deepseek-v4-flash (DeepSeek, peak)$0.44$1.321M$792
GLM-5.3-Flash (Morph, morph-glm53flash)$0.1$0.351M$195
DeepSeek V4 Flash (Morph, morph-dsv4flash)$0.1234375$0.34751M$215
GLM-5.3 744B (Morph, morph-glm53-744b)$1$3.411M$1,923
Kimi K3 2.8T (Morph, morph-kimik3)$2.5$141M$6,450

Qwen rates from Model Studio Singapore; DeepSeek rates from its official pricing page as checked for our DeepSeek API page (peak hours 01:00 to 04:00 and 06:00 to 10:00 UTC); Morph rates from Morph pricing. Arithmetic: 900 times the input rate plus 300 times the output rate.

Three things fall out of the table. First, the Qwen Flash and Plus tiers sit in the same band as DeepSeek off-peak and Morph's GLM-5.3-Flash; within that band the deciding factors are rate limits, region, and how each model handles your tool-call format, not price. Second, the Max tier costs about 13x the Plus tier for the same tokens, so an agent that routes only hard turns to Max keeps most of Max's quality at a Plus-sized bill; see LLM routing. Third, the 27B open-weight model is more expensive hosted on Model Studio ($0.50/$3.00) than the proprietary Plus model, which is why teams that want the 27B usually self-host it or buy a dedicated endpoint rather than call it per token.

On quality, the model cards put Qwen3.8-27B at 61.7 SWE-bench Pro and Qwen3.8-2.4T-A95B at 67.7. For where GLM-5.3 and Kimi K3 land on the same benchmarks and how Morph serves them, see GLM-5.3, Kimi K3, and Morph's model lineup. For the broader provider table, see LLM API comparison and Kimi API.

Dedicated inference planner

Plan a Qwen 3.6 27B endpoint

Turn your team size and agent workload into a capacity estimate. Then validate the recommendation with your own traces.

Workload economics
Per model decision
900M
tokens per month
100 tok/s
required generation
$471
serverless per month
$14,016
dedicated per month
Sizing review required

An exact Morph capacity measurement is required before recommending a dedicated plan.

B200 is the compatible public platform. Dedicated capacity is invoiced monthly at the beginning of the month. Tokens are not billed separately.

Difference from serverless: $13,545 more per month.

A dedicated endpoint is the third way to run Qwen: not Alibaba's shared API, not your own vLLM box. Morph provisions Qwen 3.6 27B on single-tenant B200 GPUs behind the same OpenAI-compatible contract, billed per GPU-hour, so a team's agent traffic never queues behind another customer's and rate limits are whatever the hardware sustains. Use the planner above to turn a team size and agent workload into a GPU count, then open the full calculator or read the dedicated inference overview for pricing and lead time.

FAQ

What is the Qwen API?

The Qwen API is the hosted interface to Alibaba's Qwen model family, served by Alibaba Cloud Model Studio, the platform previously branded DashScope. It exposes an OpenAI-compatible Chat Completions endpoint, an Anthropic-compatible Messages endpoint used by Claude Code, and the DashScope native API for Alibaba-specific features such as image generation. You call it with an OpenAI SDK by changing base_url, api_key, and model name, and you are billed per million input and output tokens.

How do I get a Qwen API key?

Create an Alibaba Cloud account at account.alibabacloud.com, open modelstudio.console.alibabacloud.com and accept the Terms of Service dialog to activate Model Studio, select your region in the console header, then open the API Key page and click Create API key. The key looks like sk-ee166797fe40xxx and the plaintext is shown once. Export it as DASHSCOPE_API_KEY. Keys are region-scoped, so a Singapore key will not authenticate against the Beijing endpoint.

What is DashScope and is it the same as the Qwen API?

DashScope is the former name of Alibaba Cloud Model Studio, and the two refer to the same service. The name survives in the parts developers touch most: the API key environment variable is still DASHSCOPE_API_KEY, the native (non-OpenAI-compatible) API is still called the DashScope API, and several endpoint hostnames still contain dashscope. New integrations should use the workspace-specific Model Studio domains; the older dashscope-intl.aliyuncs.com host is legacy and has known client-side connection failures.

What are the main features of the Qwen API?

OpenAI-compatible Chat Completions with streaming, tool calling, and JSON mode; an Anthropic-compatible Messages endpoint for Claude Code; context windows up to 1M tokens; controllable reasoning through enable_thinking and thinking_budget with reasoning returned in a reasoning_content field; vision-language input on the flagship and qwen3-vl models; image generation through the DashScope MultiModalConversation API; batch inference at 50% off on supported models; and context caching that discounts repeated input. Open weights for several Qwen generations are downloadable, so the same model can be self-hosted.

Are Qwen thinking tokens billed as extra output tokens?

Yes. Alibaba's deep-thinking documentation states that thinking content is billed per output token, so reasoning counts at the full output rate, which is $6 per million on qwen3.8-max. It also states that when a thinking-mode model produces no reasoning output, non-thinking pricing applies. Use thinking_budget to cap reasoning tokens; the model stops reasoning and answers immediately when the cap is reached.

Where can I access Qwen 3.6 Plus and Qwen 3.7 Plus via API?

Both are Alibaba's own proprietary models, so the first-party source is Alibaba Cloud Model Studio on the /compatible-mode/v1 endpoint using the model IDs qwen3.6-plus and qwen3.7-plus. Model Studio Singapore lists qwen3.7-plus at $0.40/$1.60 per million tokens and qwen3.6-plus at $0.50/$3.00. They are also resold through routers such as OpenRouter, at rates that track upstream promotions and move independently of Alibaba's list price. Neither is open-weight, so neither can be self-hosted.

What is the Qwen API base URL?

For the international (Singapore) region of Alibaba Cloud Model Studio, the OpenAI-compatible base URL is https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1, where {WorkspaceId} is your Model Studio workspace ID. The China (Beijing) region uses https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1 and the US (Virginia) region uses https://dashscope-us.aliyuncs.com/compatible-mode/v1. The DashScope native endpoint replaces /compatible-mode/v1 with /api/v1. Older docs reference dashscope-intl.aliyuncs.com; Alibaba now recommends the workspace-specific domains.

How much does the Qwen API cost?

On the Singapore region, per million tokens: qwen3.8-max is $2 input and $6 output, flat. qwen3.7-plus is $0.40/$1.60 up to 256K input tokens and $1.20/$4.80 from 256K to 1M, with a limited-time 20% discount applied at the time of writing. qwen3.8-flash is $0.15/$0.47 flat. qwen3-coder-plus is tiered by input length: $1/$5 up to 32K, $1.80/$9 to 128K, $3/$15 to 256K, and $6/$60 to 1M. The open-weight qwen3.8-27b is $0.50/$3 hosted. Batch inference is 50% off on the models that list it, and context caching discounts cached input.

Is the Qwen API free?

Partly. Every proprietary Qwen model on Model Studio ships with a 1M-token free quota valid for 90 days from the later of Model Studio activation or model release, so a new account gets roughly 1M free tokens per model across the catalog. After the quota is used or expires, billing is pay-as-you-go per token. The free quota does not apply to the Batch API, context caching, or fine-tuning. The open weights are free to download under Apache 2.0 (Qwen3.8-27B, Qwen3.6-27B, Qwen3.6-35B-A3B) if you self-host. Note that this is a different free tier from the Qwen Code OAuth free tier, which required no Alibaba Cloud account and was discontinued on April 15, 2026.

Which Qwen API model should I use for coding agents?

qwen3.7-plus ($0.40/$1.60, 1M context) is the price-performance default for agent loops; qwen3.8-max ($2/$6) when the task needs the flagship. qwen3-coder-plus is the dedicated coding line but its tiered pricing climbs to $6/$60 above 256K input, so keep its context short. qwen3.8-flash ($0.15/$0.47) covers classification and cheap subagent turns. For self-hosting, Qwen3.8-27B (Apache 2.0) scores 61.7 on SWE-bench Pro and fits one 80 GB GPU at FP8.

Is the Qwen API OpenAI-compatible?

Yes. Model Studio exposes an OpenAI-compatible Chat Completions endpoint under /compatible-mode/v1, so the OpenAI Python and Node SDKs work by changing base_url and api_key. It also exposes an Anthropic-compatible Messages endpoint under /apps/anthropic that serves only /v1/messages (no model list), which is what Claude Code uses. The DashScope native API under /api/v1 carries Alibaba-specific features.

How do I use Qwen with Claude Code?

Point Claude Code at the Anthropic-compatible endpoint for your plan. Set ANTHROPIC_BASE_URL to https://coding-intl.dashscope.aliyuncs.com/apps/anthropic (Coding Plan) or https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic (Token Plan), ANTHROPIC_AUTH_TOKEN to your Model Studio key, and ANTHROPIC_MODEL plus ANTHROPIC_DEFAULT_SONNET_MODEL to a model ID such as qwen3.8-max or qwen3.7-plus. The base URL must end at /apps/anthropic; adding /v1 makes Claude Code request /v1/models and 404. The legacy dashscope.aliyuncs.com/api/v2/apps/claude-code-proxy URL only serves qwen3-coder-plus.

What are the Qwen API rate limits?

Limits are per Alibaba Cloud account, combined across all RAM users, workspaces, and API keys. On Singapore: qwen3.8-max is 15,000 RPM and 2,000,000 TPM, qwen3.7-plus 15,000 RPM and 5,000,000 TPM, qwen3-coder-plus 2,400 RPM and 2,000,000 TPM. Beijing is higher: 30,000 RPM and 5,000,000 TPM for qwen3.8-max. The service also enforces per-second ceilings of RPM/60 and TPM/60, so bursts can 429 before the minute total does. You can raise TPM temporarily for 30 days from the console. Three separate hard limits also return a 400 and are not on the rate-limit page: the Coding Plan endpoint caps input at 169,984 tokens, max_tokens is capped at 65,536, and the /models route is not served.

Can I self-host Qwen instead of using the API?

Yes. Qwen3.8-27B (27B dense, Apache 2.0, 262,144 native context) serves on vLLM 0.17.0+ or SGLang with the qwen3 reasoning parser and qwen3_coder tool-call parser; at FP8 the weights are about 27 GB, so one 80 GB H100 or H200 holds them with KV cache headroom. Qwen3.8-2.4T-A95B (2.4T total, 95B active) is open-weight under the qwen3.8-max license, which requires attribution above 100M monthly active users or $20M monthly revenue and a separate license for model-as-a-service businesses above $50M in 12 months. Morph runs Qwen as a dedicated single-tenant endpoint if you want it hosted without sharing capacity.

Does Morph still serve Qwen on its public API?

No. Morph's public Qwen aliases (morph-qwen35-397b, morph-qwen36-27b, morph-qwen38-27b) were retired on August 27, 2026 when that capacity consolidated onto GLM-5.3-Flash. The names still resolve for existing traffic but are off every public surface. Qwen 3.6 27B remains available as a dedicated single-tenant deployment on Morph's B200 pool, priced per GPU-hour rather than per token.

Want Qwen without the shared rate limit?

Morph runs Qwen 3.6 27B as a dedicated single-tenant endpoint on B200 GPUs: one OpenAI-compatible API, capacity you do not share, priced per GPU-hour. Size it with the calculator or talk to us about a custom checkpoint.

Sources