Skip to main content
The Kimi intelligent assistant can upload files and answer questions based on those files. The Kimi API offers the same functionality. Below, we’ll walk through a practical example of how to upload files and ask questions using the Kimi API:
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.
Let’s review the basic steps and considerations for file-based Q&A:
  1. Upload the file to the Kimi server using the /v1/files interface or the files.create API in the SDK;
  2. Retrieve the file content using the /v1/files/{file_id} interface or the files.content API in the SDK. The retrieved content is already formatted in a way that our recommended model can easily understand;
  3. Place the extracted (and formatted) file content (not the file id) in the messages list as a system prompt;
  4. Start asking questions about the file content;
Note again: Place the file content in the prompt, not the file id.

Q&A on Multiple Files

If you want to ask questions based on multiple files, it’s quite simple. Just place each file in a separate system prompt. Here’s how you can do it in code:

Best Practices for File Management

In general, the file upload and extraction features are designed to convert files of various formats into a format that our recommended model can easily understand. After completing the file upload and extraction steps, the extracted content can be stored locally. In the next file-based Q&A request, there is no need to upload and extract the files again. Since we have limited the number of files a single user can upload (up to 1000 files per user), we suggest that you regularly clean up the uploaded files after the extraction process is complete. You can periodically run the following code to clean up the uploaded files:
In the code above, we first list all the file details using the files.list API and then delete each file using the files.delete API. Regularly performing this operation ensures that file storage space is released, allowing subsequent file uploads and extractions to be successful.