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

# 取消批处理

> 停止批处理中排队项的工作。已经在运行的项可能仍会完成。

> [!NOTE]
>
> **刚发送就发现了拼写错误？** 这种情况谁都会遇到。取消批处理，您只需为成功完成的项付费。
>
> * **已完成：** 已计费。这些结果已完成并等待您查看。
> * **仍在队列中：** 从未运行，未计费。这是节省费用的地方。
> * **正在运行：** 您只需为成功的项付费，和往常一样。
>
> 已经花费的积分不予退还，但批处理的其余部分将不再产生费用。

> [!TIP]
>
> **取消后：** 批处理仍可能显示为 `in_progress`，直到正在运行的项完成或超时。使用 [批处理信息](https://docs.olostep.com/api-reference/batches/info.md) 检查进度。可以安全地再次对同一批处理调用取消操作。


## OpenAPI

````yaml zh/openapi/batches.json POST /v1/batches/{batch_id}/cancel
openapi: 3.0.3
info:
  title: 批处理 API
  version: 1.0.0
servers:
  - url: https://api.olostep.com
security: []
paths:
  /v1/batches/{batch_id}/cancel:
    post:
      summary: 取消一个批次
      description: 取消批次中**排队**的项目。已经运行的项目可能仍会完成。不需要请求正文。再次调用同一批次的取消是安全的：已经取消的项目不会再次计数。
      parameters:
        - name: batch_id
          in: path
          required: true
          schema:
            type: string
          description: 要取消的批次的ID。
      responses:
        '200':
          description: 整个批次的取消摘要。
          content:
            application/json:
              schema:
                type: object
                properties:
                  total_count:
                    type: integer
                    description: 批次中的项目总数。
                  done_count:
                    type: integer
                    description: 在此调用之前已完成或已取消的项目。
                  in_flight_count:
                    type: integer
                    description: 已经在运行的项目。它们不会被取消。
                  canceled_count:
                    type: integer
                    description: 此调用取消的排队项目。
                required:
                  - total_count
                  - done_count
                  - in_flight_count
                  - canceled_count
              example:
                total_count: 100
                done_count: 12
                in_flight_count: 3
                canceled_count: 87
        '401':
          description: 身份验证凭据缺失或无效。
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: error_abc123
                object: error
                code: invalid_api_key
                type: https://docs.olostep.com/errors/invalid_api_key
                status: 401
                title: 无效或缺失的API密钥
                detail: The provided API key is invalid.
                created: 1704067200
                metadata: {}
        '404':
          description: 提供的ID未找到批次，或它属于另一个团队。
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: error_abc123
                object: error
                code: not_found
                type: https://docs.olostep.com/errors/not_found
                status: 404
                title: 未找到批次
                detail: No batch with id 'YOUR_BATCH_ID' exists for your team.
                created: 1704067200
                metadata: {}
        '409':
          description: 批次截止日期已过，因此不再允许取消。
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: error_abc123
                object: error
                code: resource_conflict
                type: https://docs.olostep.com/errors/resource_conflict
                status: 409
                title: 资源冲突
                detail: The batch deadline has passed.
                created: 1704067200
                metadata: {}
        '500':
          description: >-
            内部服务器错误。详情请参见 [Internal
            Error](/api-reference/errors/internal_error)。
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: error_abc123
                object: error
                code: internal_server_error
                type: https://docs.olostep.com/api-reference/errors/internal_error
                status: 500
                title: 内部服务器错误
                detail: An unexpected error occurred
                created: 1704067200
                metadata: {}
      security:
        - Authorization: []
components:
  schemas:
    Error:
      type: object
      description: RFC 7807 问题详情错误响应
      properties:
        id:
          type: string
          description: 唯一错误标识符
        object:
          type: string
          enum:
            - error
          description: 始终为 'error'
        code:
          type: string
          description: 机器可读的错误代码
        type:
          type: string
          format: uri
          description: 标识问题类型的 URI 引用
        status:
          type: integer
          description: HTTP 状态代码
        title:
          type: string
          description: 简短的、可读的摘要
        detail:
          type: string
          description: 可读的解释
        created:
          type: integer
          description: Unix 时间戳
        metadata:
          $ref: '#/components/schemas/Metadata'
        errors:
          type: array
          description: 可选的额外错误详情数组
          items: {}
      required:
        - id
        - object
        - code
        - type
        - status
        - title
        - detail
        - created
    Metadata:
      type: object
      description: >-
        用于存储对象附加信息的键值对集合。遵循 Stripe 的验证规则：最多 50 个键，键最多 40 个字符（不含方括号），值最多 500
        个字符，所有值以字符串形式存储。
      additionalProperties:
        type: string
        maxLength: 500
        description: 元数据值（最多 500 个字符）。数字和布尔值会自动转换为字符串。
      maxProperties: 50
      example:
        order_id: '12345'
        customer_name: John Doe
        priority: high
        processed: 'true'
      x-validation-rules:
        max_keys: 50
        key_max_length: 40
        key_forbidden_chars:
          - '['
          - ']'
        value_max_length: 500
        value_types:
          - string
          - number (coerced)
          - boolean (coerced)
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer
      description: Bearer身份验证头的格式为Bearer <token>，其中<token>是你的身份验证令牌。

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.