Identify user intent and select tools in milliseconds with tongyi-intent-detect-v3
tongyi-intent-detect-v3 identifies a user's intent and selects the tool that can handle the request. It returns results in milliseconds, which makes it suitable for routing requests in voice assistants, customer service bots, and agent pipelines.
Key capabilities:
- Millisecond intent parsing: classifies intent in a few hundred milliseconds.
- Tool selection: matches a user request to the appropriate tool and returns the tool call.
- Multi-turn conversations: asks follow-up questions when the request lacks the information a tool needs.
https://cn-beijing.maas.qwencloudapi.com. See Regions and endpoints.
Supported models
| Model | Context | Max input | Max output | Input price | Output price |
|---|---|---|---|---|---|
tongyi-intent-detect-v3 | 8,192 | 8,192 | 1,024 | $0.058 per 1M tokens | $0.144 per 1M tokens |
How it works
The model supports three modes, selected by a keyword in the system message:
| Mode | System message keyword | Response |
|---|---|---|
| Intent and function call | Response in INTENT_MODE. | Intent tags, tool call, and reply content |
| Intent only | A tag list plus Just reply with the chosen tag. | A single tag |
| Function call only | Response in NORMAL_MODE. | A tool call |
Prerequisites
Get an API key and set it as an environment variable. To use an SDK, install it.
Output intent and function call information
To return intent tags, the tool call, and reply content in one response, set the system message as follows:
Sample request
- OpenAI compatible
- DashScope
Sample response
tags: what the model detected in the request.tool_call: a JSON array with the tools to call and their arguments. It is empty when no tool is needed.content: the reply to the user, empty when the model only calls a tool.
Parse the response
Output only intent information
To classify the request into one of your own intent categories, list them in the system message:
Sample request
- OpenAI compatible
- DashScope
Sample response
Improve response time
Single-token responses are faster than multi-token ones. For the lowest latency, map each intent to a single uppercase letter:
Output only function call information
To return only the tool call, set the system message as follows:
Sample request
- OpenAI compatible
- DashScope
Sample response
Parse the response
Multi-turn conversations
When the request is missing a parameter a tool needs, the model asks a follow-up question instead of calling the tool. After the user supplies the missing information, it returns the tool call. Append each response to the message history before sending the next question.
- Intent and function call
- Function call only
- OpenAI compatible
- DashScope
Sample response
content and an empty tool_call. The second round completes the tool call.FAQ
How many tools can I pass in?
Pass no more than 10 tools. Exceeding this limit can reduce tool call accuracy.
Why is the tool call returned as text instead of a tool_calls field?
tongyi-intent-detect-v3 returns intent and tool information inside the message content, wrapped in <tags>, <tool_call>, and <content> tags. Parse the tags with a regular expression as shown above rather than reading choices[0].message.tool_calls.