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

# 获取批处理状态

> 获取先前创建的批处理任务。

需要工作区的预览功能访问权限。有关设置、Webhook 和结果处理，请参阅[视频与批处理任务](../../guides/async-video-and-batch.mdx)。


## OpenAPI

````yaml zh-Hans/openapi/v1/openapi.localized.yaml GET /batches/{batch_id}
openapi: 3.0.3
info:
  title: Phaseo Gateway API
  description: 通过兼容 OpenAI 的端点访问各种 AI 模型的网关 API。
  version: 1.0.0
  contact:
    name: Phaseo
    url: https://phaseo.app
    email: danielbutler500@gmail.com
servers:
  - url: https://api.phaseo.app/v1
    description: 全球路由
security:
  - BearerAuth: []
tags:
  - name: Gateway
    description: Core Phaseo Gateway operations.
paths:
  /batches/{batch_id}:
    get:
      tags:
        - Gateway
      summary: 获取批处理
      description: 获取先前创建的批处理任务。
      operationId: retrieveBatch
      parameters:
        - name: batch_id
          in: path
          required: true
          description: 要获取的批处理ID。
          schema:
            type: string
      responses:
        '200':
          description: 批处理状态响应
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchResponse'
        '401':
          description: 未授权
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: 未找到批处理
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '501':
          description: 此提供商不支持刷新批处理状态
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    BatchResponse:
      type: object
      properties:
        id:
          type: string
        native_batch_id:
          type: string
          nullable: true
          description: 与网关自有ID不同时的提供商原生批处理ID。
        object:
          type: string
        endpoint:
          type: string
        errors:
          type: object
        input_file_id:
          type: string
        completion_window:
          type: string
        status:
          type: string
        lifecycle_status:
          type: string
          enum:
            - pending
            - running
            - completed
            - failed
            - cancelled
            - expired
          description: 供轮询、WebSocket和Webhook使用方使用的标准化异步生命周期状态。
        progress:
          type: integer
          minimum: 0
          maximum: 100
          description: 基于提供商请求计数计算的粗略批处理完成百分比（如可用）。已完成批处理报告100。
        polling_url:
          type: string
          format: uri
        websocket_url:
          type: string
          format: uri
          description: 用于订阅标准化异步任务生命周期更新的WebSocket URL。
        cancel_url:
          type: string
          format: uri
          nullable: true
          description: 为兼容性保留；目前始终为null。
        results_url:
          type: string
          format: uri
          nullable: true
          description: >-
            受支持终态批处理的需认证Phaseo
            JSONL下载URL。处理中为null。终态批处理可能没有输出。请使用所属工作区的API密钥；提供商保留期限限制仍然适用。
        output_file_id:
          type: string
        error_file_id:
          type: string
        created_at:
          type: integer
        in_progress_at:
          type: integer
        expires_at:
          type: integer
        finalizing_at:
          type: integer
        completed_at:
          type: integer
        failed_at:
          type: integer
        expired_at:
          type: integer
        cancelling_at:
          type: integer
        cancelled_at:
          type: integer
        request_counts:
          $ref: '#/components/schemas/BatchRequestCounts'
        metadata:
          type: object
        request_id:
          type: string
        provider:
          type: string
        session_id:
          type: string
        webhook:
          $ref: '#/components/schemas/AsyncWebhookPublicState'
        next_webhook_retry_at:
          type: string
          nullable: true
        last_webhook_progress:
          type: number
          nullable: true
        last_webhook_progress_at:
          type: string
          nullable: true
        last_webhook_dispatched_at:
          type: string
          nullable: true
        finalized_at:
          type: string
          nullable: true
        pricing_lines:
          type: array
          items:
            type: object
            additionalProperties: true
        usage:
          type: object
          description: 完成后的标准化汇总使用量和成本。
          properties:
            requests:
              type: integer
              nullable: true
            input_tokens:
              type: integer
              nullable: true
            output_tokens:
              type: integer
              nullable: true
            total_tokens:
              type: integer
              nullable: true
            cost_nanos:
              type: integer
              nullable: true
            cost_usd:
              type: number
              nullable: true
            currency:
              type: string
        billing:
          $ref: '#/components/schemas/BatchBillingSummary'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        ok:
          type: boolean
          example: false
        error:
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
          example: error_type
        message:
          type: string
          example: Human-readable error message
        description:
          type: string
          example: Additional error details.
        generation_id:
          type: string
          example: G-abc123
        status_code:
          type: integer
          example: 502
        error_type:
          type: string
          enum:
            - user
            - system
          example: system
        error_origin:
          type: string
          enum:
            - user
            - gateway
            - upstream
          example: upstream
        reason:
          type: string
          example: all_candidates_failed
        attempt_count:
          type: integer
          example: 2
        failed_providers:
          type: array
          items:
            type: string
          example:
            - google-ai-studio
            - openai
        failed_statuses:
          type: array
          items:
            type: integer
          example:
            - 403
            - 429
        upstream_error:
          $ref: '#/components/schemas/ErrorUpstreamError'
        failure_sample:
          type: array
          items:
            $ref: '#/components/schemas/ErrorFailureSampleItem'
        provider_failure_diagnostics:
          $ref: '#/components/schemas/ErrorProviderFailureDiagnostics'
        routing_diagnostics:
          $ref: '#/components/schemas/ErrorRoutingDiagnostics'
        provider_candidate_diagnostics:
          $ref: '#/components/schemas/ErrorProviderCandidateDiagnostics'
        provider_enablement:
          $ref: '#/components/schemas/ErrorProviderEnablementDiagnostics'
        missing_pricing_providers:
          type: array
          items:
            type: string
        provider_payment_required_provider:
          type: string
          example: openai
        provider_payment_required_support_notice:
          type: string
          example: >-
            Our upstream provider billing appears to be unavailable. If this
            persists, contact support.
        details:
          type: array
          items:
            type: object
            additionalProperties: true
      additionalProperties: true
    BatchRequestCounts:
      type: object
      properties:
        total:
          type: integer
        completed:
          type: integer
        failed:
          type: integer
    AsyncWebhookPublicState:
      type: object
      description: >-
        已清理的异步Webhook配置及投递状态。绝不返回密钥；`has_secret`表示是否启用签名投递。签名投递包含x-phaseo-signature、x-phaseo-timestamp、x-phaseo-event-id、x-phaseo-event-type、x-phaseo-delivery-key、x-phaseo-attempt和x-phaseo-max-attempts请求头。
      properties:
        url:
          type: string
          format: uri
          nullable: true
        events:
          type: array
          items:
            type: string
        has_secret:
          type: boolean
        delivery:
          $ref: '#/components/schemas/AsyncWebhookDeliverySummary'
        attempts:
          type: array
          items:
            $ref: '#/components/schemas/AsyncWebhookDeliveryAttempt'
    BatchBillingSummary:
      type: object
      properties:
        currency:
          type: string
        billed:
          type: boolean
        charged:
          type: boolean
        reason:
          type: string
        state:
          type: string
          enum:
            - pending
            - estimated
            - settled
            - void
        reservation_id:
          type: string
          nullable: true
        reservation_status:
          type: string
          nullable: true
        estimated_provider_cost:
          type: string
          nullable: true
        estimated_user_cost:
          type: string
          nullable: true
        settled_provider_cost:
          type: string
          nullable: true
        settled_user_cost:
          type: string
          nullable: true
        estimated_nanos:
          type: integer
          nullable: true
        reserved_nanos:
          type: integer
          nullable: true
        estimation_truncated:
          type: boolean
          nullable: true
          description: 当预留估算由较大批处理输入文件的有限样本按比例扩展时为True。
        estimation_sample_size:
          type: integer
          nullable: true
          description: 预留估算中直接定价的输入行数。
        estimation_total_rows:
          type: integer
          nullable: true
          description: 预留估算代表的输入行总数。
        total_nanos:
          type: integer
          nullable: true
        cost_nanos:
          type: integer
          nullable: true
        cost_usd:
          type: number
          nullable: true
        finalized_at:
          type: string
          nullable: true
        pricing_breakdown:
          type: object
          additionalProperties: true
    ErrorUpstreamError:
      type: object
      properties:
        code:
          type: string
          nullable: true
          example: PERMISSION_DENIED
        message:
          type: string
          nullable: true
          example: The caller does not have permission.
        description:
          type: string
          nullable: true
        param:
          type: string
          nullable: true
    ErrorFailureSampleItem:
      type: object
      properties:
        provider:
          type: string
          nullable: true
        type:
          type: string
          nullable: true
        status:
          type: integer
          nullable: true
        upstream_error_code:
          type: string
          nullable: true
        upstream_error_message:
          type: string
          nullable: true
        upstream_error_description:
          type: string
          nullable: true
        upstream_error_param:
          type: string
          nullable: true
        upstream_payload_preview:
          type: string
          nullable: true
        retryable:
          type: boolean
          nullable: true
      additionalProperties: true
    ErrorProviderFailureDiagnostics:
      type: object
      properties:
        category:
          type: string
          enum:
            - credentials_not_configured
            - credentials_invalid_or_forbidden
            - provider_access_missing
            - region_or_project_restriction
            - model_unavailable_for_endpoint
            - rate_limited
            - server_error
        hint:
          type: string
        provider:
          type: string
          nullable: true
    ErrorRoutingDiagnostics:
      type: object
      properties:
        filterStages:
          type: array
          items:
            type: object
            properties:
              stage:
                type: string
              beforeCount:
                type: integer
              afterCount:
                type: integer
              droppedProviders:
                type: array
                items:
                  type: object
                  properties:
                    providerId:
                      type: string
                      nullable: true
                    reason:
                      type: string
                      nullable: true
                  additionalProperties: true
            additionalProperties: true
      additionalProperties: true
    ErrorProviderCandidateDiagnostics:
      type: object
      properties:
        totalProviders:
          type: integer
        supportsEndpointCount:
          type: integer
        candidateCount:
          type: integer
        droppedUnsupportedEndpoint:
          type: array
          items:
            type: string
        droppedMissingAdapter:
          type: array
          items:
            type: object
            properties:
              providerId:
                type: string
                nullable: true
              endpoint:
                type: string
                nullable: true
            additionalProperties: true
      additionalProperties: true
    ErrorProviderEnablementDiagnostics:
      type: object
      properties:
        capability:
          type: string
        providersBefore:
          type: array
          items:
            type: string
        providersAfter:
          type: array
          items:
            type: string
        dropped:
          type: array
          items:
            type: object
            properties:
              providerId:
                type: string
                nullable: true
              reason:
                type: string
                nullable: true
            additionalProperties: true
      additionalProperties: true
    AsyncWebhookDeliverySummary:
      type: object
      description: 网关管理的异步Webhook公开投递摘要。用于区分任务执行状态和Webhook投递健康状况。
      properties:
        total_attempts:
          type: integer
          description: 此任务记录的投递尝试总次数。
        delivered_events:
          type: integer
          description: 达到已投递状态的投递键数量。
        delivered_event_types:
          type: array
          description: 至少成功投递一次的投递键。
          items:
            type: string
          example:
            - video.completed
        pending_retries:
          type: integer
          description: 当前安排重试的投递键数量。
        next_retry_at:
          type: string
          nullable: true
          description: 下一次计划重试的ISO时间戳（如有）。
        last_attempt_at:
          type: string
          nullable: true
          description: 最近一次投递尝试的ISO时间戳。
        last_attempt_status:
          type: string
          nullable: true
          enum:
            - delivered
            - scheduled_retry
            - failed_permanently
          description: 最近一次投递尝试的结果。
        last_response_status:
          type: integer
          nullable: true
          description: Webhook目标返回的HTTP状态（如可用）。
        last_delivered_at:
          type: string
          nullable: true
          description: 最近一次成功投递的ISO时间戳。
        last_failure_at:
          type: string
          nullable: true
          description: 最近一次失败或正在重试的尝试的ISO时间戳。
        last_error_message:
          type: string
          nullable: true
          description: 最近一次投递错误消息（如可用）。
    AsyncWebhookDeliveryAttempt:
      type: object
      description: 最近一次网关管理的异步Webhook投递尝试。
      properties:
        id:
          type: string
          description: 用于审计和调试的稳定尝试标识符。
        delivery_key:
          type: string
          description: 此事件投递的幂等键。
          example: video.completed
        event_type:
          type: string
          description: 投递到Webhook目标的事件类型。
          example: video.completed
        status:
          type: string
          enum:
            - delivered
            - scheduled_retry
            - failed_permanently
        attempt_number:
          type: integer
          description: 此投递键从1开始的尝试编号。
        max_attempts:
          type: integer
          description: 将投递标记为永久失败之前的最大尝试次数。
        tried_at:
          type: string
          description: 进行此次尝试的ISO时间戳。
        delivered_at:
          type: string
          nullable: true
          description: 此次尝试成功投递的ISO时间戳。
        next_retry_at:
          type: string
          nullable: true
          description: 此次尝试后下一次重试的ISO时间戳（如已安排）。
        response_status:
          type: integer
          nullable: true
          description: Webhook目标返回的HTTP状态（如可用）。
        error_message:
          type: string
          nullable: true
          description: 投递错误消息（如可用）。
        response_body_preview:
          type: string
          nullable: true
          description: Webhook目标响应正文的已脱敏预览。
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Bearer 令牌身份验证

````

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