Creates a completion for the chat message. Supports standard chat, Partial Mode, and Tool Use (Function Calling).
Content Field Description
content field supports the following forms:"Hello"[{"type": "text", "text": "..."}, {"type": "image_url", "image_url": {"url": "..."}}][{"type": "video_url", "video_url": {"url": "data:video/mp4;base64,..."}}]url field of image_url and video_url supports base64 format and ms://<file_id> format. See Use the Kimi Vision Model.Vision (Image Understanding)
message.content field changes from str to List[Object[str, any]]. Each element in the List has the following fields:| Parameter | Required | Description | Type |
|---|---|---|---|
type | required | Only supports text type (text) or image type (image_url) | string |
image_url | required | Object for transmitting images | Dict[str, any] |
image_url parameter fields:| Parameter | Required | Description | Type |
|---|---|---|---|
url | required | Image content specified via base64 encoding or file id | string |
The Authorization header expects a Bearer token. Use an MOONSHOT_API_KEY as the token. This is a server-side secret key. Generate one on the API keys page in your dashboard.
A list of messages in the conversation so far. Each element has the format {"role": "user", "content": "Hello"}. role supports system, user, or assistant. content must not be empty. The content field can be a string or a List[Dict] (for multimodal input).
Model ID
kimi-k2.5 Deprecated, please refer to max_completion_tokens
The maximum number of tokens to generate for the chat completion. If not specified, defaults to a reasonable integer such as 1024. If the result reaches the maximum number of tokens without ending, the finish reason will be "length"; otherwise, it will be "stop". This refers to the length of tokens you expect us to return, not the total length of input plus output. If input plus max_completion_tokens exceeds the model context window, the API returns invalid_request_error.
Setting this to {"type": "json_object"} enables JSON mode, ensuring that the generated information is valid JSON. When you set response_format to {"type": "json_object"}, you must explicitly guide the model to output JSON-formatted content in the prompt and specify the exact format of the JSON, otherwise it may result in unexpected outcomes. Default is {"type": "text"}.
Stop words, which will halt the output when a full match is found. The matched words themselves will not be output. A maximum of 5 strings is allowed, and each string must not exceed 32 bytes
Whether to return the response in a streaming fashion. Default is false.
Options for streaming responses
A list of tools the model may call
128Used to cache responses for similar requests to optimize cache hit rates. For Coding Agents, this is typically a session id or task id representing a single session; if the session is exited and later resumed, this value should remain the same. For Kimi Code Plan, this field is required to improve cache hit rates. For other agents involving multi-turn conversations, it is also recommended to implement this field
A stable identifier used to help detect users of your application that may be violating usage policies. The ID should be a string that uniquely identifies each user. It is recommended to hash the username or email address to avoid sending any identifying information
Controls if thinking is enabled for kimi-k2.5 model. Only available when model equals to kimi-k2.5. Optional parameter. Default value is {"type": "enabled"}.