Qwen Character API
Complete API reference for Qwen Character roleplay models by Alibaba. Qwen Character models use the Flaq AI chat completions endpoint, but they also support character-specific fields for long-term memory, group-chat simulation, and partial assistant continuation.
Model Variants
This API supports two model variants:
Quick Comparison
How Character Roleplay Works
Use normal system, user, and assistant messages for single-character roleplay. Put stable persona instructions in a system message for the current request. When long-term memory is enabled, put the reusable character profile in profile.
For group-chat simulation, Qwen Character does not automatically infer speaker names from profile. The caller must write speaker names at the beginning of each message content, such as Cheng Yi: or Ling Lu:. To make the model continue as a specific character, append a final assistant message whose content is the target speaker prefix and set partial: true.
partial is a message-level field on the final assistant message. It is not a top-level request parameter.
Qwen Plus Character
Endpoint
http
Request Parameters
Required
Headers
Message Support
Message Fields
Optional
When long-term memory is enabled, you must provide:
x-sessionrequest headerprofilein the request bodyenable_long_term_memory: true
skip_save_types supports these values:
Basic Roleplay Request
javascript
Long-Term Memory Request
javascript
Group Chat Simulation with partial
Group-chat simulation is implemented through message text. The API does not automatically assign or migrate speaker names. Write each speaker name manually at the start of content, then append a final assistant message with the target speaker prefix and partial: true.
javascript
Continue as Character with partial
Use the same partial pattern when the user has not replied but you want the character to continue speaking. Add a final assistant message with the character prefix.
javascript
Qwen Flash Character
Request Parameters
Same protocol as Qwen Plus Character, with these differences:
Example Request
javascript
Response Format
Qwen Character LLM models return OpenAI-compatible completion responses. With stream: true, the response is Server-Sent Events; with stream: false, the response is a single JSON object.
Best Practices
- Put request-level persona instructions in
systemmessages. - Put reusable character background in
profileonly when long-term memory is enabled. - Reuse the same
x-sessionvalue across related conversations when long-term memory is enabled. Sessions unused for 365 days may be cleared. - Continue sending recent conversation messages when useful; long-term memory and short-term context can work together.
- For group-chat simulation, manually write speaker names in
content. The API will not infer names fromprofile. - Use
partial: trueonly on the final assistant message when the model should continue from a prefix. - Use Qwen Flash Character for lightweight roleplay and Qwen Plus Character for richer dialogue quality.