Tradução de apoio para consulta. Código e identificadores técnicos preservados. Consultar referência original ↗
OpenAPI
#Bate-papo OpenAI
API de bate-papo compatível
OpenAPI
openapi: 3.1.0
info:
title: Qwen OpenAI-compatible Chat API
description: Call Qwen models using the OpenAI-compatible Chat API. Supports text and multimodal models, streaming, tool calls, and structured output.
version: 1.0.0
servers:
- url: https://maas.qwencloudapi.com
description: Singapore
security:
- BearerAuth: []
paths:
/compatible-mode/v1/chat/completions:
post:
operationId: openaiChatCompletions
summary: Chat completions
description: Send messages to a Qwen model and receive a generated reply using the OpenAI-compatible API. Supports multi-turn chat, streaming, tool calls, structured output, thinking mode, and multimodal input (images, video, audio).
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ChatCompletionRequest"
example:
model: qwen3.8-max
messages:
- role: system
content: You are a helpful assistant.
- role: user
content: Who are you?
responses:
"200":
description: Successful response
content:
application/json:
schema:
$ref: "#/components/schemas/ChatCompletion"
example:
choices:
- message:
role: assistant
content: I am a large-scale language model developed by Alibaba Cloud. My name is Qwen.
finish_reason: stop
index: 0
logprobs: null
object: chat.completion
usage:
prompt_tokens: 3019
completion_tokens: 104
total_tokens: 3123
prompt_tokens_details:
cached_tokens: 2048
created: 1735120033
system_fingerprint: null
model: qwen3.8-max
id: chatcmpl-6ada9ed2-7f33-9de2-8bb0-78bd4035025a
text/event-stream:
schema:
$ref: "#/components/schemas/ChatCompletionChunk"
example:
id: chatcmpl-9b4f5e3a-5b7d-4c8e-a1f2-3d6e7f8a9b0c
choices:
- delta:
content: ""
function_call: null
refusal: null
role: assistant
tool_calls: null
finish_reason: null
index: 0
logprobs: null
created: 1735120033
model: qwen3.8-max
system_fingerprint: null
object: chat.completion.chunk
usage: null
"400":
description: Invalid request parameters
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
example:
error:
message: you must provide a model parameter.
type: invalid_request_error
param: null
code: null
"401":
description: Authentication failed
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
example:
error:
message: Incorrect API key provided.
type: invalid_request_error
param: null
code: invalid_api_key
"429":
description: Rate limit exceeded
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
example:
error:
message: You have exceeded your current request limit.
type: limit_requests
param: null
code: limit_requests
x-codeSamples:
- lang: python
label: Text input
source: |-
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not set, replace the following line with:api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://maas.qwencloudapi.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
model="qwen3.8-max",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"},
],
# extra_body={"enable_thinking": False},
)
print(completion.model_dump_json())
- lang: java
label: Text input
source: |-
// This code uses OpenAI SDK version 2.6.0
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.chat.completions.ChatCompletion;
import com.openai.models.chat.completions.ChatCompletionCreateParams;
public class Main {
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.baseUrl("https://maas.qwencloudapi.com/compatible-mode/v1")
.build();
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
.addUserMessage("Who are you?")
.model("qwen3.8-max")
.build();
try {
ChatCompletion chatCompletion = client.chat().completions().create(params);
System.out.println(chatCompletion);
} catch (Exception e) {
System.err.println("Error occurred: " + e.getMessage());
e.printStackTrace();
}
}
}
- lang: javascript
label: Text input
source: |-
import OpenAI from "openai";
const openai = new OpenAI(
{
// If the environment variable is not set, replace the following line with:apiKey: "sk-xxx",
apiKey:process.env.DASHSCOPE_API_KEY,
baseURL: "https://maas.qwencloudapi.com/compatible-mode/v1"
}
);
async function main() {
const completion = await openai.chat.completions.create({
model: "qwen3.8-max",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Who are you?" }
],
});
console.log(JSON.stringify(completion))
}
main();
- lang: go
label: Text input
source: |-
package main
import (
"context"
"os"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey(os.Getenv("DASHSCOPE_API_KEY")), // defaults to os.LookupEnv("OPENAI_API_KEY")
option.WithBaseURL("https://maas.qwencloudapi.com/compatible-mode/v1/"),
)
chatCompletion, err := client.Chat.Completions.New(
context.TODO(), openai.ChatCompletionNewParams{
Messages:openai.F(
[]openai.ChatCompletionMessageParamUnion{
openai.UserMessage("Who are you?"),
},
),
Model:openai.F("qwen3.8-max"),
},
)
if err != nil {
panic(err.Error())
}
println(chatCompletion.Choices[0].Message.Content)
}
- lang: csharp
label: Text input
source: |-
using System.Net.Http.Headers;
using System.Text;
class Program
{
private static readonly HttpClient httpClient = new HttpClient();
static async Task Main(string[] args)
{
// If the environment variable is not set, replace the following line with:string? apiKey = "sk-xxx";
string? apiKey = Environment.GetEnvironmentVariable("DASHSCOPE_API_KEY");
if (string.IsNullOrEmpty(apiKey))
{
Console.WriteLine("API Key is not set. Make sure the 'DASHSCOPE_API_KEY' environment variable is set.");
return;
}
// Set the request URL and content
string url = "https://maas.qwencloudapi.com/compatible-mode/v1/chat/completions";
string jsonContent = @"{
""model"": ""qwen3.8-max"",
""messages"": [
{
""role"": ""system"",
""content"": ""You are a helpful assistant.""
},
{
""role"": ""user"",
""content"": ""Who are you?""
}
]
}";
// Send the request and get the response
string result = await SendPostRequestAsync(url, jsonContent, apiKey);
// Print the result
Console.WriteLine(result);
}
private static async Task<string> SendPostRequestAsync(string url, string jsonContent, string apiKey)
{
using (var content = new StringContent(jsonContent, Encoding.UTF8, "application/json"))
{
// Set the request headers
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// Send the request and get the response
HttpResponseMessage response = await httpClient.PostAsync(url, content);
// Handle the response
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadAsStringAsync();
}
else
{
return $"Request failed: {response.StatusCode}";
}
}
}
}
- lang: php
label: Text input
source: |-
<?php
// Set the request URL
$url = 'https://maas.qwencloudapi.com/compatible-mode/v1/chat/completions';
// If the environment variable is not set, replace the following line with: $apiKey = "sk-xxx";
$apiKey = getenv('DASHSCOPE_API_KEY');
// Set the request headers
$headers = [
'Authorization: Bearer '.$apiKey,
'Content-Type:application/json'
];
// Set the request body
$data = [
"model" => "qwen3.8-max",
"messages" => [
[
"role" => "system",
"content" => "You are a helpful assistant."
],
[
"role" => "user",
"content" => "Who are you?"
]
]
];
// Initialize a cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Execute the cURL session
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
}
// Close the cURL resource
curl_close($ch);
// Print the response
echo $response;
?>
- lang: curl
label: Text input
source: |-
curl -X POST https://maas.qwencloudapi.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type:application/json" \
-d '{
"model": "qwen3.8-max",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Who are you?"
}
]
}'
- lang: python
label: Streaming
source: |-
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not set, replace the following line with:api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://maas.qwencloudapi.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
model="qwen3.8-max",
messages=[{'role': 'system', 'content': 'You are a helpful assistant.'},
{'role': 'user', 'content': 'Who are you?'},],
stream=True,
stream_options={"include_usage": True}
)
for chunk in completion:print(chunk.model_dump_json())
- lang: javascript
label: Streaming
source: |-
import OpenAI from "openai";
const openai = new OpenAI(
{
apiKey:process.env.DASHSCOPE_API_KEY,
baseURL: "https://maas.qwencloudapi.com/compatible-mode/v1"
}
);
async function main() {
const completion = await openai.chat.completions.create({
model: "qwen3.8-max",
messages: [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"}
],
stream:true,
});
for await (const chunk of completion) {
console.log(JSON.stringify(chunk));
}
}
main();
- lang: curl
label: Streaming
source: |-
curl --location "https://maas.qwencloudapi.com/compatible-mode/v1/chat/completions" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type:application/json" \
--data '{
"model": "qwen3.8-max",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Who are you?"
}
],
"stream":true
}'
- lang: python
label: Image input
source: |-
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not set, replace the following line with:api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://maas.qwencloudapi.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
model="qwen3.8-max",
messages=[
{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"}},
{"type": "text", "text": "Describe what you see in this image"},
],
}
],
)
print(completion.model_dump_json())
- lang: javascript
label: Image input
source: |-
import OpenAI from "openai";
const openai = new OpenAI({
// If the environment variable is not set, replace the following line with:apiKey: "sk-xxx",
apiKey:process.env.DASHSCOPE_API_KEY,
baseURL: "https://maas.qwencloudapi.com/compatible-mode/v1"
});
async function main() {
const completion = await openai.chat.completions.create({
model: "qwen3.8-max",
messages: [
{
role: "user",
content: [
{ type: "image_url", image_url: { url: "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg" } },
{ type: "text", text: "Describe what you see in this image" },
]
}
],
});
console.log(JSON.stringify(completion));
}
main();
- lang: curl
label: Image input
source: |-
curl -X POST https://maas.qwencloudapi.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": [
{
"type": "image_url",
"image_url": {"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"}
},
{
"type": "text",
"text": "Describe what you see in this image"
}
]
}
]
}'
- lang: python
label: Video input
source: |-
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not set, replace the following line with:api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://maas.qwencloudapi.com/compatible-mode/v1",
)
# This example passes a list of images as video input. See the visual understanding guide for passing video files
completion = client.chat.completions.create(
model="qwen3.8-max",
messages=[
{
"role": "user",
"content": [
{
"type": "video",
"video": [
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg"
]
},
{"type": "text", "text": "Describe the specific process in this video"},
],
}
],
)
print(completion.model_dump_json())
- lang: javascript
label: Video input
source: |-
import OpenAI from "openai";
const openai = new OpenAI({
// If the environment variable is not set, replace the following line with:apiKey: "sk-xxx",
apiKey:process.env.DASHSCOPE_API_KEY,
baseURL: "https://maas.qwencloudapi.com/compatible-mode/v1"
});
async function main() {
const completion = await openai.chat.completions.create({
model: "qwen3.8-max",
messages: [
{
role: "user",
content: [
{
type: "video",
video: [
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg"
]
},
{ type: "text", text: "Describe the specific process in this video" },
]
}
],
});
console.log(JSON.stringify(completion));
}
main();
- lang: curl
label: Video input
source: |-
curl -X POST https://maas.qwencloudapi.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": [
{
"type": "video",
"video": [
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg",
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg"
]
},
{
"type": "text",
"text": "Describe the specific process in this video"
}
]
}
]
}'
- lang: python
label: Tool calling
source: |-
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not set, replace the following line with:api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://maas.qwencloudapi.com/compatible-mode/v1",
)
tools = [
# Tool 1:get the current time
{
"type": "function",
"function": {
"name": "get_current_time",
"description": "Useful when you want to know the current time.",
# Getting the current time needs no input parameters, so parameters is an empty dictionary
"parameters": {}
}
},
# Tool 2:get the weather for a specified city
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Useful when you want to query the weather of a specified city.",
"parameters": {
"type": "object",
"properties": {
# A location must be provided to query the weather, so the parameter is set to location
"location": {
"type": "string",
"description": "A city or district, such as Beijing, Hangzhou, or Yuhang District."
}
},
"required": ["location"]
}
}
}
]
messages = [{"role": "user", "content": "What's the weather like in Hangzhou?"}]
completion = client.chat.completions.create(
model="qwen3.8-max",
messages=messages,
tools=tools,
)
print(completion.model_dump_json())
- lang: javascript
label: Tool calling
source: |-
import OpenAI from "openai";
const openai = new OpenAI({
// If the environment variable is not set, replace the following line with:apiKey: "sk-xxx",
apiKey:process.env.DASHSCOPE_API_KEY,
baseURL: "https://maas.qwencloudapi.com/compatible-mode/v1"
});
const messages = [{ "role": "user", "content": "What's the weather like in Hangzhou?" }];
const tools = [
// Tool 1:get the current time
{
"type": "function",
"function": {
"name": "get_current_time",
"description": "Useful when you want to know the current time.",
// Getting the current time needs no input parameters, so parameters is empty
"parameters": {}
}
},
// Tool 2:get the weather for a specified city
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Useful when you want to query the weather of a specified city.",
"parameters": {
"type": "object",
"properties": {
// A location must be provided to query the weather, so the parameter is set to location
"location": {
"type": "string",
"description": "A city or district, such as Beijing, Hangzhou, or Yuhang District."
}
},
"required": ["location"]
}
}
}
];
async function main() {
const completion = await openai.chat.completions.create({
model: "qwen3.8-max",
messages:messages,
tools:tools,
});
console.log(JSON.stringify(completion));
}
main();
- lang: curl
label: Tool calling
source: |-
curl -X POST https://maas.qwencloudapi.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type:application/json" \
-d '{
"model": "qwen3.8-max",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What's the weather like in Hangzhou?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_current_time",
"description": "Useful when you want to know the current time.",
"parameters": {}
}
},
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Useful when you want to query the weather of a specified city.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "A city or district, such as Beijing, Hangzhou, or Yuhang District."
}
},
"required": ["location"]
}
}
}
]
}'
- lang: python
label: Asynchronous invocation
source: |-
import os
import asyncio
import platform
from openai import AsyncOpenAI
client = AsyncOpenAI(
# If the environment variable is not set, replace the following line with:api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://maas.qwencloudapi.com/compatible-mode/v1",
)
async def main():completion = await client.chat.completions.create(
model="qwen3.8-max",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"},
],
)
print(completion.model_dump_json())
if platform.system() == "Windows":asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
description: DashScope API key.
schemas:
ChatCompletionRequest:
type: object
required:
- model
- messages
properties:
model:
type: string
description: The name of the model to use. Supported models include Qwen large language models (commercial and open source), Qwen-VL, Qwen-Coder, Qwen-Omni, and Qwen-Math. For specific model names and billing information, see [Text Generation - Qwen](/developer-guides/getting-started/text-generation-models).
messages:
type: array
description: The conversation history for the model, listed in chronological order.
items:
$ref: "#/components/schemas/Message"
stream:
type: boolean
default: false
description: Enables streaming output mode. When `true`, the model generates and sends output incrementally. A data block (chunk) is returned as soon as part of the content is generated. You can read these chunks in real time to assemble the full reply. Set this to `true` to improve the reading experience and reduce the risk of timeouts.
stream_options:
type: object
description: Configuration options for streaming output. This parameter is effective only when `stream` is set to `true`.
properties:
include_usage:
type: boolean
default: false
description: Specifies whether to include token consumption information in the last data block of the response.
modalities:
type: array
items:
type: string
default:
- text
description: 'Specifies the modalities of the output data. This parameter applies only to Qwen-Omni models. Valid values: `["text","audio"]` (applies to models that support audio output) or `["text"]`. `qwen3.8-omni-flash` produces text only.'
audio:
type: object
description: The voice and format of the output audio. This parameter applies to Qwen-Omni models that support audio output and requires the `modalities` parameter to `["text","audio"]`.
properties:
voice:
type: string
description: The voice used for the output audio. For more information, see [Voice list](/developer-guides/speech/omni-voice-list).
format:
type: string
description: The format of the output audio. Only `wav` is supported.
required:
- voice
- format
temperature:
type: number
description: The sampling temperature controls the diversity of the generated text. Higher values increase diversity, while lower values make the output more deterministic. The value must be greater than or equal to 0 and less than 2. Both `temperature` and `top_p` control the diversity of the generated text. Set only one of them. For Qwen3.8-Omni-Flash, the default is `0.6` in thinking mode and `0.7` in non-thinking mode. Do not modify the default temperature value for QVQ models.
top_p:
type: number
description: "The probability threshold for nucleus sampling. A higher `top_p` value produces more diverse text. A lower `top_p` value produces more deterministic text. Value range: (0, 1.0]. Both `temperature` and `top_p` control the diversity of the generated text. Set only one of them. For Qwen3.8-Omni-Flash, the default is `0.95` in thinking mode and `0.8` in non-thinking mode. Do not modify the default `top_p` value for QVQ models."
top_k:
type: integer
description: |-
Specifies the number of candidate tokens to use for sampling during generation. A larger value produces more random output, whereas a smaller value produces more deterministic output. If set to `null` or a value greater than 100, the `top_k` strategy is disabled and only `top_p` takes effect. The value must be an integer greater than or equal to 0.
**Default `top_k` values:**
- QVQ series, qwen-vl-plus-2025-07-10, and qwen-vl-plus-2025-08-15: 10
- QwQ series: 40
- Other series, models before qwen-vl-max-2025-08-13: 1
- Qwen3-Omni-Flash series: 50
- All other models: 20
You must not change the default `top_k` value for QVQ models.
**This is not a standard OpenAI parameter.** When using the Python SDK, include it in `extra_body`: `extra_body={"top_k":xxx}`.
presence_penalty:
type: number
description: |-
Controls how strongly the model avoids repeating content. Valid values: -2.0 to 2.0. Positive values reduce repetition. Negative values increase it. For creative writing or brainstorming, increase this value. For technical documents or formal text, decrease this value.
**Default `presence_penalty` values:**
- the following models in non-thinking mode (`qwen3.8-max`, `qwen3.8-max-0902`, `qwen3.8-flash`, `qwen3.8-2.4t-a95b`, `qwen3.8-27b`), Qwen3.7 (non-thinking mode), Qwen3.6 (non-thinking mode), Qwen3.5-Omni, Qwen3.5 (non-thinking mode), Qwen3 (non-thinking mode), Qwen3-Instruct series, qwen3-0.6b/1.7b/4b (thinking mode), QVQ series, qwen-max, qwen-max-latest, qwen2.5-vl series, Qwen3-VL (non-thinking): 1.5
- qwen-vl-plus-latest, qwen-vl-plus-2025-08-15: 1.2
- qwen-vl-plus-2025-01-25: 1.0
- qwen3.6-plus/qwen3.6-plus-2026-04-02, qwen3.5-plus/qwen3.5-plus-latest/2025-04-28 (thinking mode): 0.5
- Qwen3.8-Omni-Flash: 0.0 in thinking mode and 1.5 in non-thinking mode
- All other models: 0.0
**How it works:** When the parameter value is positive, the model penalizes tokens that already appear in the generated text. The penalty does not depend on how many times a token appears. This reduces the likelihood of those tokens reappearing, which decreases repetition and increases lexical diversity.
When using the qwen-vl-plus-2025-01-25 model for text extraction, set `presence_penalty` to 1.5.
Do not modify the default `presence_penalty` value for QVQ models.
response_format:
type: object
description: |-
The format of the response content. Defaults to `{"type": "text"}`.
Valid values:
- `{"type": "text"}`:Returns a plain text response.
- `{"type": "json_object"}`:Returns a JSON string that conforms to standard JSON syntax.
- `{"type": "json_schema", "json_schema": {...}}`:Returns a JSON string that conforms to a custom schema.
If you specify `{"type": "json_object"}`, explicitly instruct the model to output JSON in the prompt, such as by adding "Please output in JSON format." Otherwise, an error occurs.
For supported models, see Structured output.
properties:
type:
type: string
enum:
- text
- json_object
- json_schema
description: The format type. `text` returns plain text. `json_object` returns a JSON string that conforms to standard JSON syntax. `json_schema` returns a JSON string that conforms to a custom schema.
json_schema:
type: object
description: Defines the configuration for structured output. Required when `type` is `json_schema`.
properties:
name:
type: string
description: A unique name for the schema. Can contain only letters, numbers, underscores, and hyphens. Maximum 64 characters.
description:
type: string
description: A description of the schema's purpose. This helps the model understand the semantic context of the output.
schema:
type: object
description: An object that conforms to the JSON Schema standard defining the output data structure.
strict:
type: boolean
default: false
description: Specifies whether the model must strictly follow all schema constraints. `true` (recommended) ensures full compliance. `false` may result in output that does not conform to the specification.
required:
- name
required:
- type
max_tokens:
type: integer
description: |-
**Deprecated.** Use `max_completion_tokens` for new integrations.
The meaning of this parameter varies by model:
- `deepseek-v4.1-flash`, `deepseek-v4-pro`, `deepseek-v4-pro-0813`, `deepseek-v4-flash-0731`: The maximum number of tokens for the sum of the model's answer and chain-of-thought content. If the model's output exceeds this value, generation stops early, and the returned `finish_reason` is `length`.
- `glm-5.3`: `max_tokens` is the maximum number of tokens for the sum of the model's answer and chain-of-thought content. If the model's output exceeds this value, generation stops early and the returned `finish_reason` is `length`. glm-5.3 ignores the `thinking_budget` parameter.
- `glm-5.2`: When `thinking_budget` is not passed, `max_tokens` is the maximum number of tokens for the sum of the model's answer and chain-of-thought content, and if the model's output exceeds this value, generation stops early with the returned `finish_reason` being `length`. When `thinking_budget` is passed, `max_tokens` is the maximum number of tokens for the model's answer only, and the chain-of-thought token count is controlled separately by `thinking_budget`.
- Other models: The maximum number of tokens for the model's answer. If the generated content exceeds this value, generation stops early, and the returned `finish_reason` is `length`.
The default and maximum values are both the model's maximum output length.
deprecated: true
max_completion_tokens:
type: integer
description: |-
The maximum number of tokens in this response, including chain-of-thought tokens. Generation stops when this limit is reached, and `finish_reason` is set to `length`. The default and maximum values correspond to the model's maximum output length.
**Difference from `max_tokens`:** `max_completion_tokens` limits the total length of both the chain-of-thought and the final response, while `max_tokens` does not limit the chain-of-thought length. For reasoning models, `max_completion_tokens` is recommended.
**Supported models:**
- Qwen-Max: Qwen3.7-Max and later
- Qwen-Plus: Qwen3.5-Plus and later
- Qwen-Flash: Qwen3.5-Flash and later
- DeepSeek: deepseek-v4-pro, and later
The actual number of output tokens may differ from the configured value by up to 10 tokens.
vl_high_resolution_images:
type: boolean
default: false
description: |-
Increases the maximum pixel limit for input images to the pixel value corresponding to 16384 tokens. When `true`, a fixed-resolution strategy is used and the `max_pixels` setting is ignored. If an image exceeds the pixel limit, its total pixel count is downscaled to meet the limit.
**Pixel limits when `vl_high_resolution_images` is `true`:**
- qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b, qwen3.8-omni-flash, Qwen3.7 series, Qwen3.6 series, Qwen3.5 series, Qwen3-VL series, qwen-vl-max-latest, qwen-vl-max-0813, qwen-vl-plus-latest, qwen-vl-plus-0815: 16,777,216 (each token corresponds to 32×32 pixels, i.e., 16,384×32×32)
- QVQ series and other Qwen2.5-VL series models: 12,845,056 (each token corresponds to 28×28 pixels, i.e., 16,384×28×28)
If `vl_high_resolution_images` is `false`, the actual pixel limit is determined by `max_pixels`.
**This is not a standard OpenAI parameter.** When using the Python SDK, include it in `extra_body`: `extra_body={"vl_high_resolution_images":xxx}`.
n:
type: integer
default: 1
description: The number of responses to generate. Must be an integer in the range of 1-4. This is useful for scenarios that require multiple candidate responses, such as creative writing or ad copy. `n=0` is equivalent to `n=1`. Supported only by Qwen3 (non-thinking mode) models. If you pass the `tools` parameter, set `n` to 1. Increasing `n` increases output token consumption but does not affect input token consumption.
enable_thinking:
type: boolean
description: |-
Enables the thinking mode for hybrid thinking models. This mode is available for the Qwen3.7, Qwen3.6, Qwen3.5, Qwen3, Qwen3-Omni-Flash, and Qwen3-VL models, as well as the DeepSeek-V4.1-Flash, DeepSeek-V4-Pro/V4-Flash series, DeepSeek-V3.2-exp/V3.1 series, Kimi-K2.7-code (thinking model only), Kimi-K2.6/K2.5 series, and GLM series. qwen3.8-max and qwen3.8-max-0902 enable thinking mode by default. When enabled, the thinking content is returned in the `reasoning_content` field. The DeepSeek-V4 series enables thinking by default. You can adjust the inference intensity with the `reasoning_effort` parameter.
Default values differ by model. For supported models and their default `enable_thinking` values, see the Model List.
**This is not a standard OpenAI parameter.** When using the Python SDK, place it in `extra_body`: `extra_body={"enable_thinking":xxx}`.
If you call over HTTP directly (for example, with curl) instead of using the OpenAI SDK, do not use `extra_body`. Simply place `enable_thinking` at the top level of the request body (`body`), alongside parameters such as `model` and `messages`, for example `"enable_thinking":true`.
thinking_budget:
type: integer
description: |-
The maximum number of tokens for the thinking process. Applies to `qwen3.8-max`, `qwen3.8-max-0902`, `qwen3.8-flash`, `qwen3.8-2.4t-a95b`, `qwen3.8-27b`, as well as Qwen3.7, Qwen3.6, Qwen3.5, Qwen3-VL, Qwen3, GLM, and Kimi models, except kimi-k3, which does not support this parameter. For these models, the default value is the model's maximum chain-of-thought length. For more information, see the Model List.
**This is not a standard OpenAI parameter.** When using the Python SDK, place it in `extra_body`: `extra_body={"thinking_budget":xxx}`.
preserve_thinking:
type: boolean
default: false
description: |-
Specifies whether to append the `reasoning_content` from assistant messages in the conversation history to the model input. This is suitable for scenarios where the model needs to refer to the historical thinking process.
To reference reasoning from a previous turn, include it in the historical assistant message's `reasoning_content` field in `messages`. See [Pass the thinking process](/en/model-studio/deep-thinking#jln7docdq5et5).
Currently supported by qwen3.8-max (enabled by default), qwen3.8-max-0902 (enabled by default), qwen3.8-flash, qwen3.8-omni-flash (enabled by default), qwen3.7-max, qwen3.7-max-2026-05-20 and subsequent snapshots, qwen3.7-plus, qwen3.7-plus-2026-05-26, qwen3.6-plus, qwen3.6-plus-2026-04-02, qwen3.7-flash, qwen3.7-flash-2026-07-15, qwen3.6-flash, qwen3.6-flash-2026-04-16, kimi-k2.6 (deployed on QwenCloud), kimi-k2.7-code (deployed on QwenCloud, enabled by default), kimi/kimi-k2.7-code-highspeed (supplied by Moonshot AI, enabled by default), and kimi/kimi-k2.7-code (supplied by Moonshot AI, enabled by default).
- For the supported `qwen3.8-max`, `qwen3.8-max-0902`, `qwen3.8-flash`, Qwen3.7, Qwen3.6, and Kimi models listed above, enabling this parameter when historical messages lack `reasoning_content` does not cause an error.
- When enabled, the `reasoning_content` from the historical conversation is included in the input token count and is billed.
**Important (qwen3.8-max):** When using qwen3.8-max, preserve_thinking defaults to true. You must send back all historical reasoning_content in the reasoning_content field. **Do NOT concatenate reasoning_content into the content field.** Doing so may degrade model performance.
**This is not a standard OpenAI parameter.** When using the Python SDK, place it in `extra_body`: `extra_body={"preserve_thinking": True}`.
reasoning_effort:
type: string
description: |-
Controls model reasoning effort.
**`qwen3.8-max`, `qwen3.8-max-0902`, `qwen3.8-flash`, `qwen3.8-2.4t-a95b`, `qwen3.8-27b`:** Options: `low`, `medium`, `xhigh`. Default: `xhigh`. Cannot be set together with thinking_budget — setting both will cause an error. The two parameters support automatic conversion:when thinking_budget is not set, reasoning_effort maps to thinking_budget (`low`→4096, `medium`→16384, `xhigh`→262144); when reasoning_effort is not set, thinking_budget maps back to reasoning_effort (0–4096→`low`, 4097–16384→`medium`, 16385–262144→`xhigh`); when neither is set, defaults are thinking_budget=131072, reasoning_effort=`xhigh`. OpenAI standard value mapping: `max` is mapped to xhigh, `high` is mapped to xhigh, `minimal` is mapped to low, and `none` is mapped to enable_thinking=False. Setting values other than the above valid values and mapped values will cause an error.
**DeepSeek-V4 and GLM series:** Options: `high` (intensive reasoning), `max` (maximum reasoning). low and medium map to high, xhigh maps to max. Applies to glm-5.2, glm-5.1, glm-5, deepseek-v4-pro.
**glm-5.3, ZHIPU/GLM-5.3, kimi-k3 (supplied by Alibaba Cloud):** Default value: `max`. Valid values: `max` (default, deep reasoning), `high` (enhanced reasoning), `low` (light reasoning). The glm-5.3 series models always perform thinking. `enable_thinking` supports only `true`, and passing `false` causes the API request to fail. kimi-k3 supports passing `false` to disable thinking.
**deepseek-v4-flash-0731 and deepseek-v4-pro-0813:** Default value: `high`. Valid values: `max` (maximum-intensity inference), `high` (default, standard inference), `low` (low-intensity inference). For compatibility, `medium` is mapped to high, and `xhigh` is mapped to high.
**deepseek-v4.1-flash:** Default value: `high`. Valid values: `max` (maximum-intensity inference), `high` (default, high-intensity inference), `low` (low-intensity inference). `minimal` is mapped to `low`, `medium` and `xhigh` are mapped to `high`, and `ultra` is mapped to `max`.
**kimi/kimi-k3 (supplied by Moonshot AI):** Default value: `max`; only `max` is supported.
**Qwen3.8-Omni-Flash:** `qwen3.8-omni-flash` has thinking enabled by default, with `reasoning_effort` defaulting to `xhigh`. In Chat Completions, `reasoning_effort` accepts `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`; do not set it together with `thinking_budget`. Choose `low`, `medium`, or `xhigh` for the thinking effort. For compatibility, `minimal` maps to `low`, `high` and `max` map to `xhigh`, and `none` disables thinking.
`reasoning_effort` is a standard OpenAI parameter. With the Python SDK, pass `reasoning_effort="high"` directly instead of placing it in `extra_body`.
clear_thinking:
type: boolean
default: false
description: |-
Controls whether the `reasoning_content` (thinking process) from previous turns in a multi-turn conversation is used as context input for the model. Supported only by the GLM series models glm-5.3, glm-5.2, glm-5.1, glm-5, and glm-4.7. The default value is `true` for glm-5.3 and `false` for the other models.
- `true`:Ignores the `reasoning_content` from previous turns and uses only visible text, tool calls, results, and other non-inference content as context input. This can reduce the context length and cost.
- `false` (default): Retains the `reasoning_content` from previous turns and provides it to the model along with the context. If you want to enable Preserved Thinking, you must pass the historical `reasoning_content` completely, unmodified, and in the original order within messages.
**This is not a standard OpenAI parameter.** When using the Python SDK, place it in `extra_body`: `extra_body={"clear_thinking": True}`.
tool_stream:
type: boolean
default: false
description: |-
Only takes effect when `stream=true`. Controls streaming behavior for complex tool arguments. Ordinary tool arguments (all parameter types are string) are streamed as long as `stream=true` is enabled; `tool_stream` has no effect on them. Complex tools are those whose definitions include parameters of type array or object.
**Supported Qwen models:**
- qwen-max series:text modality of the qwen3.7-max series
- qwen-plus series:text modality of the qwen3.7-plus and qwen3.6-plus series, and all modalities of the qwen3.5-plus series
- qwen-flash series:all modalities of the qwen3.8-flash, qwen3.7-flash, qwen3.6-flash and qwen3.5-flash series
**Qwen usage:**
- `tool_stream=false`:Complex tool arguments are returned all at once (default). More accurate for complex formats.
- `tool_stream=true`:Complex tool arguments are streamed. Avoids timeout risk for complex formats.
**Supported GLM models:** glm-5.1.
**GLM usage:**
- `tool_stream=false`:Tool arguments are returned all at once (default). More accurate for complex formats.
- `tool_stream=true`:Tool arguments are streamed. Avoids timeout risk for complex formats.
**This is not a standard OpenAI parameter.** When using the Python SDK, include it in `extra_body`: `extra_body={"tool_stream":true}`.
enable_code_interpreter:
type: boolean
default: false
description: |-
Specifies whether to enable the code interpreter feature.
**This is not a standard OpenAI parameter.** When using the Python SDK, include it in `extra_body`: `extra_body={"enable_code_interpreter":xxx}`.
seed:
type: integer
description: "The random number seed. Ensures reproducible results. If you use the same seed value and other parameters remain unchanged, the model returns the same result whenever possible. Valid values: [0, 2^31-1]."
logprobs:
type: boolean
default: false
description: |-
Specifies whether to return the log probabilities of the output tokens. Content generated during the thinking phase (`reasoning_content`) does not include log probabilities.
**Supported models:**
- Qwen-plus series snapshots (excluding the stable model)
- Qwen3-vl-plus models (including the stable model)
- Qwen3 open source models
top_logprobs:
type: integer
default: 0
description: "The number of most likely candidate tokens to return at each generation step. Valid values: 0 to 5. This parameter applies only if `logprobs` is set to `true`."
stop:
oneOf:
- type: string
- type: array
items:
type: string
description: Stop words. If a string or token specified in `stop` appears in the generated text, generation stops immediately. If `stop` is an array, do not use a `token_id` and a string as elements simultaneously.
tools:
type: array
description: An array of one or more tool objects that the model can call in function calling. When `tools` is set and the model determines that a tool needs to be called, the response returns tool information in the `tool_calls` field. For usage examples, see the [Function calling guide](/developer-guides/text-generation/function-calling).
items:
type: object
required:
- type
- function
properties:
type:
type: string
enum:
- function
description: Tool type. Currently supports only `function`.
function:
type: object
required:
- name
- description
properties:
name:
type: string
description: The tool name. Must contain only letters, digits, underscores, and hyphens. Up to 64 tokens.
description:
type: string
description: A description of the tool. Helps the model determine when and how to call the tool.
parameters:
type: object
default: {}
description: The tool's parameters described using a valid JSON Schema. If empty, the tool has no input parameters.
tool_choice:
oneOf:
- type: string
enum:
- auto
- none
- required
- type: object
properties:
type:
type: string
enum:
- function
function:
type: object
properties:
name:
type: string
description: The name of the function to call.
required:
- name
required:
- type
- function
default: auto
description: 'The tool selection policy. `auto` lets the model select. `none` disables tool calling. `required` forces at least one tool to be called; the model will always return tool call information (the Qwen series models do not support `required`:in non-thinking mode it cannot guarantee that a tool is always called, and in thinking mode `required` is not supported). An object with `{"type": "function", "function": {"name": "..."}}` forces a specific tool. Models in thinking mode do not support forcing a specific tool.'
parallel_tool_calls:
type: boolean
default: false
description: Specifies whether to enable parallel tool calling.
enable_search:
type: boolean
default: false
description: |-
Enables web search. Enabling web search may increase token consumption.
**This is not a standard OpenAI parameter.** When using the Python SDK, include it in `extra_body`: `extra_body={"enable_search": True}`.
search_options:
type: object
description: |-
The web search strategy. Takes effect only when `enable_search` is `true`.
**Properties:**
- `forced_search` (boolean, default: `false`): Forces web search. `true` forcefully enables web search. `false` lets the model decide.
- `search_strategy` (string, default: `turbo`): The search scale strategy. `turbo` balances speed and effectiveness. `max` uses a more comprehensive strategy with multiple search engines. `agent` calls search and LLM multiple times for multi-round retrieval (applicable only to qwen3.7-max, qwen3.7-max-2026-06-08, qwen3.7-max-2026-05-20, qwen3.7-max-preview, qwen3.7-max-2026-05-17, qwen3.5-plus, qwen3.5-plus-2026-02-15, qwen3.5-flash, qwen3.5-flash-2026-02-23,qwen3.8-omni-flash, qwen3.5-omni-plus, qwen3.5-omni-plus-2026-03-15, qwen3.5-omni-flash, and qwen3.5-omni-flash-2026-03-15). `agent_max` adds web extraction support to the `agent` strategy (applicable only to the thinking mode of qwen3.7-max, qwen3.7-max-2026-06-08, qwen3.7-max-2026-05-20, qwen3.7-max-preview, qwen3.7-max-2026-05-17). When `agent` or `agent_max` is enabled, only return search sources (`enable_source:true`) is supported. All other web search features are unavailable.
- `enable_search_extension` (boolean, default: `false`): Enables domain-specific search.
**This is not a standard OpenAI parameter.** When using the Python SDK, include it in `extra_body`: `extra_body={"search_options":xxx}`.
properties:
forced_search:
type: boolean
default: false
description: Forces web search. `true` forcefully enables web search. `false` lets the model decide.
search_strategy:
type: string
enum:
- turbo
- max
- agent
- agent_max
default: turbo
description: The search scale strategy. `turbo` (default) balances speed and effectiveness. `max` uses a more comprehensive strategy with multiple search engines; response time may be longer. `agent` calls web search and LLM multiple times for multi-round retrieval. Applicable only to qwen3.7-max, qwen3.7-max-2026-06-08, qwen3.7-max-2026-05-20, qwen3.7-max-preview, qwen3.7-max-2026-05-17, qwen3.5-plus, qwen3.5-plus-2026-02-15, qwen3.5-flash, qwen3.5-flash-2026-02-23,qwen3.8-omni-flash, qwen3.5-omni-plus, qwen3.5-omni-plus-2026-03-15, qwen3.5-omni-flash, and qwen3.5-omni-flash-2026-03-15. `agent_max` adds web extraction support to the `agent` strategy. Applicable only to the thinking mode of qwen3.7-max, qwen3.7-max-2026-06-08, qwen3.7-max-2026-05-20, qwen3.7-max-preview, qwen3.7-max-2026-05-17, and qwen3-max-2026-01-23. When `agent` or `agent_max` is enabled, only return search sources (`enable_source:true`) is supported.
enable_search_extension:
type: boolean
default: false
description: Enables domain-specific search.
Message:
oneOf:
- title: System message
type: object
description: A system message that defines the role, tone, task objectives, or constraints for the model. Place it at the beginning of the messages array. Do not set a System Message for the QwQ model. A System Message has no effect on the QVQ model.
required:
- role
- content
properties:
role:
type: string
enum:
- system
description: The role for a system message. Fixed as `system`.
content:
type: string
description: A system instruction that defines the model's role, behavior, response style, and task constraints.
- title: User message
type: object
description: A user message that passes questions, instructions, or context to the model.
required:
- role
- content
properties:
role:
type: string
enum:
- user
description: The role for a user message. Fixed as `user`.
content:
description: The message content. A string for text-only input; an array for multimodal input or explicit caching.
oneOf:
- type: array
description: An array of content parts. Use for multimodal input (images, audio, video) or when explicit caching is enabled.
items:
type: object
properties:
type:
type: string
enum:
- text
- image_url
- input_audio
- video
- video_url
description: The content type. `text` for text, `image_url` for images, `input_audio` for audio, `video` for image list video, `video_url` for video files.
text:
type: string
description: The input text. Required when `type` is `text`.
image_url:
type: object
description: The input image information. Required when `type` is `image_url`. For usage examples, see the [Vision guide](/developer-guides/multimodal/vision).
properties:
url:
type: string
description: The URL or Base64 Data URL of the image.
required:
- url
input_audio:
type: object
description: The input audio information. Required when `type` is `input_audio`. For usage examples, see the [Audio understanding guide](/developer-guides/text-generation/audio-understanding).
properties:
data:
type: string
description: The URL or Base64 Data URL of the audio.
format:
type: string
description: The format of the input audio, such as `mp3` or `wav`.
required:
- data
- format
video:
type: array
items:
type: string
description: The video as an image list. Required when `type` is `video`. For usage examples, see the [Vision guide](/developer-guides/multimodal/vision).
video_url:
type: object
description: The input video file information. Required when `type` is `video_url`. For usage examples, see the [Vision guide](/developer-guides/multimodal/vision).
properties:
url:
type: string
description: The public network URL or Base64 Data URL of the video file.
required:
- url
fps:
type: number
description: |-
The number of frames to extract per second. Value range: [0.1, 10]. Default: 2.0.
The fps parameter has two functions:
- When you input a video file, it controls the frame extraction frequency. One frame is extracted every `1/fps` seconds.
- It informs the model of the time interval between adjacent frames to help it better understand the video's progression over time. This applies to both video file and image list inputs. This feature is suitable for scenarios such as event time localization or segmented content summarization.
Supported by Qwen3.7, Qwen3.6, Qwen3.5, `Qwen3-VL`, `Qwen2.5-VL`, Qwen3.8-Omni-Flash, Qwen3.5-Omni, and QVQ models.
min_pixels:
type: integer
description: |-
Sets the minimum pixel threshold for an input image or video frame. If an input image or video frame has a pixel count less than min_pixels, it is scaled up until the total pixel count exceeds min_pixels. See the supported models and values below.
Value range:
- For image input:
- qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b, Qwen3.7, Qwen3.6, Qwen3.5, and Qwen3-VL: Default and minimum is 65536.
- qwen3.8-omni-flash and Qwen3.5-Omni: Default and minimum is 24576.
- qwen-vl-max-latest, qwen-vl-max-0813, qwen-vl-plus-latest, qwen-vl-plus-0815:Default and minimum is 4096.
- Other models, open source Qwen2.5-VL series, and QVQ series models: Default and minimum is 3136.
- For video file or image list input:
- qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b, qwen3.8-omni-flash, Qwen3.7, Qwen3.6, Qwen3.5, Qwen3.5-Omni, Qwen3-VL (including commercial and open source versions), qwen-vl-max-latest, qwen-vl-max-0813, qwen-vl-plus-latest, qwen-vl-plus-0815:Default is 65536. Minimum is 4096.
- Other models, open source Qwen2.5-VL series, and QVQ series models: Default is 50176. Minimum is 3136.
max_pixels:
type: integer
description: |-
Sets the maximum pixel threshold for an input image or video frame. If an input image or video has a pixel count within the [min_pixels, max_pixels] range, the model processes the original image. If the pixel count exceeds max_pixels, the image is scaled down until its total pixel count is less than max_pixels. See the supported models and values below.
Value range:
- For image input (max_pixels is related to whether the vl_high_resolution_images parameter is enabled):
- If vl_high_resolution_images is False:
- qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b, Qwen3.7, Qwen3.6, Qwen3.5, and Qwen3-VL: Default is 2621440. Maximum is 16777216.
- qwen3.8-omni-flash and Qwen3.5-Omni: Default is 1310720. Maximum is 16777216.
- qwen-vl-max-latest, qwen-vl-max-0813, qwen-vl-plus-latest, qwen-vl-plus-0815:Default is 1310720. Maximum is 16777216.
- Other models, open source Qwen2.5-VL series, and QVQ series models: Default is 1003520. Maximum is 12845056.
- If vl_high_resolution_images is True:
- qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b, qwen3.8-omni-flash, Qwen3.7, Qwen3.6, Qwen3.5-Omni, Qwen3.5, Qwen3-VL, qwen-vl-max-0813, qwen-vl-plus-0815:max_pixels is invalid. The maximum pixel count for an input image is fixed at 16777216.
- Other models, open source Qwen2.5-VL series, and QVQ series models:max_pixels is invalid. The maximum pixel count for an input image is fixed at 12845056.
- For video file or image list input:
- qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b, qwen3.8-omni-flash, Qwen3.7 series, Qwen3.6 series, Qwen3.5 series, Qwen3.5-Omni, Qwen3-VL closed-source series: Default is 655360. Maximum is 2048000.
- Other Qwen3-VL open source models, qwen-vl-max-latest, qwen-vl-max-0813, qwen-vl-plus-latest, qwen-vl-plus-0815:Default is 655360. Maximum is 786432.
- Other models, open source Qwen2.5-VL series, and QVQ series models: Default is 501760. Maximum is 602112.
total_pixels:
type: integer
description: |-
Limits the total number of pixels for all frames extracted from a video (pixels per frame × total number of frames). If the video's total pixel count exceeds this limit, the system scales down the video frames while ensuring that the pixel count of any single frame remains within the [min_pixels, max_pixels] range. See the supported models and values below. For long videos with many extracted frames, lower this value to reduce token consumption and processing time (though this may cause a loss of image detail).
Value range:
- qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b, Qwen3.7, Qwen3.6, Qwen3.5 series: Default and maximum is 819200000. This corresponds to approximately 800000 image tokens (1 image token per 32×32 pixels).
- qwen3.8-omni-flash and Qwen3.5-Omni: Default and minimum is 184549376. This corresponds to approximately 180224 image tokens (1 image token per 32×32 pixels).
- Qwen3-VL closed-source series: Default and maximum is 134217728. This corresponds to approximately 131072 image tokens (1 image token per 32×32 pixels).
- Other Qwen3-VL open source models, qwen-vl-max-latest, qwen-vl-max-0813, qwen-vl-plus-latest, qwen-vl-plus-0815:Default and minimum is 67108864. This corresponds to approximately 65536 image tokens (1 image token per 32×32 pixels).
- Other models, open source Qwen2.5-VL series, and QVQ series models: Default and minimum is 51380224. This corresponds to approximately 65536 image tokens (1 image token per 28×28 pixels).
cache_control:
type: object
description: Enables explicit caching.
properties:
type:
type: string
enum:
- ephemeral
description: Only `ephemeral` is supported.
required:
- type
required:
- type
- type: string
description: A plain text string. Use for text-only input.
- title: Assistant message
type: object
description: The model's reply. Typically sent back to the model as context in a multi-turn conversation.
required:
- role
properties:
role:
type: string
enum:
- assistant
description: The role for an assistant message. Fixed as `assistant`.
content:
type: string
description: The text content of the model's reply. If `tool_calls` is included, `content` can be empty. Otherwise, `content` is required.
partial:
type: boolean
default: false
description: Specifies whether to enable partial mode.
tool_calls:
type: array
description: The tool and input parameter information returned after a function call is initiated.
items:
type: object
required:
- id
- type
- function
- index
properties:
id:
type: string
description: The ID of the tool response.
type:
type: string
enum:
- function
description: The tool type. Currently, only `function` is supported.
function:
type: object
required:
- name
- arguments
properties:
name:
type: string
description: The tool name.
arguments:
type: string
description: The input parameter information, formatted as a JSON string.
index:
type: integer
description: The index of the current tool in the `tool_calls` array.
- title: Tool message
type: object
description: The output information of the tool.
required:
- role
- content
- tool_call_id
properties:
role:
type: string
enum:
- tool
description: Fixed as `tool`.
content:
type: string
description: The output content of the tool function. Must be a string. If the tool returns structured data (such as JSON), serialize it into a string.
tool_call_id:
type: string
description: The ID returned after a function call is initiated. Retrieve it from `completion.choices[0].message.tool_calls[$index].id`.
ChatCompletion:
type: object
description: Chat response object (non-streaming output).
properties:
id:
type: string
description: The unique identifier for this request.
choices:
type: array
description: An array of generated content from the model.
items:
type: object
properties:
finish_reason:
type: string
enum:
- stop
- length
- tool_calls
description: The reason the model stopped generating. `stop`:stopped naturally or by stop parameter. `length`:reached maximum output length. `tool_calls`:stopped to call a tool.
index:
type: integer
description: The index of this object in the choices array.
logprobs:
$ref: "#/components/schemas/Logprobs"
message:
$ref: "#/components/schemas/AssistantResponseMessage"
created:
type: integer
description: The Unix timestamp, in seconds, when the request was created.
model:
type: string
description: The model used for this request.
object:
type: string
enum:
- chat.completion
description: Always `chat.completion`.
service_tier:
type: string
nullable: true
description: Currently fixed as `null`.
system_fingerprint:
type: string
nullable: true
description: Currently fixed as `null`.
usage:
$ref: "#/components/schemas/Usage"
ChatCompletionChunk:
type: object
description: Chat response chunk object (streaming output).
properties:
id:
type: string
description: The unique identifier for this request. All chunks in the same response share the same id.
choices:
type: array
description: An array of generated content objects. If `include_usage` is `true`, the `choices` array is empty in the final chunk.
items:
type: object
properties:
delta:
type: object
description: The incremental content object for this chunk.
properties:
content:
type: string
description: The incremental message content.
reasoning_content:
type: string
description: The incremental chain-of-thought content.
function_call:
type: object
nullable: true
description: Defaults to `null`. Use `tool_calls` instead.
audio:
type: object
description: The response generated by Qwen-Omni.
properties:
data:
type: string
description: The incremental Base64-encoded audio data.
expires_at:
type: integer
description: The UNIX timestamp when the request was created.
refusal:
type: object
nullable: true
description: Always `null`.
role:
type: string
description: The role. Appears only in the first chunk.
tool_calls:
type: array
description: Tool call information generated after a function call.
items:
type: object
properties:
index:
type: integer
description: The index of the current tool in the tool_calls array.
id:
type: string
description: The unique ID for this tool response.
function:
type: object
properties:
arguments:
type: string
description: Incremental input parameter information. Concatenate from all chunks.
name:
type: string
description: The tool name. Appears only in the first chunk.
type:
type: string
description: The tool type. Currently, only `function` is supported.
finish_reason:
type: string
nullable: true
enum:
- stop
- length
- tool_calls
- null
description: The reason generation stopped. `null` before generation is complete.
index:
type: integer
description: The index of the current response in the choices array.
logprobs:
$ref: "#/components/schemas/Logprobs"
created:
type: integer
description: The UNIX timestamp when this request was created.
model:
type: string
description: The model used for this request.
object:
type: string
enum:
- chat.completion.chunk
description: Always `chat.completion.chunk`.
service_tier:
type: string
nullable: true
description: Currently fixed as `null`.
system_fingerprint:
type: string
nullable: true
description: Currently fixed as `null`.
usage:
$ref: "#/components/schemas/Usage"
AssistantResponseMessage:
type: object
description: The message generated by the model.
properties:
content:
type: string
description: The content of the model's response.
reasoning_content:
type: string
description: The content of the model's chain-of-thought reasoning.
refusal:
type: string
nullable: true
description: This field is always `null`.
role:
type: string
enum:
- assistant
description: Always `assistant`.
audio:
type: object
nullable: true
description: This field is always `null`.
function_call:
type: object
nullable: true
description: (Deprecated) This field is always `null`. Use `tool_calls` instead.
tool_calls:
type: array
description: Information about tools and their input parameters that the model generates after initiating a function call.
items:
type: object
properties:
id:
type: string
description: The unique identifier for this tool response.
type:
type: string
enum:
- function
description: The type of the tool. Currently, only `function` is supported.
function:
type: object
properties:
name:
type: string
description: The name of the tool.
arguments:
type: string
description: The input parameters, formatted as a JSON string. Model outputs are non-deterministic. Validate the parameters before calling the function.
index:
type: integer
description: The index of this tool in the `tool_calls` array.
Logprobs:
type: object
nullable: true
description: Log probability information for tokens in the model's output.
properties:
content:
type: array
description: An array of tokens and their corresponding log probabilities.
items:
type: object
properties:
token:
type: string
description: The text of the current token.
bytes:
type: array
items:
type: integer
description: A list of raw UTF-8 bytes for the current token.
logprob:
type: number
nullable: true
description: The log probability of the current token. `null` indicates an extremely low probability.
top_logprobs:
type: array
description: The most likely candidate tokens for the current position.
items:
type: object
properties:
token:
type: string
description: The candidate token text.
bytes:
type: array
items:
type: integer
description: Raw UTF-8 bytes for the token.
logprob:
type: number
nullable: true
description: The log probability of this candidate token.
Usage:
type: object
description: Token consumption details for this request.
properties:
completion_tokens:
type: integer
description: The number of tokens in the model's output.
prompt_tokens:
type: integer
description: The number of tokens in the input.
total_tokens:
type: integer
description: The total number of tokens consumed (prompt_tokens + completion_tokens).
completion_tokens_details:
type: object
description: A fine-grained breakdown of output tokens. This field is returned only by some models. Note that `text_tokens` includes `reasoning_tokens` — `reasoning_tokens` is the subset of `text_tokens` corresponding to the thinking process, so `text_tokens` minus `reasoning_tokens` is the number of tokens in the final visible reply. This field is typically returned only when the model outputs a thinking process; it may be `null` or absent when thinking is not enabled.
properties:
audio_tokens:
type: integer
nullable: true
description: The number of audio tokens in the output (Qwen-Omni).
reasoning_tokens:
type: integer
nullable: true
description: The number of tokens in the thinking process. This value is a subset of `text_tokens`.
text_tokens:
type: integer
description: The number of text tokens in the output. This value already includes `reasoning_tokens`.
prompt_tokens_details:
type: object
description: A fine-grained breakdown of input tokens.
properties:
audio_tokens:
type: integer
nullable: true
description: The number of tokens in the input audio.
cached_tokens:
type: integer
description: The number of tokens that hit the cache.
text_tokens:
type: integer
description: The number of text tokens in the input.
image_tokens:
type: integer
description: The number of image tokens in the input.
video_tokens:
type: integer
description: The number of tokens for the input video.
cache_creation:
type: object
description: Information about explicit cache creation.
properties:
ephemeral_5m_input_tokens:
type: integer
description: The number of tokens used to create the explicit cache.
cache_creation_input_tokens:
type: integer
description: The number of tokens used to create the explicit cache.
cache_type:
type: string
description: When using an explicit cache, the value is `ephemeral`. Otherwise, this field does not exist.
ErrorResponse:
type: object
properties:
error:
type: object
properties:
message:
type: string
description: A human-readable error message.
type:
type: string
description: The error type.
param:
type:
- string
- "null"
description: The parameter that caused the error.
code:
type:
- string
- "null"
description: The error code.