Skip to main content
Partial Mode makes the Kimi large language model continue generating from a given piece of text instead of replying from scratch. Use it when you need to fix the opening of replies (for example, a customer service robot that starts every sentence with “Dear customer, hello.”), to complete truncated long output, or to reinforce character consistency in role play.
The examples on this page use the latest model kimi-k3 by default. K3 configures reasoning effort with the top-level reasoning_effort request field (supports "low" / "high" / "max", default "max"). To use another model such as kimi-k2.6 or kimi-k2.5, just replace the model field — parameter configurations differ across models. See the Model Parameter Reference.

Make the model continue from a given prefix

To use Partial Mode, append a message with role=assistant and partial=True at the end of the messages list, and place the text you want the model to continue from in the content field — the model is forced to start its reply with that content. The following example makes the model open its reply with a fixed greeting:
Key points of using Partial Mode:
  1. Add an extra message at the end of the messages list, with role=assistant and partial=True;
  2. Place the content you want to “feed” to the Kimi large language model in the content field. The model will start generating the response from this content;
  3. Concatenate the content from step 2 with the response generated by the Kimi large language model to form the complete reply.

Complete output truncated by max_tokens

When calling the Kimi API, the estimated number of input and output tokens may be inaccurate, causing the max_tokens value to be set too low and the Kimi large language model to be unable to output the complete response. In this case, the value of finish_reason is length, meaning the number of tokens in the generated response exceeds the max_tokens value set in the request. If you are satisfied with the already output content and want the model to continue from where it left off, use Partial Mode to pass the already output content back as a prefix. The following example shows how to continue the output after it is truncated:
Note that thinking consumes max_tokens first: kimi-k3 has thinking enabled by default, so with a small max_tokens the truncation point may fall inside the thinking phase — content is still empty while finish_reason is already length, and the continuation would restart from scratch because the prefix is empty. When using this flow, set max_tokens large enough to ensure the truncation happens in the content phase.
In thinking mode, pass the reasoning_content returned by the previous turn back together with the prefix (see the comment in the example).

Fix the character identity with the name field

The name field in Partial Mode is a special field that enhances the model’s understanding of its role, compelling it to output content in the voice of the specified character. The name field is part of the output prefix. The following example uses the Kimi large language model for role play, with Dr. Kelsier from the mobile game Arknights: by setting "name": "Kelsier", the Kimi large language model responds as Kelsier, which better maintains character consistency:

Maintain character consistency in long conversations

The following general methods help large language models maintain character consistency during long conversations:
  • Provide clear character descriptions: when setting up a character, give a detailed introduction of their personality, background, and any specific traits or quirks they might have, to help the Kimi large language model better understand and imitate the character;
  • Add more details about the character: their tone of voice, style, personality, and even background, such as backstory and motivations — for example, we provided some quotes from Kelsier above;
  • Guide how the character should act in various situations: if you expect the character to encounter certain types of user input, or want to control the model’s output in some situations during the role-playing interaction, provide clear instructions and guidelines in the system prompt explaining how the character should act in these situations;
  • Periodically reinforce the character’s settings: if the conversation goes on for many rounds, periodically use the system prompt to reinforce the character’s settings, especially when the model starts to deviate.
The following example shows re-inserting the system prompt after many rounds of conversation to reinforce the character’s settings: