Batch

Creates a batch of requests that run asynchronously against a single endpoint (/v1/chat/completions, /v1/responses, /v1/messages, /v1/embeddings, /v1/audio/speech, /v1/images/generations). Returns 202 with status: "validating". Poll GET /batches/{id} for progress and results. See the Batch API Quickstart.

post/batches

Request

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

Request body

BatchSubmitBody required

Batch submit request body.

callback_url, string uri

HTTPS URL that receives a batch.completed, batch.failed, batch.cancelled or batch.expired webhook event when the batch reaches a terminal status. Must appear before requests in the request body.

completion_window, '24h'
endpoint, '/v1/chat/completions' | '/v1/responses' | '/v1/messages' | '/v1/embeddings' | '/v1/audio/speech' | '/v1/images/generations' required
input, BatchInputReference

A batch input file or table in your own storage, named in place of requests. Available to allowlisted callers on Google Vertex BYOK endpoints only.

model, string required
provider, BatchProviderPreferences nullable

Batch provider routing preferences. Only provider.only and provider.allow_fallbacks are supported.

requests, object[]

The batch requests. Send exactly one of requests or input; requests must be the last field in the request body.

Example request

{
  "input": {
    "uri": "gs://my-bucket/batches/input.jsonl"
  },
  "provider": {
    "only": [
      "google-vertex"
    ]
  }
}

Response

Batch payload durably persisted and queued for asynchronous validation and provider submission (status: "validating").

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

    • info

      added the new Celeris enum value to the request property provider/only/items/anyOf[#/components/schemas/ProviderName]

    • info

      added the new LangChain enum value to the request property provider/only/items/anyOf[#/components/schemas/ProviderName]