> ## 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.

# 创建批处理任务

> 创建一个新的批量处理任务。见 [批量服务](/cn/guide/tools/batch)。点击 **Try it** 按钮可快速试用。



## OpenAPI

````yaml /openapi/openapi.json post /paas/v4/batches
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/batches:
    post:
      tags:
        - 批处理 API
      summary: 创建批处理任务
      description: 创建一个新的批量处理任务。见 [批量服务](/cn/guide/tools/batch)。点击 **Try it** 按钮可快速试用。
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BatchCreateRequest'
        required: true
      responses:
        '200':
          description: 业务处理成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Batch'
        default:
          description: 请求失败。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    BatchCreateRequest:
      type: object
      properties:
        input_file_id:
          type: string
          description: >-
            上传文件的 `ID`，该文件包含`Batch`的请求。输入文件必须是 `.Jsonl`
            格式，并且文件上传时的目的必须标记为"batch"。
        endpoint:
          type: string
          description: '`Batch` 中所有请求将使用的端点。目前支持 `/v4/chat/completions`。'
          enum:
            - /v4/chat/completions
        auto_delete_input_file:
          type: boolean
          description: 是否自动删除`batch`原始文件，默认为`True`：`True`：执行自动删除。`False`：保留原始`batch`文件。
          default: true
        metadata:
          type: object
          nullable: true
          description: >-
            用于存储与 `Batch` 相关的数据，如客户`I`D、描述或其他任务管理和跟踪所需的额外信息。可附加到对象上的键值对集合最多为
            `16` 个。每个键的长度最多为 `64` 个字符，每个值的长度最多为 `512` 个字符。
      required:
        - input_file_id
        - endpoint
    Batch:
      type: object
      properties:
        id:
          type: string
          description: 批处理的唯一标识符。
        object:
          type: string
          description: 对象类型，这里为 `batch`。
        endpoint:
          type: string
          description: 批处理使用的 `API` 端点。
        input_file_id:
          type: string
          description: 批处理使用的输入文件的`ID`。
        completion_window:
          type: string
          description: 批处理应在此时间框架内完成的期限。
        status:
          type: string
          description: 批处理的当前状态。
        output_file_id:
          type: string
          description: 包含成功执行请求的输出的文件`ID`。
        error_file_id:
          type: string
          description: 包含出现错误的请求的输出的文件`ID`。
        created_at:
          type: integer
          description: 创建批处理的`Unix`时间戳（秒）。
        in_progress_at:
          type: integer
          description: 批处理开始处理的`Unix`时间戳（秒）。
        expires_at:
          type: integer
          description: 批处理将过期的`Unix`时间戳（秒）。
        finalizing_at:
          type: integer
          description: 批处理开始最终处理的`Unix`时间戳（秒）。
        completed_at:
          type: integer
          description: 批处理完成的`Unix`时间戳（秒）。
        failed_at:
          type: integer
          description: 批处理失败的`Unix`时间戳（秒）。
        expired_at:
          type: integer
          description: 批处理过期的`Unix`时间戳（秒）。
        cancelling_at:
          type: integer
          description: 批处理开始取消的`Unix`时间戳（秒）。
        cancelled_at:
          type: integer
          description: 批处理取消完成的`Unix`时间戳（秒）。
        request_counts:
          type: integer
          description: batch 请求计数。
        total:
          type: integer
          description: 批处理中的请求总数。
        completed:
          type: integer
          description: 批处理中已成功完成的请求数量。
        failed:
          type: integer
          description: 批处理中失败的请求数量。
        metadata:
          type: object
          description: >-
            可附加到对象上的 `16` 个键值对的集合。这有助于以结构化格式存储对象的附加信息。键的长度最多为 `64` 个字符，值的长度最多为
            `512` 个字符。
    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) 页面获取密钥。

````