---
title: "Batches API: submit, track and cancel a batch of requests"
canonical: https://uncensoredllm.ai/docs/batches
generated: 2026-11-23T06:12:10.033Z
source: https://uncensoredllm.ai/docs/batches
base_url: https://api.uncensoredllm.ai/v1
---

# Batches.

Updated November 22, 2026.

A batch runs many requests asynchronously from one uploaded file and returns its results as files when it finishes, through the batches API at `https://api.uncensoredllm.ai/v1`. Every route takes a key. You upload the input file first (see the [files API](https://uncensoredllm.ai/docs/files)), submit the batch, poll its status, and read the output when it completes.

[Get a key](https://app.uncensoredllm.ai/console)

## Create a batch

`POST /v1/batches` accepts:

| Field | Notes |
| --- | --- |
| `input_file_id` | An uploaded batch input file. |
| `endpoint` | The route each line calls. |
| `completion_window` | How long the batch may take; `24h` is the one value. |
| `metadata` | Your own key and value pairs. |

The response is the batch in progress. `GET /v1/batches` lists the organization’s batches, and `GET /v1/batches/{batch_id}` returns one with its `request_counts`.

## The batch object

A batch carries `id`, `object`, `endpoint`, `input_file_id`, and a `status` that moves through validating, in_progress, finalizing and then one of completed, failed, expired or cancelled. When it finishes, `output_file_id` is set if any line answered with a success and `error_file_id` if any line failed or expired; read both through the files API. Lifecycle timestamps (`in_progress_at`, `finalizing_at`, `completed_at`, `cancelled_at` and the rest) and `request_counts` track progress, and `errors` holds any validation problems found at submission.

## Cancel

`POST /v1/batches/{batch_id}/cancel` stops a batch that is still running; it moves to cancelling and then cancelled. A batch that has already finished cannot be cancelled.

## Example

```bash
curl https://api.uncensoredllm.ai/v1/batches \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-ullm-live-…" \
  -d '{"input_file_id": "file_...", "endpoint": "/v1/chat/completions", "completion_window": "24h"}'
```

The response is the new batch with its id and starting status.

## Status codes

`200` on create, list, read and cancel. An unknown endpoint or a `completion_window` other than 24h is `400 invalid_request`. An absent or invalid key is `401 invalid_api_key`. No such input file, or no such batch in this organization, is `404 not_found`. Cancelling a batch that already finished is `409 batch_not_cancellable`.

## Batches: questions

### How do I submit a batch?

Upload a JSONL input file through the files API, then POST /v1/batches with its input_file_id and the endpoint each line should call. The batch runs asynchronously and reports progress in request_counts.

### Where do the results go?

Into files: output_file_id collects the lines that succeeded and error_file_id the lines that failed or expired, each set once the batch finishes if it has any lines. Read them through the files API.

### Can I stop a batch after it starts?

Yes, with POST /v1/batches/{batch_id}/cancel, as long as it has not already finished; a finished batch returns 409 batch_not_cancellable.

## Read next

- [MCP servers](https://uncensoredllm.ai/docs/mcp-servers)
- [Log export](https://uncensoredllm.ai/docs/exports)
- [Invoices](https://uncensoredllm.ai/docs/invoices)
- [Billing details](https://uncensoredllm.ai/docs/billing-details)
- [Statement signing key](https://uncensoredllm.ai/docs/statements-public-key)
- [Keys](https://uncensoredllm.ai/docs/keys)
- [Requests and receipts](https://uncensoredllm.ai/docs/requests)
- [Balance and spend limits](https://uncensoredllm.ai/docs/budgets)
- [Files](https://uncensoredllm.ai/docs/files)
- [Count tokens](https://uncensoredllm.ai/docs/count-tokens)
- [App usage stats](https://uncensoredllm.ai/docs/stats-apps)
- [Auth keys](https://uncensoredllm.ai/docs/auth-keys)
- [Webhook deliveries](https://uncensoredllm.ai/docs/webhooks-deliveries)
- [Docs: connect in two minutes](https://uncensoredllm.ai/docs)
