Kimi is a very powerful AI dialogue system that can generate smooth and natural replies in just a few seconds by inputting prompt words. Kimi provides amazing intelligent assistance, greatly enhancing human work efficiency and creativity. This document mainly introduces the usage process of the Kimi Chat Completion API, allowing us to easily utilize the official Kimi dialogue features.Documentation Index
Fetch the complete documentation index at: https://docs.acedata.cloud/llms.txt
Use this file to discover all available pages before exploring further.
Application Process
To use the Gemini Chat Completion API, you can first visit the Kimi Chat Completion API page and click the “Acquire” button to obtain the credentials needed for the request:
If you are not logged in or registered, you will be automatically redirected to the login page inviting you to register and log in. After logging in or registering, you will automatically return to the current page.
During the first application, there will be a free quota provided, allowing you to use the API for free.
Basic Usage
Next, you can fill in the corresponding content on the interface, as shown in the figure:
authorization, which can be selected directly from the dropdown list. The other parameter is model, which is the category of the Kimi official model we choose to use. Here we mainly have 7 types of models; details can be found in the models we provide. The last parameter is messages, which is an array of our input questions. It is an array that allows multiple questions to be uploaded simultaneously, with each question containing role and content. The role indicates the role of the questioner, and we provide three identities: user, assistant, and system. The other content is the specific content of our question.
You can also notice that there is corresponding code generation on the right side; you can copy the code to run directly or click the “Try” button for testing.

id, the ID generated for this dialogue task, used to uniquely identify this dialogue task.model, the selected Kimi official model.choices, the response information provided by Kimi for the question.usage: statistics on the tokens used for this Q&A.
choices contains Kimi’s response information, and the choices inside it shows the specific information of Kimi’s response, as can be seen in the figure.

content field in choices contains the specific content of the Gemini reply.
Streaming Response
This interface also supports streaming responses, which is very useful for web integration, allowing the webpage to achieve a word-by-word display effect. If you want to return responses in a streaming manner, you can change thestream parameter in the request header to true.
Modify as shown in the figure, but the calling code needs to have corresponding changes to support streaming responses.

stream to true, the API will return the corresponding JSON data line by line, and we need to make corresponding modifications at the code level to obtain the line-by-line results.
Python sample calling code:
data in the response, and the choices within data are the latest response content, consistent with the content introduced above. choices are the newly added response content, and you can integrate it into your system based on the results. The end of the streaming response is determined by the content of data; if the content is [DONE], it indicates that the streaming response has completely ended. The returned data result has multiple fields, described as follows:
id, the ID generated for this dialogue task, used to uniquely identify this dialogue task.model, the selected Kimi official website model.choices, the response information provided by Kimi for the query.
Multi-turn Dialogue
If you want to integrate multi-turn dialogue functionality, you need to upload multiple query words in themessages field. The specific examples of multiple query words are shown in the image below:

choices is consistent with the basic usage content, which includes the specific content of Kimi’s responses to multiple dialogues, allowing you to answer corresponding questions based on multiple dialogue contents.
Error Handling
When calling the API, if an error occurs, the API will return the corresponding error code and message. For example:400 token_mismatched: Bad request, possibly due to missing or invalid parameters.400 api_not_implemented: Bad request, possibly due to missing or invalid parameters.401 invalid_token: Unauthorized, invalid or missing authorization token.429 too_many_requests: Too many requests, you have exceeded the rate limit.500 api_error: Internal server error, something went wrong on the server.

