> ## Documentation Index
> Fetch the complete documentation index at: https://oma-codex-339-workspace-permissions.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 列出消息批处理

> 通过 OMA API 列出消息批处理。

<Info>要使用此处展示的 Beta 请求和响应结构，请同时发送 `?beta=true` 与 `anthropic-beta: message-batches-2024-09-24`。</Info>


## OpenAPI

````yaml /openapi/oma.zh.json get /v1/messages/batches
openapi: 3.1.0
info:
  title: OMA API 参考
  version: 1.0.0
  description: Open Managed Agents 应用 API 参考。
servers:
  - url: http://localhost:38080
    description: 本地 OMA 服务器
security:
  - omaApiKey: []
  - omaBearer: []
paths:
  /v1/messages/batches:
    get:
      summary: 列出消息批处理
      description: 通过 OMA API 列出消息批处理。
      operationId: beta_message_batches_list
      parameters:
        - name: beta
          in: query
          required: true
          description: 为此接口启用 Beta API 合同，必须为 `true`。
          schema:
            type: boolean
            enum:
              - true
        - name: before_id
          in: query
          required: false
          schema:
            type: string
            description: 用作分页游标的对象 ID。提供时，返回紧邻该对象之前的结果页。
            title: 之前的 ID
          description: 用作分页游标的对象 ID。提供时，返回紧邻该对象之前的结果页。
        - name: after_id
          in: query
          required: false
          schema:
            type: string
            description: 用作分页游标的对象 ID。提供时，返回紧随该对象之后的结果页。
            title: 之后的 ID
          description: 用作分页游标的对象 ID。提供时，返回紧随该对象之后的结果页。
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 1000
            minimum: 1
            description: |-
              每页返回的条目数量。

              默认为 `20`。取值范围为 `1` 到 `1000`。
            default: 20
            title: 数量上限
          description: |-
            每页返回的条目数量。

            默认为 `20`。取值范围为 `1` 到 `1000`。
        - name: anthropic-beta
          in: header
          required: true
          schema:
            type: string
            items:
              type: string
            description: |-
              用于指定要使用的 beta 版本的可选请求头。

              要使用多个 beta，请使用逗号分隔的列表（如 `beta1,beta2`），或为每个 beta 分别指定该请求头。
            title: Anthropic-Beta
            x-stainless-override-schema:
              x-stainless-param: betas
              x-stainless-extend-default: true
              type: array
              description: 用于指定一个或多个 Beta 版本的可选请求头。
              items:
                $ref: '#/components/schemas/AnthropicBeta'
            x-default: message-batches-2024-09-24
          description: |-
            用于指定要使用的 beta 版本的可选请求头。

            要使用多个 beta，请使用逗号分隔的列表（如 `beta1,beta2`），或为每个 beta 分别指定该请求头。
        - name: anthropic-version
          in: header
          required: false
          schema:
            type: string
            description: |-
              你想使用的 OMA API 版本。

              在此处阅读更多关于版本控制和我们版本历史的信息。
            title: Anthropic-Version
          description: |-
            你想使用的 OMA API 版本。

            在此处阅读更多关于版本控制和我们版本历史的信息。
      responses:
        '200':
          description: 成功的响应
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaListResponse_MessageBatch_'
        4XX:
          description: |-
            错误响应。

            详见我们的错误文档。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
components:
  schemas:
    BetaListResponse_MessageBatch_:
      properties:
        data:
          items:
            $ref: '#/components/schemas/BetaMessageBatch'
          type: array
          title: 数据
        first_id:
          anyOf:
            - type: string
            - type: 'null'
          title: 首个 ID
          description: '`data` 列表中的第一个 ID。可用作上一页的 `before_id`。'
        has_more:
          type: boolean
          title: 是否还有更多
          description: 表示在请求的分页方向上是否还有更多结果。
        last_id:
          anyOf:
            - type: string
            - type: 'null'
          title: 末尾 ID
          description: '`data` 列表中的最后一个 ID。可用作下一页的 `after_id`。'
      type: object
      required:
        - data
        - first_id
        - has_more
        - last_id
      title: ListResponse[MessageBatch]
    BetaErrorResponse:
      properties:
        error:
          discriminator:
            mapping:
              api_error:
                $ref: '#/components/schemas/BetaAPIError'
              authentication_error:
                $ref: '#/components/schemas/BetaAuthenticationError'
              billing_error:
                $ref: '#/components/schemas/BetaBillingError'
              invalid_request_error:
                $ref: '#/components/schemas/BetaInvalidRequestError'
              not_found_error:
                $ref: '#/components/schemas/BetaNotFoundError'
              overloaded_error:
                $ref: '#/components/schemas/BetaOverloadedError'
              permission_error:
                $ref: '#/components/schemas/BetaPermissionError'
              rate_limit_error:
                $ref: '#/components/schemas/BetaRateLimitError'
              timeout_error:
                $ref: '#/components/schemas/BetaGatewayTimeoutError'
            propertyName: type
          oneOf:
            - $ref: '#/components/schemas/BetaInvalidRequestError'
            - $ref: '#/components/schemas/BetaAuthenticationError'
            - $ref: '#/components/schemas/BetaBillingError'
            - $ref: '#/components/schemas/BetaPermissionError'
            - $ref: '#/components/schemas/BetaNotFoundError'
            - $ref: '#/components/schemas/BetaRateLimitError'
            - $ref: '#/components/schemas/BetaGatewayTimeoutError'
            - $ref: '#/components/schemas/BetaAPIError'
            - $ref: '#/components/schemas/BetaOverloadedError'
          title: 错误
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: 请求 ID
        type:
          const: error
          default: error
          title: 类型
          type: string
      required:
        - error
        - request_id
        - type
      title: ErrorResponse
      type: object
    BetaMessageBatch:
      properties:
        archived_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: 归档时间
          description: 表示消息批处理被归档且其结果不再可用的时间的 RFC 3339 日期时间字符串。
          examples:
            - '2024-08-20T18:37:24.100435Z'
        cancel_initiated_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: 取消开始时间
          description: 表示发起取消该消息批处理的时间的 RFC 3339 日期时间字符串。仅在已发起取消时才会指定。
          examples:
            - '2024-08-20T18:37:24.100435Z'
        created_at:
          type: string
          format: date-time
          title: 创建时间
          description: 表示消息批处理创建时间的 RFC 3339 日期时间字符串。
          examples:
            - '2024-08-20T18:37:24.100435Z'
        ended_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: 结束时间
          description: |-
            表示消息批处理处理结束时间的 RFC 3339 日期时间字符串。仅在处理结束时指定。

            当消息批处理中的每个请求都已成功、出错、取消或过期时，处理结束。
          examples:
            - '2024-08-20T18:37:24.100435Z'
        expires_at:
          type: string
          format: date-time
          title: 过期时间
          description: 表示消息批处理将到期并结束处理的时间的 RFC 3339 日期时间字符串，即创建后 24 小时。
          examples:
            - '2024-08-20T18:37:24.100435Z'
        id:
          type: string
          title: ID
          description: |-
            唯一的对象标识符。

            ID 的格式和长度可能会随时间变化。
          examples:
            - msgbatch_013Zva2CMHLNnXjNJJKqJ2EF
        processing_status:
          type: string
          enum:
            - in_progress
            - canceling
            - ended
          title: 处理状态
          description: 消息批处理的处理状态。
          examples:
            - in_progress
        request_counts:
          $ref: '#/components/schemas/BetaRequestCounts'
          description: |-
            按状态分类统计消息批处理中的请求。

            请求初始状态为 `processing`，仅在整个批次的处理结束后才会转为其他状态之一。所有值之和始终与批次中的请求总数一致。
        results_url:
          anyOf:
            - type: string
            - type: 'null'
          title: 结果 URL
          description: |-
            包含消息批处理请求结果的 `.jsonl` 文件的 URL。仅在处理结束时指定。

            不保证文件中的结果与请求的顺序一致。请使用 `custom_id` 字段将结果与请求匹配。
          examples:
            - >-
              https://oma.example.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results
        type:
          type: string
          const: message_batch
          title: 类型
          description: |-
            对象类型。

            对于消息批处理，此值始终为 `"message_batch"`。
          default: message_batch
      type: object
      required:
        - archived_at
        - cancel_initiated_at
        - created_at
        - ended_at
        - expires_at
        - id
        - processing_status
        - request_counts
        - results_url
        - type
      title: MessageBatch
    BetaAPIError:
      properties:
        message:
          default: Internal server error
          title: 消息
          type: string
        type:
          const: api_error
          default: api_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: APIError
      type: object
    BetaAuthenticationError:
      properties:
        message:
          default: Authentication error
          title: 消息
          type: string
        type:
          const: authentication_error
          default: authentication_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: AuthenticationError
      type: object
    BetaBillingError:
      properties:
        message:
          default: Billing error
          title: 消息
          type: string
        type:
          const: billing_error
          default: billing_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: BillingError
      type: object
    BetaInvalidRequestError:
      properties:
        message:
          default: Invalid request
          title: 消息
          type: string
        type:
          const: invalid_request_error
          default: invalid_request_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: InvalidRequestError
      type: object
    BetaNotFoundError:
      properties:
        message:
          default: Not found
          title: 消息
          type: string
        type:
          const: not_found_error
          default: not_found_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: NotFoundError
      type: object
    BetaOverloadedError:
      properties:
        message:
          default: Overloaded
          title: 消息
          type: string
        type:
          const: overloaded_error
          default: overloaded_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: OverloadedError
      type: object
    BetaPermissionError:
      properties:
        message:
          default: Permission denied
          title: 消息
          type: string
        type:
          const: permission_error
          default: permission_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: PermissionError
      type: object
    BetaRateLimitError:
      properties:
        message:
          default: Rate limited
          title: 消息
          type: string
        type:
          const: rate_limit_error
          default: rate_limit_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: RateLimitError
      type: object
    BetaGatewayTimeoutError:
      properties:
        message:
          default: Request timeout
          title: 消息
          type: string
        type:
          const: timeout_error
          default: timeout_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: GatewayTimeoutError
      type: object
    BetaRequestCounts:
      properties:
        canceled:
          type: integer
          title: 已取消
          description: |-
            消息批处理中已被取消的请求数量。

            在整个消息批处理的处理结束之前，该值始终为零。
          default: 0
          examples:
            - 10
        errored:
          type: integer
          title: 错误数
          description: |-
            消息批处理中遇到错误的请求数量。

            在整个消息批处理的处理结束之前，该值始终为零。
          default: 0
          examples:
            - 30
        expired:
          type: integer
          title: 已过期
          description: |-
            消息批处理中已过期的请求数量。

            在整个消息批处理的处理结束之前，该值始终为零。
          default: 0
          examples:
            - 10
        processing:
          type: integer
          title: 处理中
          description: 消息批处理中正在处理的请求数量。
          default: 0
          examples:
            - 100
        succeeded:
          type: integer
          title: 成功数
          description: |-
            消息批处理中已成功完成的请求数。

            在整个消息批处理处理结束之前，该值为零。
          default: 0
          examples:
            - 50
      type: object
      required:
        - canceled
        - errored
        - expired
        - processing
        - succeeded
      title: RequestCounts
  securitySchemes:
    omaApiKey:
      type: apiKey
      in: header
      name: X-Api-Key
      description: OMA 工作区 API 密钥。
      x-default: sk-ant-local-default
    omaBearer:
      type: http
      scheme: bearer
      description: 以 Bearer 令牌形式发送的 OMA 工作区 API 密钥。

````