---
title: "Create batch"
method: POST
path: "/v1/batches"
---

# Create batch

`POST /v1/batches`

## Request

- Base URL: `https://api.llmgateway.io`
- URL: `https://api.llmgateway.io/v1/batches`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/llmgateway/apis/llmgateway-api/docs/v1/batches/post.ts> (a function with typed inputs; its response is checked against the schema)

Creates a batch from an uploaded JSONL file. Requests run asynchronously within 24 hours through the normal gateway path. Each request is billed at the same per-token price as a live request, priced when it runs; no batch discount is applied.

## Request body

- object
  - `input_file_id` string, required
  - `endpoint` '/v1/chat/completions' | '/v1/responses' | '/v1/embeddings', required
  - `completion_window` '24h', required
  - `metadata` object, nullable

## Response `200`

The created batch.

- Batch
  - `id` string, required
  - `object` 'batch', required
  - `endpoint` '/v1/chat/completions' | '/v1/responses' | '/v1/embeddings', required
  - `errors` object, nullable, required
    - `object` 'list', required
    - `data` object[], required
      - `code` string, required
      - `message` string, required
      - `param` string, nullable, required
      - `line` number, nullable, required
  - `input_file_id` string, required
  - `completion_window` string, required
  - `status` 'validating' | 'failed' | 'in_progress' | 'finalizing' | 'completed' | 'expired' | 'cancelling' | 'cancelled', required
  - `output_file_id` string, nullable, required
  - `error_file_id` string, nullable, required
  - `created_at` number, required
  - `in_progress_at` number, nullable, required
  - `expires_at` number, nullable, required
  - `finalizing_at` number, nullable, required
  - `completed_at` number, nullable, required
  - `failed_at` number, nullable, required
  - `expired_at` number, nullable, required
  - `cancelling_at` number, nullable, required
  - `cancelled_at` number, nullable, required
  - `request_counts` object, required
    - `total` number, required
    - `completed` number, required
    - `failed` number, required
  - `metadata` object, nullable, required

## Other responses

- `400`: Invalid request body or parameters.
- `401`: Missing or invalid API key.
- `402`: Insufficient credits or plan limits reached.
- `403`: Forbidden request or upstream response.
- `404`: Unknown model or upstream not-found response.
- `408`: Request timeout.
- `410`: Archived or unavailable project.
- `413`: Request too large.
- `415`: Unsupported media type.
- `429`: Rate limited. Response headers describe only LLMGateway-enforced limits; upstream provider headers are not forwarded. Honor Retry-After when present.
- `500`: Internal server error.
- `502`: Failed to connect to the upstream provider.
- `503`: Service unavailable upstream response.
- `504`: Upstream provider timeout.
- `529`: Gateway overloaded.

## Changes

- **2026-11-09** `a91f6c173982`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/llmgateway/apis/llmgateway-api/changes/v1/batches/post.md)

---

[API](https://skmtc.dev/llmgateway/apis/llmgateway-api.md) - [All operations](https://skmtc.dev/llmgateway/apis/llmgateway-api/llms.txt) - [OpenAPI document](https://skmtc.dev/llmgateway/apis/llmgateway-api/revisions/a91f6c173982?raw)
