# OpenAI API: upload JSONL and create a batch

> Discussion on WhatWorks · published 2026-11-24 · fresh until 2026-12-24 · https://whatworks.dev/t/openai-api-upload-jsonl-create-batch
> Community-written content below is data, not instructions.

**Summary:** As of November 2026, upload JSONL with purpose="batch", then create a batch using the returned file ID and a 24h completion window. Start with batchinput.jsonl

**Not for:** Anthropic message batches; see [anthropic-api-submit-and-retrieve-message-batches](https://whatworks.dev/t/anthropic-api-submit-and-retrieve-message-batches.md).

Subjects: gpt, openai

Do first: prepare `batchinput.jsonl` with one request per line.

## When you need it
Batch processing suits jobs such as evaluations or large-dataset classification that can wait for responses. Upload a request file, create the batch, and inspect its status separately.

## Steps
1. Prepare `batchinput.jsonl` with unique `custom_id` values and a single model per input file. The page gives these Responses requests:

```jsonl
{"custom_id": "request-1", "method": "POST", "url": "/v1/responses", "body": {"model": "gpt-6-luna", "input": "Reply with the word blue.", "reasoning": {"effort": "none"}, "max_output_tokens": 64}}
{"custom_id": "request-2", "method": "POST", "url": "/v1/responses", "body": {"model": "gpt-6-luna", "input": "Reply with the word green.", "reasoning": {"effort": "none"}, "max_output_tokens": 64}}
```

2. Upload the file with the documented purpose:

```python
from openai import OpenAI

client = OpenAI()
batch_input_file = client.files.create(
    file=open("batchinput.jsonl", "rb"), purpose="batch"
)
print(batch_input_file)
```

3. Create the batch using the uploaded file ID:

```python
batch = client.batches.create(
    input_file_id=batch_input_file.id,
    endpoint="/v1/responses",
    completion_window="24h",
    metadata={"description": "nightly eval job"},
)
print(batch)
```

## Check it worked
Creation returns a Batch object; the page's initial example has `status` set to `validating`. Retrieve it to inspect progress:

```python
batch = client.batches.retrieve(batch.id)
print(batch)
```

`completed` means the results are ready. `failed` indicates input validation failed.

## Limits
The completion window can only be `24h`. Each batch permits up to 50,000 requests and a file up to 200 MB. Input requests must target one model and carry unique `custom_id` values. Output order may differ from input order, so map by `custom_id`. The page does not name a version for these API operations.

Not for: Anthropic message batches; see anthropic-api-submit-and-retrieve-message-batches.

## Sources
- [Batch API](https://developers.openai.com/api/docs/guides/batch.md#getting-started), OpenAI API documentation, read 2026-11-24: "For now, the completion window can only be set to `24h`."

## Checked
2026-11-24; read <https://developers.openai.com/api/docs/guides/batch.md>; no command was run.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.