Canonical: https://weaveos.com/reference/openai/retrieve-batch-results

1. [Software capabilities](https://weaveos.com/reference)
2. /[OpenAI API](https://weaveos.com/reference/openai)
3. /Retrieve OpenAI batch results

[![](https://weaveos.com/reference/logos/openai.svg)OpenAI API](https://weaveos.com/reference/openai)

# Retrieve OpenAI batch results

Poll a batch until it reaches a terminal state, then use its output\_file\_id or error\_file\_id to download JSONL results. Match each line by custom\_id instead of assuming request order.

Documentation reviewed November 27, 2026 · 3 methods with sources

## Ways to do it

1. [1API: GET /v1/batches/{batch\_id}](https://weaveos.com/reference/openai/retrieve-batch-results#method-1)
2. [2SDK: client.batches.retrieve() and client.files.content()](https://weaveos.com/reference/openai/retrieve-batch-results#method-2)
3. [3API: GET /v1/files/{file\_id}/content](https://weaveos.com/reference/openai/retrieve-batch-results#method-3)

API

### GET /v1/batches/{batch\_id}

Read batch status, request counts, output\_file\_id, and error\_file\_id before downloading results.

[Read source: OpenAI retrieve batch reference](https://developers.openai.com/api/reference/resources/batches/methods/retrieve)

- Requirements

  An OpenAI API key and the batch ID.

- Limitations

  File IDs can be null. An expired batch may still contain completed outputs, while unfinished requests appear in the error file with batch\_expired.

Example shell

Copy

```
curl --fail "https://api.openai.com/v1/batches/$OPENAI_BATCH_ID" -H "Authorization: Bearer $OPENAI_API_KEY"
```

SDK

### client.batches.retrieve() and client.files.content()

Inspect the file IDs, then read each available JSONL file with the Python SDK.

[Read source: OpenAI Batch API guide](https://developers.openai.com/api/docs/guides/batch)

- Requirements

  The openai Python package, OPENAI\_API\_KEY, and a batch ID.

- Limitations

  Use custom\_id to match lines to input requests. The API can return results in a different order.

Example text

Copy

```
import os
from openai import OpenAI

client = OpenAI()
batch = client.batches.retrieve(os.environ["OPENAI_BATCH_ID"])
for file_id in (batch.output_file_id, batch.error_file_id):
    if file_id:
        with client.files.with_streaming_response.content(file_id) as response:
            response.stream_to_file(f"{file_id}.jsonl")
```

API

### GET /v1/files/{file\_id}/content

Download the JSONL content for a completed output or error file.

[Read source: OpenAI retrieve file content reference](https://developers.openai.com/api/reference/resources/files/methods/content)

- Requirements

  An OpenAI API key and a file ID returned by the batch object.

- Limitations

  Output and error files expire 30 days after creation by default. A batch can set a shorter retention window.

Example shell

Copy

```
curl --fail "https://api.openai.com/v1/files/$OPENAI_OUTPUT_FILE_ID/content" -H "Authorization: Bearer $OPENAI_API_KEY" > batch-output.jsonl
```

[Previous OpenAI API taskSubmit a batch of Responses API requests](https://weaveos.com/reference/openai/submit-responses-batch)

## More from OpenAI API

[View all 2 OpenAI API tasks](https://weaveos.com/reference/openai)

## The same task in other apps

- [![](https://weaveos.com/reference/logos/anthropic.svg)Anthropic Claude API](https://weaveos.com/reference/anthropic)

  ### [Download Anthropic Message Batch results](https://weaveos.com/reference/anthropic/download-message-batch-results)

  After processing ends, stream the Message Batch results as JSONL. Match each line by custom\_id and check result.type for succeeded, errored, canceled, or expired before reading message content.

  API, SDK
