Skip to Content
ModelsQwen

Qwen family

Alibaba Cloud’s Qwen text models, including the Qwen3.8, Qwen3.7 and Qwen3.6 series, Qwen Flash and Qwen Plus. They are called through the OpenAI-compatible API, and the Qwen3.x series also supports the Anthropic-native API. For image generation models, see Qwen-Image.

Common tasks

Models

For the full model list and live prices, see the model page , or query the Models API. You can omit the qwen/ prefix from model IDs.

Common model IDs (copy them exactly)
Qwen3.8 Maxqwen/qwen3.8-maxSupports image input
Qwen3.8 Flashqwen/qwen3.8-flashSupports image input
Qwen3.7 Plusqwen/qwen3.7-plusSupports image input
Qwen Flashqwen/qwen-flashNo thinking by default; text only
CapabilitySupported models
Image inputQwen3.8 Max, 3.8 Flash, 3.8 27B, 3.7 Plus, 3.6 Flash
Anthropic-native APIQwen3.8, 3.7 and 3.6 series, Qwen Flash
Responses APIQwen3.8 and 3.7 series, Qwen Flash and others; supported_endpoints in the Models API is authoritative

Qwen models are served by Alibaba Cloud Model Studio through two providers, the China site (aliyun) and the international site (alicloud), selected automatically by default. For how to select one, see Provider routing.

Examples

qwen_basic.py
import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"]) resp = client.chat.completions.create( model="qwen/qwen3.8-flash", messages=[{"role": "user", "content": "Explain idempotency in one sentence."}], extra_body={"enable_thinking": False}, ) print(resp.choices[0].message.content)

Thinking mode

Key pointThe Qwen3.x series thinks by default, and complex questions can use tens of thousands of thinking tokens and take several minutes. Turn thinking off as needed, or cap its length with thinking_budget.
ModelDefaultTurn thinking offTurn thinking on
Qwen3.8, 3.7 and 3.6 seriesOn"enable_thinking": falseOn by default
Qwen Flash, Qwen PlusOffOff by default"enable_thinking": true

In our tests on the same math problem, Qwen3.8 Flash thought for about 5,800 tokens by default and took about 1.5 minutes, while Qwen3.6 Flash thought for over 30,000 tokens and took more than 4 minutes; with thinking off, both returned within a few seconds.

Capping thinking length

When you need thinking but want to control latency and cost, pass thinking_budget (a cap on thinking tokens):

qwen_thinking_budget.py
import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"]) resp = client.chat.completions.create( model="qwen/qwen3.8-flash", messages=[{"role": "user", "content": "Find all positive integers n less than 50 for which n² + n + 41 is not prime."}], extra_body={"enable_thinking": True, "thinking_budget": 1000}, ) msg = resp.choices[0].message details = getattr(msg, "reasoning_details", None) or [] print("[Thinking]", "".join(d.get("text", "") for d in details)[:200], "…") print("[Answer]", msg.content) print("Thinking tokens:", resp.usage.completion_tokens_details.reasoning_tokens)
  • In our tests thinking_budget is enforced strictly: set to 200, thinking used exactly 200 tokens.
  • enable_thinking and thinking_budget are not standard OpenAI SDK parameters, so put them in extra_body; when sending raw HTTP requests, put them at the top level of the request body.
  • Thinking tokens are billed at the output rate; the count is in usage.completion_tokens_details.reasoning_tokens.

Reading the thinking content

  • In streaming responses, thinking content is in delta.reasoning_content, the same as the official Alibaba Cloud Model Studio API.
  • In non-streaming responses, thinking content is in message.reasoning_details; concatenate the text of each item in order (see the example above).

Image input

Models that support image input use the standard image_url content block:

qwen_vision.py
import base64 import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"]) img_b64 = base64.b64encode(open("photo.png", "rb").read()).decode() resp = client.chat.completions.create( model="qwen/qwen3.8-flash", messages=[{"role": "user", "content": [ {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img_b64}"}}, {"type": "text", "text": "Describe this image."}, ]}], extra_body={"enable_thinking": False}, ) print(resp.choices[0].message.content)

Qwen3.7 Max, Qwen Plus and Qwen Flash are text-only; use one of the image-capable models in the table above instead.

Use in Claude Code

The Qwen3.x series and Qwen Flash support the Anthropic-native API at https://api.ofox.io/anthropic:

Claude Code settings
ANTHROPIC_BASE_URLhttps://api.ofox.io/anthropic
ANTHROPIC_AUTH_TOKENPaste your OfoxAI API key
ANTHROPIC_MODELqwen/qwen3.8-max
  • On the Anthropic API, thinking content is returned as thinking blocks.
  • The Qwen3.8 series thinks a lot, so set a large enough max_tokens. In our tests, with max_tokens at 4000 the response could contain only a thinking block and no answer.
  • Qwen Plus does not support the Anthropic API; calls return protocol_not_supported.

For full Claude Code setup steps, see Claude Code setup.

JSON output and tool calling

response_format supports {"type": "json_object"} and {"type": "json_schema", ...}; tool calling uses the standard tools parameter. When using json_object, state “return JSON” and the required fields in the prompt. For the syntax, see Structured output and Function calling.

Prompt caching

Qwen automatically caches repeated request prefixes, with no changes to your request. The cached amount is in usage.prompt_tokens_details.cached_tokens, and the cached portion is billed at the cache read rate. Caching is best-effort; requests with the same prefix may still miss.

Common errors

Key pointSlow requests or empty answers are usually caused by thinking, which is on by default. Turn it off if you don’t need it.
HTTP · typeError messageCauseFix
400 invalid_request_errorContains The provided messages input is invalid. The error info is [Unexpected item type in content.]An image was sent to a text-only model (e.g. Qwen3.7 Max)Use an image-capable model — see Image input
400 protocol_not_supportedModel 'qwen/qwen-plus' does not support the 'anthropic' protocol on this platform.The model does not support the Anthropic APIUse the OpenAI-compatible API, or switch to the Qwen3.x series
404 model_not_foundModel 'qwen/qwen9-max' not foundModel ID misspelledCopy the model ID from this page
200, empty answer or thinking content only—Thinking used up the output budgetIncrease max_tokens, set thinking_budget, or turn thinking off
Request timeout—Thinking is on by default, and complex questions take longerTurn thinking off, set thinking_budget, use streaming, or set the client timeout to 600 seconds or more

For other general errors, see Error Handling.

Official docs

The official docs describe behavior when calling Alibaba Cloud Model Studio directly. When calling through OfoxAI, model IDs and endpoints on this page take precedence.

FAQ

How do I write a Qwen model ID?

The standard format is qwen/qwen3.8-flash; you can also omit the qwen/ prefix.

How do I turn off Qwen thinking?

Pass "enable_thinking": false; with the OpenAI SDK, put it in extra_body. The Qwen3.8, 3.7 and 3.6 series think by default; Qwen Flash and Qwen Plus do not.

Why does Qwen take several minutes to respond?

The Qwen3.x series thinks by default, and complex questions can use tens of thousands of thinking tokens. Turn thinking off, or cap its length with thinking_budget, e.g. "thinking_budget": 1000.

How do I use Qwen thinking_budget?

Pass it together with "enable_thinking": true; the value is the cap on thinking tokens, e.g. 1000. In our tests it is enforced strictly.

Which Qwen models can understand images?

Qwen3.8 Max, 3.8 Flash, 3.8 27B, 3.7 Plus and 3.6 Flash support image input. Qwen3.7 Max, Qwen Plus and Qwen Flash are text-only.

Can I use Qwen in Claude Code?

Yes. Set ANTHROPIC_BASE_URL to https://api.ofox.io/anthropic and use a Qwen3.x series model such as qwen/qwen3.8-max. Qwen Plus does not support the Anthropic API.

Where is Qwen reasoning_content?

In streaming responses it is in delta.reasoning_content; in non-streaming responses it is in message.reasoning_details, where you concatenate the text of each item.

Last updated on