Authentication
authorization string required
All APIs require authentication via Bearer Token.
Get API Key:
Visit API Key Management Page to get your API Key.
Usage:
Add to request header:
Authorization: Bearer YOUR_API_KEY
Parameters
model string required
Model ID to use for the request.
Value: tongyi-intent-detect-v3
messages array required
Array of message objects representing the conversation history.
role
stringrequiredMessage role.
Options:
user,assistant,system
content
stringrequiredMessage content. System message must include mode instructions and configuration.
max_tokens integer
Maximum tokens to generate in the completion.
Range: 1 - 1024
temperature number
Sampling temperature to use.
Default: 1.0
Range: 0.0 - 2.0
Usage Modes
Intent + Function Call Mode (INTENT_MODE)
Outputs both intent tags and function call information. System message format:
You are Qwen, created by Alibaba Cloud. You are a helpful assistant. You may call one or more tools to assist with the user query. The tools you can use are as follows:
[Tool definitions in JSON format]
Response in INTENT_MODE.
Response Format:
<tags>
[intent tags]
</tags><tool_call>
[function call array]
</tool_call><content>
response text
</content>
Intent Only Mode
Outputs only intent classification. System message format:
You are Qwen, created by Alibaba Cloud. You are a helpful assistant.
You should choose one tag from the tag list:
{intent dictionary in JSON format}
Just reply with the chosen tag.
Tips: Use single uppercase letters (A, B, C…) as intent keys for faster response (always 1 token).
Function Call Only Mode (NORMAL_MODE)
Outputs only function call information. System message format:
You are Qwen, created by Alibaba Cloud. You are a helpful assistant. You may call one or more tools to assist with the user query. The tools you can use are as follows:
[Tool definitions in JSON format]
Response in NORMAL_MODE.
Response Format:
<tool_call>
{function call object}
</tool_call>
Tool Definition Format
Tools should be defined in the system message as a JSON array:
[
{
"name": "function_name",
"description": "Function description",
"parameters": {
"type": "object",
"properties": {
"param_name": {
"type": "string",
"description": "Parameter description"
}
},
"required": ["param_name"]
}
}
]
Multi-turn Conversations
The model supports multi-turn conversations. If insufficient information is provided, it will ask follow-up questions before making function calls.
Example:
User: “I want to check the weather”
Model: “Which city would you like to check?”
User: “Hangzhou”
Model: Returns function call with location parameter
Response Format
Standard chat completion response with model-specific content formatting based on the selected mode.
id string
Unique identifier for the completion.
choices array
Array of completion choices.
message
objectThe generated message.
content
stringResponse content in the format specified by the mode (intent tag, XML-formatted tool calls, or plain text).
usage object
Token usage statistics.
prompt_tokens
integerNumber of tokens in the prompt.
completion_tokens
integerNumber of tokens in the completion.
total_tokens
integerTotal number of tokens used.