This topic describes how to call Qwen using the OpenAI-compatible Responses API, the input and output parameters, and code samples.
Advantages over the OpenAI Chat Completions API:
Built-in tools: Includes web search, code interpreter, and web extractor. Use these tools together (
tools=[{"type": "web_search"}, {"type": "code_interpreter"}, {"type": "web_extractor"}]) for best performance against complex tasks. See Call built-in tools.More flexible input: Supports passing a string directly as model input. Compatible with message arrays in the Chat format.
Simplified context management: Pass the
previous_response_idfrom the previous response instead of manually building the complete message history array.
Compatibility notes and limitations
This API is designed to be compatible with OpenAI to reduce migration costs. However, there are differences in parameters, features, and specific behaviors.
Core principle: Requests process only the parameters explicitly listed in this document. Any OpenAI parameters that are not mentioned are ignored.
Key differences:
Multimodal input not supported: Currently, only
qwen3-max-2026-01-23is supported. Theinputparameter supports only text, not images or other file types.Unsupported parameters: Some OpenAI Responses API parameters are not supported, such as
instructionsandbackground. Currently, only synchronous calls are supported.Additional parameters: This API also supports extra parameters, such as
enable_thinking. For specific usage, see the description of the corresponding parameter.
Currently, supported only in the Singapore region.
Singapore
base_url for SDK: https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1
HTTP endpoint: POST https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1/responses
Request body | Basic callPythonNode.jscurlStreaming outputPythonNode.jscurlMulti-turn conversationPythonNode.jsCall built-in toolsPythonNode.jscurl |
model The model name. Currently, only | |
input The model input. The following formats are supported:
| |
previous_response_id The unique ID of the previous response. The current response | |
stream Specifies whether to enable streaming output. If this parameter is set to | |
tools An array of tools that the model can call when it generates a response. It supports a mix of built-in tools and user-defined function tools. For the best response, we recommend that you enable the | |
tool_choice Controls how the model selects and calls tools. This parameter supports two formats: a string and an object. String format
Object Pattern Sets the range of available tools for the model. The model can select and call tools only from the predefined list of tools. | |
temperature The sampling temperature. This parameter controls the diversity of the generated text. A higher temperature results in more diverse text. A lower temperature results in more deterministic text. Value range: [0, 2) Both temperature and top_p control the diversity of the generated text. We recommend that you set only one of them. For more information, see Text generation model overview. | |
top_p The probability threshold for nucleus sampling. This parameter controls the diversity of the generated text. A higher top_p value results in more diverse text. A lower top_p value results in more deterministic text. Value range: (0, 1.0] Both temperature and top_p control the diversity of the generated text. We recommend that you set only one of them. For more information, see Text generation model overview. | |
enable_thinking Specifies whether to enable the thinking mode. If this parameter is enabled, the model thinks before it replies. The thinking process is returned through an output item of the If the thinking mode is enabled, we recommend that you enable the built-in tools to achieve the best model performance on complex tasks. Valid values:
This parameter is not a standard OpenAI parameter. The Python SDK passes it using |
Response object (non-streaming output) | |
id The unique identifier for this response. It is a UUID string and is valid for 7 days. You can use this identifier in the | |
created_at The Unix timestamp in seconds for this request. | |
object The object type. The value is | |
status The status of the response generation. Valid values:
| |
model The ID of the model that is used to generate the response. | |
output An array of output items that are generated by the model. The type and order of elements in the array depend on the model's response. | |
usage The token consumption information for this request. | |
error The error object that is returned when the model fails to generate a response. This field is | |
tools The complete content of the | |
tool_choice The value of the |
Response chunk object (streaming output) | Basic callCall built-in tools |
Streaming output returns a series of JSON objects. Each object includes a | |
type The event type identifier. Valid values:
| |
sequence_number The event serial number. It starts from 0 and increments. You can use it to ensure that the client processes events in the correct order. | |
response The response object. It appears in the | |
item The output item object. It appears in the | |
part The content block object. It appears in the | |
delta The incremental text content. It appears in the | |
text The complete text content. It appears in the | |
item_id The unique identifier for the output item. It is used to associate related events for the same output item. | |
output_index The index position of the output item in the | |
content_index The index position of the content block in the | |
summary_index The index of the summary array. It appears in the |
FAQ
Q: How to pass the context for a multi-turn conversation?
A: To start a new turn in the conversation, just pass the id from the previous response as previous_response_id.
Q: Why are some fields in the response examples not described in this document?
A: If you use the official OpenAI SDK, it may output additional fields, usually null, based on its own model structure. These fields are defined by the OpenAI protocol but are not currently supported by our service. You need to focus only on the fields that are described in this document.