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

# Create Batch

> Creates an OpenAI-compatible batch job from an uploaded input file.

## Overview

This endpoint is part of TokenLab's OpenAI-compatible Batch API. Batch jobs use uploaded JSONL files, run asynchronously, and can return output/error files later.

## Notes

* Batch input files must use `purpose=batch`.
* `completion_window` is currently `24h`.
* Output ordering is not guaranteed; always match by `custom_id`.
* Streaming is not supported inside batch items.
* Supported batch item endpoints are currently `/v1/chat/completions` and `/v1/embeddings`; `/v1/responses` batch jobs are rejected until a native Responses batch executor is available.

## Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.tokenlab.sh/v1/batches" \
    -H "Authorization: Bearer sk-your-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "input_file_id": "file_abc123",
      "endpoint": "/v1/chat/completions",
      "completion_window": "24h"
    }'
  ```
</RequestExample>

## Request / Response

Use the interactive OpenAPI panel above for the exact schema.

## Operational Tips

* Use `custom_id` for idempotent downstream reconciliation.
* Expect `output_file_id` and `error_file_id` only after the worker finalizes the batch.
* Batch pricing may differ from synchronous pricing because `isBatchRequest=true` discount rules apply.

## Response example

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "id": "batch_abc123",
    "object": "batch",
    "endpoint": "/v1/chat/completions",
    "input_file_id": "file_abc123",
    "completion_window": "24h",
    "status": "validating",
    "output_file_id": null,
    "error_file_id": null,
    "created_at": 1706000000
  }
  ```
</ResponseExample>

## Important fields

<ResponseField name="id" type="string">Identifier used for follow-up calls and support.</ResponseField>
<ResponseField name="status" type="string">Current lifecycle state for this resource.</ResponseField>
<ResponseField name="output_file_id" type="string|null">File identifier used by related APIs.</ResponseField>
