> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bigmodel.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 上传文件

> 上传用于 `Batch 任务`、`智能体` 等功能的文件。注意 `Try it` 功能仅支持小文件上传，实际支持的文件大小请参见下文 `purpose` 相关说明。点击 **Try it** 按钮可快速试用。



## OpenAPI

````yaml /openapi/openapi.json post /paas/v4/files
openapi: 3.0.1
info:
  title: ZHIPU AI API
  description: ZHIPU AI 接口提供强大的 AI 能力，包括聊天对话、工具调用和视频生成。
  license:
    name: ZHIPU AI 开发者协议和政策
    url: https://chat.z.ai/legal-agreement/terms-of-service
  version: 1.0.0
  contact:
    name: Z.AI 开发者
    url: https://chat.z.ai/legal-agreement/privacy-policy
    email: user_feedback@z.ai
servers:
  - url: https://open.bigmodel.cn/api/
    description: 开放平台服务
security:
  - bearerAuth: []
tags:
  - name: 模型 API
    description: Chat API
  - name: 工具 API
    description: Web Search API
  - name: Agent API
    description: Agent API
  - name: 文件 API
    description: File API
  - name: 知识库 API
    description: Knowledge API
  - name: 实时 API
    description: Realtime API
  - name: 批处理 API
    description: Batch API
  - name: 助理 API
    description: Assistant API
  - name: 智能体 API（旧）
    description: QingLiu Agent API
paths:
  /paas/v4/files:
    post:
      tags:
        - 文件 API
      summary: 上传文件
      description: >-
        上传用于 `Batch 任务`、`智能体` 等功能的文件。注意 `Try it` 功能仅支持小文件上传，实际支持的文件大小请参见下文
        `purpose` 相关说明。点击 **Try it** 按钮可快速试用。
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/FileUploadRequest'
        required: true
      responses:
        '200':
          description: 业务处理成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileObject'
        default:
          description: 请求失败。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    FileUploadRequest:
      type: object
      required:
        - file
        - purpose
      properties:
        file:
          type: string
          format: binary
          description: 要上传的文件
        purpose:
          type: string
          enum:
            - batch
            - code-interpreter
            - agent
            - voice-clone-input
          description: >-
            文件的预期用途。

            `batch`：用于批量任务处理，支持 `.jsonl` 文件格式，，单个文件大小限制为`100 MB`，文件数不超过 `1000`
            个。`Batch`指南。

            `code-interpreter`：文件上传给代码沙盒`CI`使用，支持的格式包括：`pdf、docx、doc、xls、xlsx、txt、png、jpg、jpeg、csv`，单个文件大小限制为
            `20M`，图片大小不超过`5M`，文件数不超过 `100` 个。

            `agent`：用于智能体文件上传，支持的格式包括：`pdf、docx、doc、xls、xlsx、txt、png、jpg、jpeg、csv`，单个文件大小限制为
            `20M`，图片大小不超过`5M`，文件数不超过 `1000` 个。

            `voice-clone-input`: 用于音色克隆功能示例音频文件的上传。支持的格式包括`mp3、wav`
    FileObject:
      type: object
      properties:
        id:
          type: string
          description: 文件标识符
        object:
          type: string
          enum:
            - file
        bytes:
          type: integer
          description: 文件大小（字节）
        created_at:
          type: integer
          description: 文件创建的`Unix`时间戳
        filename:
          type: string
          description: 文件名
        purpose:
          type: string
          description: 文件的预期用途
    Error:
      type: object
      properties:
        error:
          required:
            - code
            - message
          type: object
          properties:
            code:
              type: string
            message:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        标准的 HTTP Bearer 认证方式，在 [API
        Keys](https://bigmodel.cn/usercenter/proj-mgmt/apikeys) 页面获取密钥。

````