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

# Batch API

> Run Chat Completions, Responses, and native Anthropic Message Batches asynchronously

## Overview

The NanoGPT Batch API runs many independent requests asynchronously. Models with a discounted native batch route retain that discount; other models use normal per-request pricing. It is a good fit for classification, summarization, evals, synthetic data, document processing, and image analysis where immediate results are not required.

Choose a workflow:

* **File-backed API:** upload JSONL, create a batch, poll its status, then download output and error files. This OpenAI-compatible workflow is best for large or reusable inputs.
* **Inline API:** send the requests in the batch creation body and receive the results when polling the completed batch. This is simpler for smaller jobs.
* **[Anthropic Message Batches](#anthropic-message-batches):** send native Claude requests with the official Anthropic SDK or HTTP API. Requests run directly through Anthropic at batch token rates, with native JSONL results.

The file-backed and inline workflows support rows targeting `/v1/chat/completions`, `/v1/responses`, or `/v1/embeddings`. Native Message Batches use a separate `/v1/messages/batches` endpoint.

> [!NOTE]
>
> All rows in one batch must use the same endpoint and the same model. Batch requests are non-streaming and the only supported completion window is `24h`.

## Authentication and base URLs

All requests require an API key:

```http theme={null}
Authorization: Bearer $NANOGPT_API_KEY
```

Use the dedicated API host for batch operations:

| Workflow | Base URL |
| - | - |
| File-backed | `https://api.nano-gpt.com/api/v1` |
| Inline | `https://api.nano-gpt.com/api/beta` |
| Anthropic SDK | `https://api.nano-gpt.com/api` (the SDK appends `/v1/messages/batches`) |

Use `api.nano-gpt.com` for uploads. The main website host can reject larger multipart requests before they reach the Batch API.

## Supported row endpoints

Each row in a file-backed or inline batch must target one of these endpoints:

* `/v1/chat/completions`
* `/v1/responses`
* `/v1/embeddings`

Completions, image generation, audio, video, transcription, TTS, moderation, and other endpoints cannot be used as batch rows. For native Anthropic request bodies, use [Message Batches](#anthropic-message-batches); `/v1/messages` is not a supported row endpoint for `/api/v1/batches`.

## Model support

### Chat Completions batches

`/v1/chat/completions` batches support all normal chat models available through the NanoGPT API. Submit the canonical NanoGPT model slug; routing is handled automatically.

Models with a supported native batch route keep that route and its discount. Other models run asynchronously through normal chat routing within the `24h` completion window, at the normal per-request price. Managed rows accept the request's `provider` field, `tools`, and `response_format`. They do not accept NanoGPT add-ons such as web search, scraping, memory, characters, or BYOK, and every token limit they set must be greater than 0. Native batch routes may reject `tools`, `functions`, `response_format`, and `structured_outputs`.

TEE, private-execution, and zero-retention models cannot be used in batches because batch processing stores inputs. API keys and teams requiring Zero Data Retention cannot create batches either. Decisions models remain on their own [Decisions endpoint](https://docs.nano-gpt.com/api-reference/endpoint/decisions.md) and are not batch chat models.

The `:thinking` suffix is accepted where a thinking variant is configured. Claude thinking aliases are also accepted for compatible models; a numeric thinking budget must be lower than `max_tokens`.

For the live list, call [`GET /api/v1/models?detailed=true`](https://docs.nano-gpt.com/api-reference/endpoint/models) and select models whose `supported_batch_endpoints` include `/v1/chat/completions`.

Model availability changes. Validate a small batch before submitting a large job; an unsupported model returns an `unsupported_model` error.

### Responses batches

`/v1/responses` batches currently support direct OpenAI models only. The `openai/` prefix is accepted. `gpt-5.2-pro` and `gpt-5.4-pro`, including dated snapshots, are not available through the upstream Responses Batch API and are rejected.

Responses rows support function and custom tools, structured text output, and remote or data-URL image inputs. Provider-hosted tools and stateful Responses features are not supported in batches.

### Embeddings batches

`/v1/embeddings` batches support `text-embedding-3-small`, `text-embedding-3-large`, and `text-embedding-ada-002`. The `openai/` prefix is accepted. Other embedding models return an `unsupported_model` error that names the supported models.

For the live list, call `GET /api/v1/embedding-models` and select models whose `supported_batch_endpoints` include `/v1/embeddings`.

Embedding batches with content moderation accept at most 10,000 rows, though a row can hold several inputs.

Embedding inputs are checked by the same content moderation as other OpenAI-model batches. One flagged line rejects the whole batch with a 400 that names the lines. Zero Data Retention keys and teams, and EU inference keys, cannot create batches. An API key's model and provider allowlists also apply: a key whose allowlist does not permit these models, or the provider that serves them, gets a 403.

## File-backed API

### Endpoints

* `POST /files`
* `GET /files`
* `GET /files/{file_id}`
* `GET /files/{file_id}/content`
* `DELETE /files/{file_id}`
* `POST /batches`
* `GET /batches`
* `GET /batches/{batch_id}`
* `POST /batches/{batch_id}/cancel`
* `DELETE /batches/{batch_id}`

### JSONL rules

Each non-empty line must be a JSON object with:

* a unique, non-empty `custom_id`
* `method: "POST"`
* `url` set to `/v1/chat/completions`, `/v1/responses`, or `/v1/embeddings`
* a `body` object containing the model and endpoint-specific input

All rows must use the same endpoint and model. `stream: true` is rejected.

Chat Completions rows require a non-empty `messages` array and a positive `max_tokens` or `max_completion_tokens`. They support text and compatible `image_url` content. Image URLs may use HTTP, HTTPS, or base64 data URLs for PNG, JPEG, GIF, and WebP images.

For Gemini models, NanoGPT downloads each HTTP or HTTPS image link when the file is uploaded and stores the image in the batch file, so the model never fetches the link itself. A link must reach a public PNG, JPEG, GIF, or WebP image of at most 30 MB; a web page, another file type, or a private address is refused with `media_url_not_fetchable` and the line number. The image's own bytes decide its type, so an image served as a generic download works. Images larger than 3,072 pixels on a side are scaled down, and one still over 5 MB is re-encoded as JPEG. One file can link up to 1,000 different images, and all of them must download within about 75 seconds, so send larger sets as several files or as base64 data URLs. Stored images count toward the 200 MiB file limit.

### YouTube videos with Gemini

Batches for `google/gemini-3.8-flash`, `google/gemini-3.7-flash`, `google/gemini-3.5-flash`, `google/gemini-3-flash-preview`, and `google/gemini-3.1-pro-preview` also accept public YouTube links as `video_url` parts in user messages:

```jsonl theme={null}
{"custom_id":"video-1","method":"POST","url":"/v1/chat/completions","body":{"model":"google/gemini-3.8-flash","messages":[{"role":"user","content":[{"type":"text","text":"Summarize this video in one sentence."},{"type":"video_url","video_url":{"url":"https://www.youtube.com/watch?v=jNQXAC9IVRw"}}]}],"max_tokens":256}}
```

Links must use HTTPS and point at a public video: watch, `youtu.be`, Shorts, live, and embed links work. Each request can link up to two videos. Other video sources, `start_offset` and `end_offset`, and YouTube links sent as `image_url` are rejected.

Gemini's batch upstreams can't read YouTube links, so when any row in a batch has one, every row in that batch runs through NanoGPT's normal routing, like other managed rows. These rows cost the same as synchronous requests, without the 50% batch discount. A video's length isn't known until the model reads it, so each video row reserves the model's full input limit of 1,048,576 tokens at creation. The unused part of the reservation is released when the batch settles.

Responses rows require a non-empty `input` and an integer `max_output_tokens` of at least `16`.

Embeddings rows require `model` and `input`, and take no output cap. `input` is a string or an array of up to 2,048 strings; token arrays and multimodal input are rejected. Rows may also set `dimensions` (`text-embedding-3-small` and `text-embedding-3-large` only), `encoding_format` (`float` or `base64`), and `user`. NanoGPT does not forward `user`. Any other field is rejected.

Each input can be at most 8,191 tokens, and each row at most 300,000 tokens. One batch can hold at most 50,000 inputs across all of its rows.

Embedding results are much larger than their input, and result files can be at most 200 MiB. NanoGPT estimates the size at upload and rejects a batch that would not fit with an `embedding_result_too_large` error. At full size, that is about 5,600 inputs per batch with `text-embedding-3-small` or `text-embedding-ada-002` and about 2,800 with `text-embedding-3-large`. To fit more, use `encoding_format: "base64"`, which makes results about 4.5 times smaller, or request fewer `dimensions`, or split the job into several batches.

### Chat Completions example

```jsonl theme={null}
{"custom_id":"request-1","method":"POST","url":"/v1/chat/completions","body":{"model":"gpt-4.1-mini","messages":[{"role":"user","content":"Summarize this in one sentence: Batch APIs are useful for offline jobs."}],"max_tokens":64}}
{"custom_id":"request-2","method":"POST","url":"/v1/chat/completions","body":{"model":"gpt-4.1-mini","messages":[{"role":"user","content":"Classify this review as positive or negative: I loved the product."}],"max_tokens":16}}
```

### Responses example

```jsonl theme={null}
{"custom_id":"response-1","method":"POST","url":"/v1/responses","body":{"model":"gpt-4.1-mini","input":"Extract three keywords from: Batch APIs process independent prompts asynchronously.","max_output_tokens":64}}
{"custom_id":"response-2","method":"POST","url":"/v1/responses","body":{"model":"gpt-4.1-mini","input":"Reply with a JSON object containing a one-sentence summary.","text":{"format":{"type":"json_schema","name":"summary","strict":true,"schema":{"type":"object","properties":{"summary":{"type":"string"}},"required":["summary"],"additionalProperties":false}}},"max_output_tokens":128}}
```

### Embeddings example

```jsonl theme={null}
{"custom_id":"doc-1","method":"POST","url":"/v1/embeddings","body":{"model":"text-embedding-3-small","input":"Batch APIs process independent requests asynchronously."}}
{"custom_id":"doc-2","method":"POST","url":"/v1/embeddings","body":{"model":"text-embedding-3-small","input":["First passage.","Second passage."],"dimensions":512,"encoding_format":"base64"}}
```

Each successful output row holds a standard embeddings response in `response.body`. Match rows by `custom_id`, and use each item's `index` to match vectors to the strings in that row's `input`.

```json theme={null}
{"id":"batch_req_abc","custom_id":"doc-1","response":{"status_code":200,"request_id":"req_abc","body":{"object":"list","data":[{"object":"embedding","index":0,"embedding":[0.0023,-0.0093]}],"model":"text-embedding-3-small","usage":{"prompt_tokens":8,"total_tokens":8}}},"error":null}
```

### Upload the file

```bash theme={null}
curl https://api.nano-gpt.com/api/v1/files \
  -H "Authorization: Bearer $NANOGPT_API_KEY" \
  -F purpose=batch \
  -F file=@batch.jsonl
```

### Create the batch

Set `endpoint` to the same endpoint used by every JSONL row:

```bash theme={null}
curl https://api.nano-gpt.com/api/v1/batches \
  -H "Authorization: Bearer $NANOGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input_file_id": "file_abc123",
    "endpoint": "/v1/responses",
    "completion_window": "24h"
  }'
```

### Poll, cancel, and download

```bash theme={null}
# Retrieve one batch
curl https://api.nano-gpt.com/api/v1/batches/batch_abc123 \
  -H "Authorization: Bearer $NANOGPT_API_KEY"

# Best-effort cancellation
curl -X POST https://api.nano-gpt.com/api/v1/batches/batch_abc123/cancel \
  -H "Authorization: Bearer $NANOGPT_API_KEY"

# Download JSONL output
curl https://api.nano-gpt.com/api/v1/files/file_output123/content \
  -H "Authorization: Bearer $NANOGPT_API_KEY"
```

Batch statuses are `validating`, `in_progress`, `finalizing`, `completed`, `failed`, `expired`, `cancelling`, and `cancelled`. A completed batch normally has an `output_file_id`; row failures may also produce an `error_file_id`.

### Delete a finished batch

```bash theme={null}
curl -X DELETE https://api.nano-gpt.com/api/v1/batches/batch_abc123 \
  -H "Authorization: Bearer $NANOGPT_API_KEY"
```

You can delete a `completed`, `failed`, `expired` or `cancelled` batch once its charge has settled. It then no longer appears in retrieve, list or cancel. Deleting doesn't change billing: the charge and usage records stay. The batch's input, output and error files stay until you delete them with `DELETE /files/{file_id}`. NanoGPT also deletes the provider's copies of the batch input and results once it has verified its own stored copy.

The response reports NanoGPT's side (`deleted`) and the provider's (`upstream_deletion`) separately:

```json theme={null}
{
  "id": "batch_abc123",
  "object": "batch.deleted",
  "deleted": true,
  "upstream_deletion": { "status": "deleted" }
}
```

| HTTP | `upstream_deletion.status` | Meaning |
| - | - | - |
| 200 | `deleted` | The provider confirmed deleting its copies |
| 200 | `not_needed` | The provider held no copy |
| 200 | `retained` | The provider keeps a copy that NanoGPT doesn't delete automatically; `reason` says why. This answer is final |
| 503 | `pending` | Deleted on NanoGPT, but the provider hasn't confirmed its delete yet. The body adds an `error` with code `upstream_delete_pending`, and a `Retry-After` header is set. NanoGPT keeps retrying; repeat the request to check |

Repeating the request on a deleted batch reports the provider's current state. Other errors:

* `409` `batch_not_finished`: the batch is still running. Cancel it and wait until it is `cancelled`.
* `409` `batch_settling`: the charge is still settling. Retry after `Retry-After`.
* `409` `batch_changed`: the batch changed during the request. Retry.
* `400` `inline_batch_delete_unsupported`: inline batches can't be deleted with this route.
* `400` `message_batch_delete_endpoint`: native Message Batches use `DELETE /api/v1/messages/batches/{id}`.

### List and delete files

Uploaded input files count toward a staged storage allowance of 1 GiB and 100 files per API key until a batch starts from them. An upload that would exceed it returns `429` with `batch_file_storage_quota_exceeded` and the space in use. Delete input files you no longer need, and output or error files you have downloaded:

```bash theme={null}
# List files, newest first (purpose, limit 1-10000, order asc|desc, after=<last_id>)
curl "https://api.nano-gpt.com/api/v1/files?purpose=batch&limit=100" \
  -H "Authorization: Bearer $NANOGPT_API_KEY"

# Delete a file
curl -X DELETE https://api.nano-gpt.com/api/v1/files/file_abc123 \
  -H "Authorization: Bearer $NANOGPT_API_KEY"
```

The list follows the OpenAI format (`object`, `data`, `first_id`, `last_id`, `has_more`), so `client.files.list()` and `client.files.delete()` in the OpenAI SDKs work with these routes. Deletion returns `{"id": "file_abc123", "object": "file", "deleted": true}` and removes the file's stored content; batches keep the file ID, but the file can no longer be retrieved, downloaded, or used to create a batch. A file used by a batch that is still running or settling returns `409` with `file_in_use`; retry after the batch finishes, or cancel it first. Files of inline batches and native Message Batches stay with their batch and also return `409`.

## Inline API

Inline batches accept up to 10,000 requests, 20 MiB of normalized input, and 250,000 aggregate requested output tokens. Embeddings batches have no output tokens; their estimated results must instead fit in 50 MiB, or about 1,400 inputs at full size with `text-embedding-3-small`, and more with `encoding_format: "base64"` or fewer `dimensions`. Use the file-backed API for larger inputs.

### Endpoints

* `POST /batches`
* `GET /batches`
* `GET /batches/{batch_id}`
* `POST /batches/{batch_id}/cancel`

All inline routes use the `https://api.nano-gpt.com/api/beta` base URL.

### Create an inline batch

```bash theme={null}
curl https://api.nano-gpt.com/api/beta/batches \
  -H "Authorization: Bearer $NANOGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "/v1/responses",
    "model": "gpt-4.1-mini",
    "requests": [
      {
        "custom_id": "response-1",
        "body": { "input": "Summarize this text in one sentence." }
      }
    ]
  }'
```

Creation returns `202 Accepted`. Poll `GET /api/beta/batches/{batch_id}` and read `results` after completion. Cancel an active job with `POST /api/beta/batches/{batch_id}/cancel`.

The batch-level model is inherited by every request body. If an inline row omits its endpoint-specific output cap, NanoGPT applies a 4096-token default. File-backed rows must always include the output cap explicitly. Embeddings rows have no output cap, so no default is applied.

```bash theme={null}
curl https://api.nano-gpt.com/api/beta/batches \
  -H "Authorization: Bearer $NANOGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "/v1/embeddings",
    "model": "text-embedding-3-small",
    "requests": [
      { "custom_id": "doc-1", "body": { "input": "First passage." } },
      { "custom_id": "doc-2", "body": { "input": ["Second passage.", "Third passage."] } }
    ]
  }'
```

## List batches

Use the authenticated list route for the workflow you want to inspect. Each route returns only batches visible to the supplied API key, ordered newest first. Native Message Batches have their own [list route and cursor names](#list-native-message-batches).

| Workflow | Endpoint |
| - | - |
| Inline | `GET https://api.nano-gpt.com/api/beta/batches` |
| All batches (OpenAI-compatible) | `GET https://api.nano-gpt.com/api/v1/batches` |

Both routes support the same filters and bidirectional cursor pagination:

| Parameter | Description |
| - | - |
| `limit` | Page size from 1 to 100. Defaults to 20. |
| `after` | Return the next page of batches older than this batch ID. Pass the current page's `last_id`. |
| `before` | Return the adjacent page of batches newer than this batch ID, still ordered newest first. Pass the current page's `first_id`. |
| `status` | Filter by one or more statuses. Repeat the parameter or provide comma-separated values. |
| `created_after` | Return batches created strictly after this boundary. |
| `created_before` | Return batches created strictly before this boundary. |

`after` and `before` cannot be combined. Cursors are batch IDs, not arbitrary tokens. Creation boundaries accept Unix timestamps in seconds or timezone-qualified ISO 8601/RFC 3339 timestamps with no more than millisecond precision.

Supported status values are `validating`, `in_progress`, `finalizing`, `completed`, `failed`, `expired`, `cancelling`, and `cancelled`.

### Filter inline batches

```bash theme={null}
curl "https://api.nano-gpt.com/api/beta/batches?limit=20&status=in_progress,completed" \
  -H "Authorization: Bearer $NANOGPT_API_KEY"
```

You can also filter by a strict creation-time range:

```bash theme={null}
curl "https://api.nano-gpt.com/api/beta/batches?created_after=2026-09-01T00:00:00Z&created_before=2026-09-02T00:00:00Z" \
  -H "Authorization: Bearer $NANOGPT_API_KEY"
```

### Filter all batches

```bash theme={null}
curl "https://api.nano-gpt.com/api/v1/batches?limit=50&status=failed&created_after=1788192000" \
  -H "Authorization: Bearer $NANOGPT_API_KEY"
```

### Response and pagination

Both endpoints return the standard list envelope:

```json theme={null}
{
  "object": "list",
  "data": [],
  "first_id": null,
  "last_id": null,
  "has_more": false
}
```

* `data` is always ordered newest first.
* `first_id` and `last_id` are `null` for an empty page.
* To fetch older batches, send `after=<last_id>` with the same filters.
* To return to the adjacent newer page, send `before=<first_id>` with the same filters.
* `has_more` indicates that more records exist in the direction being paged.

For example:

```bash theme={null}
# Fetch the next, older page
curl "https://api.nano-gpt.com/api/v1/batches?limit=20&status=completed&after=batch_older_cursor" \
  -H "Authorization: Bearer $NANOGPT_API_KEY"

# Return to the adjacent newer page
curl "https://api.nano-gpt.com/api/v1/batches?limit=20&status=completed&before=batch_newer_cursor" \
  -H "Authorization: Bearer $NANOGPT_API_KEY"
```

> [!WARNING]
>
> Inline list responses contain metadata only. `results` is always `null`, including for completed batches. Retrieve `GET /api/beta/batches/{batch_id}` to obtain a completed inline batch's results.

Inline list items include `id`, `object`, `endpoint`, `model`, `completion_window`, `status`, `created_at`, `finalized_at`, `request_counts`, `usage`, `error`, and a `results` field that is always `null`.

The OpenAI-compatible list includes both inline and file-backed jobs. Its items retain the standard batch shape, including `input_file_id`, `output_file_id`, `error_file_id`, lifecycle timestamps, `request_counts`, `metadata`, `usage`, and `errors` where applicable.

### Listing errors

Both list routes return:

* `401` for missing or invalid authentication.
* `400` when `after` and `before` are both present.
* `400` for an unknown or inaccessible cursor. The inline-only route also rejects a cursor that identifies a non-inline batch. A cursor does not need to match the active filters; it only supplies the page boundary.
* `400` for an unsupported `status` value.
* `400` for an invalid creation timestamp or a reversed creation-time range.

## Anthropic Message Batches

Use native Anthropic request shapes for asynchronous Claude jobs, including custom tools, thinking, prompt caching, images, and documents where the selected model supports them. Submit up to 100,000 requests for one supported Claude model per batch. Requests go directly to Anthropic and use batch token pricing, paid from your NanoGPT balance.

The official Anthropic SDK works with a NanoGPT API key and `baseURL: 'https://api.nano-gpt.com/api'` (Python: `base_url`). It appends `/v1/messages/batches`. The shorter `/v1/messages/batches` alias also works with `https://api.nano-gpt.com` as the SDK base URL.

### Native endpoints

| Method | URL path | Purpose |
| - | - | - |
| POST | `/api/v1/messages/batches` | Create a batch |
| GET | `/api/v1/messages/batches` | List native Message Batches |
| GET | `/api/v1/messages/batches/{id}` | Retrieve status and request counts |
| POST | `/api/v1/messages/batches/{id}/cancel` | Request cancellation |
| GET | `/api/v1/messages/batches/{id}/results` | Download native result JSONL |
| DELETE | `/api/v1/messages/batches/{id}` | Delete an ended batch from NanoGPT's native API |

All routes also accept the `/v1/messages/batches` prefix. Authenticate with `x-api-key` or `Authorization: Bearer` using your NanoGPT API key.

### Create a native batch

Send a `requests` array containing `custom_id` and native Messages `params`. No file upload is required.

```bash theme={null}
curl https://api.nano-gpt.com/api/v1/messages/batches \
  -H "x-api-key: $NANOGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: example-anthropic-batch-001" \
  -d '{
    "requests": [{
      "custom_id": "summary-1",
      "params": {
        "model": "anthropic/claude-sonnet-5.5",
        "max_tokens": 1024,
        "messages": [{ "role": "user", "content": "Explain when batch processing is useful." }]
      }
    }]
  }'
```

Or use `@anthropic-ai/sdk`:

```ts theme={null}
import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: process.env.NANOGPT_API_KEY,
  baseURL: 'https://api.nano-gpt.com/api',
});

const batch = await client.messages.batches.create({
  requests: [{
    custom_id: 'summary-1',
    params: {
      model: 'anthropic/claude-sonnet-5.5',
      max_tokens: 1024,
      messages: [{ role: 'user', content: 'Explain when batch processing is useful.' }],
    },
  }],
}, { headers: { 'Idempotency-Key': 'example-anthropic-batch-001' } });

// Retrieve periodically until processing_status is "ended".
const current = await client.messages.batches.retrieve(batch.id);
if (current.processing_status === 'ended' && current.results_url) {
  for await (const row of await client.messages.batches.results(batch.id)) {
    console.log(row.custom_id, row.result);
  }
}
```

Choose a new `Idempotency-Key` for each distinct batch. Reuse the same key and body when retrying a submission; a different payload with the same key returns 409. A stored creation failure can also be replayed, so use a new key for a new submission after correcting that failure. The header is optional, but recommended for retries.

### Native request limits and compatibility

* Send 1–100,000 requests with unique, non-empty `custom_id` values.
* Use the same supported Claude model for every request. Thinking controls may vary by request. Support for a model on synchronous `/v1/messages` does not imply native batch support.
* Haiku 5.5 accepts `anthropic/claude-haiku-5.5`, `claude-haiku-5-5`, and `anthropic/claude-haiku-latest`. Use `thinking: { "type": "adaptive" }` with `output_config: { "effort": "medium" }` to set its default thinking behavior explicitly; fixed `budget_tokens` controls are unsupported by Haiku 5.5.
* Haiku 5.5 also accepts `thinking: { "type": "disabled" }` at `low`, `medium`, or `high` effort. Disabled thinking with `xhigh` or `max` is rejected.
* Each `params` requires `model`, `messages`, and a positive integer `max_tokens` within the model's output limit. NanoGPT's maximum accepted cap is 1,000,000; model limits can be lower. The first message must have the `user` role; use the top-level `system` field for a system prompt.
* The request body and stored normalized input must each fit within 200 MiB. Normalization can make the stored input larger than the original body.
* The completion window is 24 hours. Streaming generation is unsupported; result downloads use JSONL.
* Native custom tools and tool-result history, thinking, `output_config`, and prompt-cache controls are supported where the selected model supports them. Use native `thinking` controls, not OpenAI `reasoning` or `reasoning_effort` fields.
* Images accept URL or base64 sources; documents accept URL, base64, or plaintext sources. Provider-managed file references, containers, MCP servers, hosted tools, and video blocks are rejected.
* URL or base64 documents reserve enough balance for a full context window because their token count is unknown before processing. Final billing still uses actual token usage.
* Caller `anthropic-beta` flags are forwarded alongside any flags required by the request. A beta header does not enable fields rejected by NanoGPT's batch validation.
* Keys or teams requiring Zero Data Retention cannot create batches because batch processing retains input.

Native Message Batches use the official Anthropic SDK. NanoGPT's general-purpose SDKs do not expose these batch methods.

### Native status, results, cancellation, and deletion

Creation returns a `message_batch` object. Poll retrieval until `processing_status` is `ended`; the other states are `in_progress` and `canceling`. An ended batch can contain unsuccessful requests, so inspect `request_counts` and each result:

* `request_counts` contains `processing`, `succeeded`, `errored`, `canceled`, and `expired`.
* `results_url` is available when results can be downloaded. Results are native JSONL rows with `custom_id` and `result`; match by `custom_id` and inspect `result.type`, rather than assuming input order or success.
* Results requested before they are available return 409. Download available results before provider archival; an ended status alone does not guarantee results remain available.
* Cancellation is best-effort. Requests that complete can still incur usage charges.
* Delete only after processing ends. Deletion hides the batch from NanoGPT's native API; it does not reverse billing or promise deletion of Anthropic's retained data.

### List native Message Batches

`GET /api/v1/messages/batches` returns native batches visible to the supplied API key, newest first, with `data`, `has_more`, `first_id`, and `last_id`.

Use `limit` from 1 to 100 (default 20), `after_id=<last_id>` for older batches, or `before_id=<first_id>` for newer batches. Do not combine both cursor parameters. Use the native list for native Message Batches; the `/api/v1/batches` list uses the OpenAI-compatible representation.

## Responses Batch restrictions

Responses Batch is stateless and executes directly through the upstream batch service. NanoGPT forces `store: false` and rejects:

* `previous_response_id`, `conversation`, and `background: true`
* `context_management` and `compaction` or `compaction_trigger` input items
* reusable `prompt` references
* `input_file`, `item_reference`, video inputs, and `input_image.file_id`
* provider-hosted tools; function and custom tools remain supported
* NanoGPT-only features such as Advisor, memory, scraping, retention overrides, provider or BYOK controls, caching controls, and billing overrides

Remote HTTP(S) image URLs and image data URLs are accepted. Structured output through the Responses `text.format` field is supported.

## Billing

Batch jobs use NanoGPT account balance and do not use subscription included tokens. At creation, NanoGPT checks the balance against a conservative maximum-liability estimate based on the input and output caps. Completed usage is charged once after the batch reaches a terminal state. If there is no billable usage, no usage charge is created.

* **Text models with discounted native batch support:** retain their native batch discount. Non-token charges, where supported, keep their normal rate.
* **Other normal chat models:** each completed row uses normal per-request pricing through normal routing. Discounts do not reduce a request below its processing cost. Failed and refundable requests are not charged. Completed requests are charged exactly once, and unused reservations are refunded after settlement. If charge evidence is incomplete, settlement waits for verification rather than estimating a charge or releasing the hold.
* **Embedding models:** input tokens are priced 50% below the synchronous embedding price: $0.01, $0.065, and $0.05 per million tokens for `text-embedding-3-small`, `text-embedding-3-large`, and `text-embedding-ada-002`. There are no output tokens. At creation, NanoGPT holds the estimated input cost plus 20%, with a $0.0001 minimum, then charges the tokens reported for successful rows. Failed rows are not charged.

Each model page shows its Batch API price. Use the live pricing page or pricing API as the source of truth.

## Common errors

* **Unsupported endpoint:** file-backed and inline rows must use `/v1/chat/completions`, `/v1/responses`, or `/v1/embeddings`, consistently across all rows. Native Claude requests use `/v1/messages/batches`.
* **Missing output cap:** add `max_tokens` or `max_completion_tokens` for Chat Completions, or `max_output_tokens >= 16` for Responses.
* **Mixed model:** every row must use the same model.
* **Streaming unsupported:** remove `stream: true`.
* **Unsupported Responses model:** choose a direct OpenAI model supported by the upstream Batch API.
* **Unsupported Responses field:** remove stateful features, provider-hosted tools, file references, or NanoGPT-only extensions.
* **Unsupported embeddings input:** `input` must be a string or an array of strings. Token arrays and multimodal input return `unsupported_input_format`.
* **Embedding results too large:** `embedding_result_too_large` (file-backed) or `inline_result_too_large` (inline). Use `encoding_format: "base64"`, fewer `dimensions`, or smaller batches.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.