For scenarios like code completion and text continuation, you can generate new content starting from an existing text fragment (prefix). Partial Mode ensures the model's output connects seamlessly with your prefix for improved accuracy and control.
How it works
To use Partial Mode, configure the messages array. In the last message of the array, set the role to assistant and provide the prefix in the content field. You must also set the "partial": true parameter in that message. The messages format is as follows:
Supported models
-
Text generation models
- Qwen4-Max series :
qwen4-max - Qwen-Max (non-thinking mode): Qwen3.8-Max series, Qwen3.7-Max series, Qwen3.6-Max series, Qwen3-Max series, Qwen-Max series
- Qwen-Plus (non-thinking mode): Qwen3.7-Plus series, Qwen3.6-Plus series, Qwen3.5-Plus series, Qwen-Plus series
- Qwen-Flash (non-thinking mode): Qwen3.7-Flash series, Qwen3.6-Flash series, Qwen3.5-Flash series, Qwen-Flash series
- Qwen-Coder: Qwen3-Coder series, Qwen2.5-Coder series, Qwen-Coder series
- Qwen-Turbo (non-thinking mode): Qwen-Turbo series
- Qwen3.6 open source series (non-thinking mode)
- Qwen3.5 open source series (non-thinking mode)
- Qwen3 open source series (non-thinking mode)
- Qwen2.5 open source series
- Qwen-Math: Qwen-Math series, Qwen2.5-Math series
- DeepSeek (SiliconFlow deployment): siliconflow/deepseek-v3.1-terminus (non-thinking mode), siliconflow/deepseek-v3-0324
- DeepSeek (Vanchin deployment): vanchin/deepseek-v3.2-think
- Ling (deployed by AntDigital): antdigital/Ling-3.1-flash
- Qwen4-Max series :
-
Multimodal models
- Qwen-VL: Qwen3-VL-Plus series, Qwen3-VL-Flash series, Qwen-VL-Max series, Qwen-VL-Plus series
- Qwen3-VL open source series (non-thinking mode)
- Kimi (deployed on Moonshot AI): kimi/kimi-k3.1-pro, kimi/kimi-k3.1-pro-highspeed, kimi/kimi-k3, kimi/kimi-k2.6, kimi/kimi-k2.5
Getting started
Prerequisites
Before you begin, get an API key and set the API key as an environment variable. If you call the service using the OpenAI SDK or DashScope SDK, you must install the SDK. If you are a member of a sub-workspace, ensure that the super administrator has completed model authorization for the workspace.
The DashScope Java SDK is not supported.
Sample code
Code completion is the core use case for Partial Mode. The following example shows how to complete a Python function.
- OpenAI compatible
- DashScope
- Python
- Node.js
- curl
Response
Use cases
Pass images or videos
Qwen-VL models support Partial Mode with image or video data, which is useful for scenarios such as product descriptions, social posts, news articles, and creative copywriting.
- OpenAI compatible
- DashScope
- Python
- Node.js
- curl
Response
Continue from incomplete output
You can use Partial Mode to continue from incomplete LLM output and ensure semantically complete results. Incomplete output may occur for the following reasons:
-
The value of the
max_tokensparameter is too small, which causes the model to truncate its output. -
A non-streaming response times out. In this case, the model returns the content that it has generated so far.
Timeouts no longer cause errors. Instead, the model returns generated content so far. See How to handle model timeouts.
- OpenAI compatible
- DashScope
- Python
- Node.js
Response
length: The max_tokens limit was reached. stop: The model finished naturally or hit a stop word from the stop parameter.