Skip to main content
The files endpoints support two main workflows:
  1. Make existing files available to a session: Upload a file, save the returned file_id, and attach it either when creating a session or while a session is running.
  2. Retrieve session files: List the files in a session, then download the ones you need.
Uploaded files are not automatically attached to sessions. Manage uploaded files through /v1/files, and browse or download session files through /v1/sessions/{session_id}/filesystem.
The response format of /v1/files* endpoints is controlled by the kimi-api-version request header: sending 2026-09-01-beta returns the Hosted Agents format (HTTP 201 on upload, HTTP 204 on deletion, and the FileMetadata response model); omitting the header returns the Kimi API Platform legacy-compatible format (HTTP 200 on upload, HTTP 200 on deletion, and the FileObject model); any other non-empty value returns HTTP 400. Status codes and field names differ between the two formats, so each client should stick to one format and never mix parsing logic. We recommend including kimi-api-version: 2026-09-01-beta on every request: it keeps the response format consistent, and only files with file_-prefixed IDs created under this format can be attached to sessions.

Upload files and attach them to a session

In enterprise organizations, open Files under Project in the console sidebar, select the Hosted Agents tab, and click Upload file to upload a local file; see Using the Console for details. You can also upload files with the REST API (POST /v1/files) or the kha CLI, then select them in the Files field when creating a session in the console. To inspect files delivered by agents, open Artifacts under Project in the console sidebar. The examples below show both cURL and kha CLI commands.

Upload a file

Send a multipart/form-data request to POST /v1/files. The file part is required; the filename can come from the file part itself or be specified via the filename form field. purpose specifies how the file is processed: file-extract, image, video, or batch. Only the uploader can read the content of or delete a file uploaded with purpose=batch, and such files cannot be attached to a session. Each file can be at most 100 MiB and cannot be updated after upload. The default total storage quota per organization is 10 GiB. Once the quota is reached, new uploads are rejected; delete unused files to free up quota. Include the kimi-api-version: 2026-09-01-beta request header when calling /v1/files* endpoints to use the current API version. The command below saves id from the upload response to FILE_ID for use in subsequent requests.
On success, the endpoint responds with HTTP 201 and a file object. FILE_ID comes from id in the upload response and can be used to attach the file, retrieve its metadata, read its content, or delete it.
extract_status indicates the parsing status of the file: ready means the file is ready for use, and error means parsing failed. A file whose parsing failed can still be attached to a session, but the session receives only the raw file without extracted text. When a file with the same name is uploaded within the same scope, the server appends a suffix to the filename to avoid collisions.

Attach a file when creating a session

When creating a session, add a session resource object with type set to file in the resources array of the request body, using the FILE_ID saved in the previous step. For a complete session creation request example, see Create a Session.

Add a file during a running session

After creating a session, you can add file resources via POST /v1/sessions/{session_id}/resources. SESSION_ID comes from id in the session creation response; see Create a Session. Only file resources can be added after session creation—vaults, memory stores, and GitHub repositories must be attached when creating the session.
On success, the endpoint responds with HTTP 201 and a session resource object whose id identifies this resource binding.
Only file IDs with the file_ prefix can be attached to a session. Legacy IDs synced from the previous Kimi API Platform (without the file_ prefix) cannot be attached and return an error when submitted.

Manage uploaded files

The scope of GET /v1/files depends on the version header: sending 2026-09-01-beta lists files in the current project, whereas omitting the version header lists files across the entire organization. Results are returned in reverse chronological order by upload time, with the most recently uploaded files first. Both formats support pagination via page_size (1–1000) and page_token, returning the full list when those parameters are omitted; the Hosted Agents format uses next_page_token in the response to fetch the next page (omitted when there are no further pages), while the Model Inference API-compatible format uses has_more to indicate whether another page exists. To check which uploaded files are attached to a given session, call GET /v1/sessions/{session_id}/filesystem?prefix=upload/ to list the files under upload/ in that session. Retrieve metadata for FILE_ID:
Read the content of FILE_ID. What the endpoint returns depends on purpose: for a file-extract file, it returns a JSON object with the extracted Markdown in the content field; for a batch file, it returns the uploaded file content, which is parsed and normalized on upload so the returned bytes may differ from the original upload. image files, video files, and files that failed parsing have no extracted content, so requesting their content returns HTTP 400 (failed_precondition_error). The command below reads the content of FILE_ID and uses jq to write the Markdown in content to report.md:
Delete the uploaded file FILE_ID (responds with HTTP 204 on success):
FILE_ID in all of these commands comes from the upload response.

Response format comparison

Both /v1/files* response formats are served side by side: omitting kimi-api-version returns the Model Inference API-compatible format, while sending 2026-09-01-beta returns the Hosted Agents format. Files synced from the legacy Kimi API Platform and newly uploaded files appear in the same list. Field mapping between the two file models:

Retrieve session files

In the console, open the session details page and select the Files panel on the right to browse the session working directory tree level by level; files generated by the agent are saved in the output directory. Files delivered by the agent also appear on the project’s Artifacts page. See Using the Console for details.

List session files

Files generated or saved while a session runs are stored under the session and listed via GET /v1/sessions/{session_id}/filesystem. The endpoint returns one directory level at a time: omitting prefix lists the root directory, and passing a directory prefix lists the direct files and subdirectories under that path.
Listing session files returns SessionFSNode entries:
The response returns all direct children of the requested directory in a single call without pagination. Uploaded files attached to a session are located under upload/; pass prefix=upload/ to list them.

Download a session file

Pass the path of a listed entry to GET /v1/sessions/{session_id}/filesystem/raw to download the file.
Session files are not guaranteed to be fully durable: files written by background processes that keep running after the agent finishes may be lost or incomplete, and directory listings may lag behind recent writes. When you need durable, versioned outputs, have the agent deliver them as artifacts via save_artifact—artifacts are managed through dedicated artifact endpoints.

Next steps

Attach files and retrieve artifacts

Learn about the session lifecycle, session creation, and sending and receiving messages.