openapi: 3.1.0 info: title: Moonshot AI Batch Files API version: 1.0.0 description: API for Moonshot AI / Kimi large language model services servers: - url: https://api.moonshot.ai description: Production tags: - name: Files paths: /v1/files: post: summary: Upload File description: Uploads a file for extraction, image understanding, or video understanding. tags: - Files security: - bearerAuth: [] requestBody: required: true content: multipart/form-data: schema: type: object properties: file: type: string format: binary description: The file to upload purpose: type: string enum: - file-extract - image - video - batch description: 'Specifies how the uploaded file will be processed. file-extract: extract file contents; image: upload images for vision understanding; video: upload videos for video understanding; batch: upload JSONL files for batch processing' required: - file - purpose responses: '200': description: Uploaded file metadata content: application/json: schema: $ref: '#/components/schemas/FileObject' '400': description: Bad request - Invalid upload parameters content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '401': description: Unauthorized - Invalid or missing API key content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '500': description: Server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' get: summary: List Files description: Lists all files uploaded by the current user. tags: - Files security: - bearerAuth: [] responses: '200': description: List of uploaded files content: application/json: schema: $ref: '#/components/schemas/FileListResponse' '401': description: Unauthorized - Invalid or missing API key content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '500': description: Server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /v1/files/{file_id}: get: summary: Get File Information description: Retrieves metadata for a specific uploaded file. tags: - Files security: - bearerAuth: [] parameters: - name: file_id in: path required: true description: The file identifier schema: type: string responses: '200': description: File metadata content: application/json: schema: $ref: '#/components/schemas/FileObject' '401': description: Unauthorized - Invalid or missing API key content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '404': description: File not found content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '500': description: Server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' delete: summary: Delete File description: Deletes a previously uploaded file. tags: - Files security: - bearerAuth: [] parameters: - name: file_id in: path required: true description: The file identifier schema: type: string responses: '200': description: Deletion result content: application/json: schema: $ref: '#/components/schemas/FileDeleteResponse' '401': description: Unauthorized - Invalid or missing API key content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '404': description: File not found content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '500': description: Server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /v1/files/{file_id}/content: get: summary: Get File Content description: Retrieves extracted text content for files uploaded with purpose `file-extract`. tags: - Files security: - bearerAuth: [] parameters: - name: file_id in: path required: true description: The file identifier schema: type: string responses: '200': description: Extracted file content content: text/plain: schema: type: string description: Extracted file content as plain text '401': description: Unauthorized - Invalid or missing API key content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '404': description: File not found content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '500': description: Server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' components: schemas: FileObject: type: object properties: id: type: string description: Unique file identifier object: type: string description: Object type example: file bytes: type: integer description: File size in bytes created_at: type: integer description: Unix timestamp when the file was created filename: type: string description: Original file name purpose: type: string description: 'Purpose used when uploading the file. file-extract: extract file contents; image: upload images for vision understanding; video: upload videos for video understanding; batch: upload JSONL files for batch processing' enum: - file-extract - image - video - batch status: type: string description: Processing status of the file example: ready status_details: type: string description: Additional status details when processing fails or returns warnings required: - id - object - bytes - created_at - filename - purpose - status FileDeleteResponse: type: object properties: id: type: string description: Deleted file identifier object: type: string example: file deleted: type: boolean description: Whether the file was deleted successfully required: - id - object - deleted FileListResponse: type: object properties: object: type: string example: list data: type: array items: $ref: '#/components/schemas/FileObject' required: - object - data ErrorResponse: type: object properties: error: type: object properties: message: type: string description: Error message describing what went wrong type: type: string description: Error type code: type: string description: Error code required: - message required: - error securitySchemes: bearerAuth: type: http scheme: bearer description: 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](https://platform.kimi.ai/console/api-keys) in your dashboard.