batches
Creates, updates, deletes, gets or lists a batches resource.
Overview​
| Name | batches |
| Type | Resource |
| Id | openai.batches.batches |
Fields​
The following fields are returned by SELECT queries:
- get
- list
Batch retrieved successfully.
| Name | Datatype | Description |
|---|---|---|
id | string | |
error_file_id | string | The ID of the file containing the outputs of requests with errors. |
input_file_id | string | The ID of the input file for the batch. |
output_file_id | string | The ID of the file containing the outputs of successfully executed requests. |
cancelled_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch was cancelled. |
cancelling_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch started cancelling. |
completed_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch was completed. |
completion_window | string | The time frame within which the batch should be processed. |
created_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch was created. |
endpoint | string | The OpenAI API endpoint used by the batch. |
errors | object | |
expired_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch expired. |
expires_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch will expire. |
failed_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch failed. |
finalizing_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch started finalizing. |
in_progress_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch started processing. |
metadata | object | Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters. (x-oaiTypeLabel: map) |
model | string | Model ID used to process the batch, like gpt-5-2025-08-07. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models. |
object | string | The object type, which is always batch. (batch) |
request_counts | object | The request counts for different statuses within the batch. |
status | string | The current status of the batch. (validating, failed, in_progress, finalizing, completed, expired, cancelling, cancelled) |
usage | object | Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used. Only populated on batches created after September 7, 2025. |
Batch listed successfully.
| Name | Datatype | Description |
|---|---|---|
id | string | |
error_file_id | string | The ID of the file containing the outputs of requests with errors. |
input_file_id | string | The ID of the input file for the batch. |
output_file_id | string | The ID of the file containing the outputs of successfully executed requests. |
cancelled_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch was cancelled. |
cancelling_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch started cancelling. |
completed_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch was completed. |
completion_window | string | The time frame within which the batch should be processed. |
created_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch was created. |
endpoint | string | The OpenAI API endpoint used by the batch. |
errors | object | |
expired_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch expired. |
expires_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch will expire. |
failed_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch failed. |
finalizing_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch started finalizing. |
in_progress_at | integer (unixtime) | The Unix timestamp (in seconds) for when the batch started processing. |
metadata | object | Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters. (x-oaiTypeLabel: map) |
model | string | Model ID used to process the batch, like gpt-5-2025-08-07. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models. |
object | string | The object type, which is always batch. (batch) |
request_counts | object | The request counts for different statuses within the batch. |
status | string | The current status of the batch. (validating, failed, in_progress, finalizing, completed, expired, cancelling, cancelled) |
usage | object | Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used. Only populated on batches created after September 7, 2025. |
Methods​
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | batch_id | openai-organization, openai-project | |
list | select | after, limit, openai-organization, openai-project | ||
create | insert | input_file_id, endpoint, completion_window | openai-organization, openai-project | |
cancel | exec | batch_id | openai-organization, openai-project |
Parameters​
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
batch_id | string | The ID of the batch to cancel. |
after | string | A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. |
limit | integer | A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. Automatically applied from a SQL LIMIT clause - SELECT ... LIMIT 10 sends limit=10 on the wire. Setting it explicitly in a WHERE clause is not required. |
openai-organization | string | Optionally scope the request to a specific organization (overrides the default associated with the API key). Addressable in SQL as openai_organization. |
openai-project | string | Optionally scope the request to a specific project (overrides the default associated with the API key). Addressable in SQL as openai_project. |
SELECT examples​
- get
- list
Batch retrieved successfully.
SELECT
id,
error_file_id,
input_file_id,
output_file_id,
cancelled_at,
cancelling_at,
completed_at,
completion_window,
created_at,
endpoint,
errors,
expired_at,
expires_at,
failed_at,
finalizing_at,
in_progress_at,
metadata,
model,
object,
request_counts,
status,
usage
FROM openai.batches.batches
WHERE batch_id = '{{ batch_id }}' -- required
AND "openai-organization" = '{{ openai-organization }}'
AND "openai-project" = '{{ openai-project }}'
;
Batch listed successfully.
SELECT
id,
error_file_id,
input_file_id,
output_file_id,
cancelled_at,
cancelling_at,
completed_at,
completion_window,
created_at,
endpoint,
errors,
expired_at,
expires_at,
failed_at,
finalizing_at,
in_progress_at,
metadata,
model,
object,
request_counts,
status,
usage
FROM openai.batches.batches
WHERE after = '{{ after }}'
AND "openai-organization" = '{{ openai-organization }}'
AND "openai-project" = '{{ openai-project }}'
;
INSERT examples​
- create
- Manifest
No description available.
INSERT INTO openai.batches.batches (
input_file_id,
endpoint,
completion_window,
metadata,
output_expires_after,
"openai-organization",
"openai-project"
)
SELECT
'{{ input_file_id }}' /* required */,
'{{ endpoint }}' /* required */,
'{{ completion_window }}' /* required */,
'{{ metadata }}',
'{{ output_expires_after }}',
'{{ openai-organization }}',
'{{ openai-project }}'
RETURNING
id,
error_file_id,
input_file_id,
output_file_id,
cancelled_at,
cancelling_at,
completed_at,
completion_window,
created_at,
endpoint,
errors,
expired_at,
expires_at,
failed_at,
finalizing_at,
in_progress_at,
metadata,
model,
object,
request_counts,
status,
usage
;
# Description fields are for documentation purposes
- name: batches
props:
- name: input_file_id
value: "{{ input_file_id }}"
description: |
The ID of an uploaded file that contains requests for the new batch.
See [upload file](https://platform.openai.com/docs/api-reference/files/create) for how to upload a file.
Your input file must be formatted as a [JSONL file](https://platform.openai.com/docs/api-reference/batch/request-input), and must be uploaded with the purpose `batch`. The file can contain up to 50,000 requests, and can be up to 200 MB in size.
- name: endpoint
value: "{{ endpoint }}"
description: |
The endpoint to be used for all requests in the batch. Currently `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, `/v1/completions`, `/v1/moderations`, `/v1/images/generations`, `/v1/images/edits`, and `/v1/videos` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.
valid_values: ['/v1/responses', '/v1/chat/completions', '/v1/embeddings', '/v1/completions', '/v1/moderations', '/v1/images/generations', '/v1/images/edits', '/v1/videos']
- name: completion_window
value: "{{ completion_window }}"
description: |
The time frame within which the batch should be processed. Currently only `24h` is supported.
valid_values: ['24h']
- name: metadata
value: "{{ metadata }}"
description: |
Set of 16 key-value pairs that can be attached to an object. This can be
useful for storing additional information about the object in a structured
format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings
with a maximum length of 512 characters.
- name: output_expires_after
description: |
The expiration policy for the output and/or error file that are generated for a batch.
value:
anchor: "{{ anchor }}"
seconds: {{ seconds }}
- name: openai-organization
value: "{{ openai-organization }}"
description: Optionally scope the request to a specific organization (overrides the default associated with the API key). Addressable in SQL as `openai_organization`.
description: Optionally scope the request to a specific organization (overrides the default associated with the API key). Addressable in SQL as `openai_organization`.
- name: openai-project
value: "{{ openai-project }}"
description: Optionally scope the request to a specific project (overrides the default associated with the API key). Addressable in SQL as `openai_project`.
description: Optionally scope the request to a specific project (overrides the default associated with the API key). Addressable in SQL as `openai_project`.
Lifecycle Methods​
- cancel
Batch is cancelling. Returns the cancelling batch's details.
EXEC openai.batches.batches.cancel
@batch_id='{{ batch_id }}' --required,
@openai-organization='{{ openai-organization }}',
@openai-project='{{ openai-project }}'
;