POST/v1/batches/{batch_id}/cancel

Cancel a batch

A batch not yet sent to the provider is cancelled at once; one already running moves to cancelling and may still return paid partial results. A finished batch is returned unchanged. Some providers cannot cancel a running batch (409 cancel_unsupported); the job then runs to completion.

Authentication: Bearer API key in the Authorization header

Path parameters

  • batch_idstringrequired

    The batch id.

Responses

  • 200

    The batch after the cancel request.

    Response
    • idstring
    • objectstring
    • endpointstring
    • errorsobject | null

      Rejected input lines: {object: list, data: [{code, message, line, custom_id}]}.

    • input_file_idstring
    • completion_windowstring
    • statusenum
      "validating""in_progress""finalizing""completed""failed""expired""cancelling""cancelled"
    • output_file_idstring | null
    • error_file_idstring | null
    • created_atinteger
    • expires_atinteger | null
    • completed_atinteger | null
    • failed_atinteger | null
    • expired_atinteger | null
    • cancelled_atinteger | null
    • request_countsobject

      Accepted lines only; rejected lines are in errors.

      request_counts
      • totalinteger
      • completedinteger
      • failedinteger
    • metadataobject | null
  • 401

    The key is missing, malformed, expired or revoked.

    Response
    • errorobject
      error
      • messagestring

        What went wrong and how to fix it.

      • typestring

        For example invalid_request_error, authentication_error, permission_error, rate_limit_error, insufficient_quota, api_error.

      • codestring

        The stable error code.

      • paramstring | null

        The request field at fault, when there is one.

      • refusal_reasonenum

        Present only on code: refusal.

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 404

    No such resource for this key.

    Response
    • errorobject
      error
      • messagestring

        What went wrong and how to fix it.

      • typestring

        For example invalid_request_error, authentication_error, permission_error, rate_limit_error, insufficient_quota, api_error.

      • codestring

        The stable error code.

      • paramstring | null

        The request field at fault, when there is one.

      • refusal_reasonenum

        Present only on code: refusal.

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 409

    This batch's provider does not support cancellation.

    Response
    • errorobject
      error
      • messagestring

        What went wrong and how to fix it.

      • typestring

        For example invalid_request_error, authentication_error, permission_error, rate_limit_error, insufficient_quota, api_error.

      • codestring

        The stable error code.

      • paramstring | null

        The request field at fault, when there is one.

      • refusal_reasonenum

        Present only on code: refusal.

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"

Request

curl -X POST https://api.experientiallabs.ai/v1/batches/batch_9c2e4b7a1f0d3e6c5b8a2d4f/cancel \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

{
  "id": "batch_9c2e4b7a1f0d3e6c5b8a2d4f",
  "object": "batch",
  "endpoint": "/v1/chat/completions",
  "errors": null,
  "input_file_id": "file_3f9a1c0e7b2d4a6f8e1c2b3d",
  "completion_window": "24h",
  "status": "cancelling",
  "output_file_id": null,
  "error_file_id": null,
  "created_at": 1795132800,
  "expires_at": 1795219200,
  "completed_at": null,
  "failed_at": null,
  "expired_at": null,
  "cancelled_at": null,
  "request_counts": {
    "total": 2,
    "completed": 1,
    "failed": 0
  },
  "metadata": {
    "job": "nightly"
  }
}

https://api.experientiallabs.ai/v1/batches/batch_9c2e4b7a1f0d3e6c5b8a2d4f/cancel