# Qwen API: model IDs, thinking mode, thinking budget and errors Source: https://ofox.io/docs/develop/models/qwen 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](https://ofox.io/docs/develop/models/qwen-image). ## Common tasks - [Control thinking](#thinking) — Turn thinking off or cap its length to avoid slow requests. - [Image input](#vision) — Which models can understand images. - [Use in Claude Code](#anthropic) — Call Qwen through the Anthropic API. - [Troubleshooting errors](#errors) — Protocol not supported, image input errors, empty answers. ## Models For the full model list and live prices, see the [model page](https://ofox.io/models?provider=qwen), or query the [Models API](https://ofox.io/docs/api/openai/models). You can omit the `qwen/` prefix from model IDs. **Common model IDs (copy them exactly)** - Qwen3.8 Max: `qwen/qwen3.8-max` — Supports image input - Qwen3.8 Flash: `qwen/qwen3.8-flash` — Supports image input - Qwen3.7 Plus: `qwen/qwen3.7-plus` — Supports image input - Qwen Flash: `qwen/qwen-flash` — No thinking by default; text only | Capability | Supported models | |---|---| | Image input | Qwen3.8 Max, 3.8 Flash, 3.8 27B, 3.7 Plus, 3.6 Flash | | Anthropic-native API | Qwen3.8, 3.7 and 3.6 series, Qwen Flash | | Responses API | Qwen3.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](https://ofox.io/docs/develop/advanced/provider-routing). ## Examples **Python** ```python filename="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) ``` **cURL** ```bash filename="Terminal" curl https://api.ofox.io/v1/chat/completions \ -H "Authorization: Bearer $OFOX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen/qwen3.8-flash", "messages": [{"role": "user", "content": "Explain idempotency in one sentence."}], "enable_thinking": false }' ``` ## Thinking mode **Key point**:The 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. | Model | Default | Turn thinking off | Turn thinking on | |---|---|---|---| | Qwen3.8, 3.7 and 3.6 series | On | `"enable_thinking": false` | On by default | | Qwen Flash, Qwen Plus | Off | Off 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): ```python filename="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: ```python filename="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_URL: `https://api.ofox.io/anthropic` - ANTHROPIC_AUTH_TOKEN: Paste your OfoxAI API key - ANTHROPIC_MODEL: `qwen/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](https://ofox.io/docs/integrations/claude-code). ## 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](https://ofox.io/docs/develop/guides/structured-output) and [Function calling](https://ofox.io/docs/develop/guides/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 point**:Slow requests or empty answers are usually caused by thinking, which is on by default. Turn it off if you don't need it. | HTTP · type | Error message | Cause | Fix | |---|---|---|---| | 400 `invalid_request_error` | Contains `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](#vision) | | 400 `protocol_not_supported` | `Model 'qwen/qwen-plus' does not support the 'anthropic' protocol on this platform.` | The model does not support the Anthropic API | Use the OpenAI-compatible API, or switch to the Qwen3.x series | | 404 `model_not_found` | `Model 'qwen/qwen9-max' not found` | Model ID misspelled | Copy the model ID from this page | | 200, empty answer or thinking content only | — | Thinking used up the output budget | Increase `max_tokens`, set `thinking_budget`, or turn thinking off | | Request timeout | — | Thinking is on by default, and complex questions take longer | Turn thinking off, set `thinking_budget`, use streaming, or set the client timeout to 600 seconds or more | For other general errors, see [Error Handling](https://ofox.io/docs/develop/guides/error-handling). ## Official docs - [Alibaba Cloud Model Studio · Models](https://help.aliyun.com/zh/model-studio/models) - [Alibaba Cloud Model Studio · Deep thinking](https://help.aliyun.com/zh/model-studio/deep-thinking) - [Alibaba Cloud Model Studio · OpenAI compatibility](https://help.aliyun.com/zh/model-studio/compatibility-of-openai-with-dashscope) 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.