Batch

Asks the provider to stop a batch that is still running. Cancellation is enabled per organization; other organizations get 403. The response is the batch in its current status: it stays in_progress until the provider confirms, then becomes cancelled, or completed, failed, or expired when the provider job ended first. Poll until the batch has any final status. Repeating the call is safe while the batch is still in_progress; once it has a final status the call returns 409. On OpenAI a cancelled batch keeps the requests that finished before the cancellation when OpenAI returns them: they are in results and billed like the rows of a completed batch. On every other provider OpenRouter returns no result rows for a cancelled batch, and the provider still charges for the requests that finished. When the batch wrote its output to your own storage, retrieving the batch can still return that location, and the rows the provider wrote there stay yours to read. See the Batch API Quickstart.

post/batches/{id}/cancel

Request

  • Base URL
    https://openrouter.ai/api/v1
  • Auth
    HTTP bearer

Path parameters

id, string required

The batch job id returned from submit.

Example:batch_abc123

Response

The provider accepted the cancellation, or the provider job had already ended while OpenRouter still stores the batch as running. Poll the batch for its final status.

BatchObject required
completion_window, '24h' required
created_at, integer required
endpoint, string required
error, object nullable required
expires_at, integer nullable required

Unix timestamp after which the assigned provider no longer completes unfinished requests. Derived from the provider's documented batch window, so it can exceed created_at plus completion_window (Google Vertex can take up to 96 hours). null when the provider documents no hard expiry.

finalized_at, integer nullable required
id, string required
model, string required
object, 'batch' required
output, BatchOutputReference

The output location of a batch submitted with input, whose results are null. Returned only by GET /batches/{id}, once the batch has ended and the provider reported an output folder or table. Batch lists and responses for a batch with an unpaid charge leave it out.

provider, string nullable required

Provider OpenRouter assigned to run the batch, using the same name as the provider field of sync responses.

request_counts, object required
results, BatchResult[] nullable required
status, 'validating' | 'in_progress' | 'finalizing' | 'completed' | 'failed' | 'expired' | 'cancelling' | 'cancelled' required
usage, object nullable required

Example response

{
  "output": {
    "uri": "gs://my-bucket/openrouter-batch/output/org_abc/batch_123/batch_123/prediction-model-2026-01-01T00:00:00.000000Z"
  },
  "results": [
    {
      "error": {
        "error_type": "rate_limit_exceeded"
      },
      "response": {
        "body": {
          "alignment": {
            "calls": [
              {
                "call": 1,
                "outcome": "allowed",
                "rules": [
                  {
                    "applicable": true,
                    "broken": false,
                    "probability": 0.04
                  }
                ]
              }
            ]
          },
          "choices": [
            {
              "finish_reason": "stop",
              "message": {
                "annotations": [
                  {
                    "file": {
                      "content": [
                        {
                          "text": "Quarterly revenue grew 12%.",
                          "type": "text"
                        }
                      ],
                      "hash": "abc123",
                      "name": "report.pdf"
                    },
                    "type": "file"
                  }
                ],
                "reasoning_details": [
                  {
                    "summary": "The model analyzed the problem by first identifying key constraints, then evaluating possible solutions...",
                    "type": "reasoning.summary"
                  }
                ]
              }
            }
          ],
          "openrouter_metadata": {
            "attempt": 1,
            "endpoints": {
              "available": [
                {
                  "model": "openai/gpt-4o",
                  "provider": "OpenAI",
                  "selected": true
                }
              ],
              "total": 1
            },
            "generation_time": 2016,
            "is_byok": false,
            "region": "iad",
            "requested": "openai/gpt-4o",
            "strategy": "direct",
            "summary": "available=1, selected=OpenAI"
          },
          "safeguard_results": [
            {
              "status": {
                "tool_uses": {
                  "call_abc": {
                    "explanation": "[Data Exfiltration]",
                    "outcome": "flagged",
                    "type": "evaluated"
                  },
                  "call_def": {
                    "outcome": "not_flagged",
                    "type": "evaluated"
                  }
                },
                "type": "available"
              },
              "type": "dangerous_tool_use"
            }
          ]
        }
      }
    }
  ],
  "usage": {
    "cache_creation": {
      "ephemeral_1h_input_tokens": 0,
      "ephemeral_5m_input_tokens": 100
    },
    "cost_details": {
      "upstream_inference_completions_cost": 0.0004,
      "upstream_inference_cost": null,
      "upstream_inference_prompt_cost": 0.0008
    },
    "iterations": [
      {
        "cache_creation": null,
        "cache_creation_input_tokens": 0,
        "cache_read_input_tokens": 0,
        "input_tokens": 50,
        "output_tokens": 25,
        "type": "compaction"
      }
    ],
    "speed": "standard"
  }
}

Changes