Batches
Create batch
Batch batches().create(BatchCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /batches
Creates and executes a batch from an uploaded file of requests
Parameters
-
BatchCreateParams params-
CompletionWindow completionWindowThe time frame within which the batch should be processed. Currently only
24his supported._24H("24h")
-
Endpoint endpointThe 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/videosare supported. Note that/v1/embeddingsbatches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.-
V1_RESPONSES("/v1/responses") -
V1_CHAT_COMPLETIONS("/v1/chat/completions") -
V1_EMBEDDINGS("/v1/embeddings") -
V1_COMPLETIONS("/v1/completions") -
V1_MODERATIONS("/v1/moderations") -
V1_IMAGES_GENERATIONS("/v1/images/generations") -
V1_IMAGES_EDITS("/v1/images/edits") -
V1_VIDEOS("/v1/videos")
-
-
String inputFileIdThe ID of an uploaded file that contains requests for the new batch.
See upload file for how to upload a file.
Your input file must be formatted as a JSONL file, 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. -
Optional<Metadata> metadataSet 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.
-
Optional<OutputExpiresAfter> outputExpiresAfterThe expiration policy for the output and/or error file that are generated for a batch.
-
JsonValue; anchor "created_at"constantAnchor timestamp after which the expiration policy applies. Supported anchors:
created_at. Note that the anchor is the file creation time, not the time the batch is created.CREATED_AT("created_at")
-
long secondsThe number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).
-
-
Returns
-
class Batch:-
String id -
String completionWindowThe time frame within which the batch should be processed.
-
long createdAtThe Unix timestamp (in seconds) for when the batch was created.
-
String endpointThe OpenAI API endpoint used by the batch.
-
String inputFileIdThe ID of the input file for the batch.
-
JsonValue; object_ "batch"constantThe object type, which is always
batch.BATCH("batch")
-
Status statusThe current status of the batch.
-
VALIDATING("validating") -
FAILED("failed") -
IN_PROGRESS("in_progress") -
FINALIZING("finalizing") -
COMPLETED("completed") -
EXPIRED("expired") -
CANCELLING("cancelling") -
CANCELLED("cancelled")
-
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the batch was cancelled.
-
Optional<Long> cancellingAtThe Unix timestamp (in seconds) for when the batch started cancelling.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the batch was completed.
-
Optional<String> errorFileIdThe ID of the file containing the outputs of requests with errors.
-
Optional<Errors> errors-
Optional<List<BatchError>> data-
Optional<String> codeAn error code identifying the error type.
-
Optional<Long> lineThe line number of the input file where the error occurred, if applicable.
-
Optional<String> messageA human-readable message providing more details about the error.
-
Optional<String> paramThe name of the parameter that caused the error, if applicable.
-
-
Optional<String> object_The object type, which is always
list.
-
-
Optional<Long> expiredAtThe Unix timestamp (in seconds) for when the batch expired.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the batch will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the batch failed.
-
Optional<Long> finalizingAtThe Unix timestamp (in seconds) for when the batch started finalizing.
-
Optional<Long> inProgressAtThe Unix timestamp (in seconds) for when the batch started processing.
-
Optional<Metadata> metadataSet 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.
-
Optional<String> modelModel 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. -
Optional<String> outputFileIdThe ID of the file containing the outputs of successfully executed requests.
-
Optional<BatchRequestCounts> requestCountsThe request counts for different statuses within the batch.
-
long completedNumber of requests that have been completed successfully.
-
long failedNumber of requests that have failed.
-
long totalTotal number of requests in the batch.
-
-
Optional<BatchUsage> usageRepresents 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.
-
long inputTokensThe number of input tokens.
-
InputTokensDetails inputTokensDetailsA detailed breakdown of the input tokens.
-
long cachedTokensThe number of tokens that were retrieved from the cache. More on prompt caching.
-
-
long outputTokensThe number of output tokens.
-
OutputTokensDetails outputTokensDetailsA detailed breakdown of the output tokens.
-
long reasoningTokensThe number of reasoning tokens.
-
-
long totalTokensThe total number of tokens used.
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.batches.Batch;
import com.openai.models.batches.BatchCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
BatchCreateParams params = BatchCreateParams.builder()
.completionWindow(BatchCreateParams.CompletionWindow._24H)
.endpoint(BatchCreateParams.Endpoint.V1_RESPONSES)
.inputFileId("input_file_id")
.build();
Batch batch = client.batches().create(params);
}
}
Response
{
"id": "id",
"completion_window": "completion_window",
"created_at": 0,
"endpoint": "endpoint",
"input_file_id": "input_file_id",
"object": "batch",
"status": "validating",
"cancelled_at": 0,
"cancelling_at": 0,
"completed_at": 0,
"error_file_id": "error_file_id",
"errors": {
"data": [
{
"code": "code",
"line": 0,
"message": "message",
"param": "param"
}
],
"object": "object"
},
"expired_at": 0,
"expires_at": 0,
"failed_at": 0,
"finalizing_at": 0,
"in_progress_at": 0,
"metadata": {
"foo": "string"
},
"model": "model",
"output_file_id": "output_file_id",
"request_counts": {
"completed": 0,
"failed": 0,
"total": 0
},
"usage": {
"input_tokens": 0,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 0,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 0
}
}
Retrieve batch
Batch batches().retrieve(BatchRetrieveParamsparams = BatchRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
get /batches/{batch_id}
Retrieves a batch.
Parameters
-
BatchRetrieveParams paramsOptional<String> batchId
Returns
-
class Batch:-
String id -
String completionWindowThe time frame within which the batch should be processed.
-
long createdAtThe Unix timestamp (in seconds) for when the batch was created.
-
String endpointThe OpenAI API endpoint used by the batch.
-
String inputFileIdThe ID of the input file for the batch.
-
JsonValue; object_ "batch"constantThe object type, which is always
batch.BATCH("batch")
-
Status statusThe current status of the batch.
-
VALIDATING("validating") -
FAILED("failed") -
IN_PROGRESS("in_progress") -
FINALIZING("finalizing") -
COMPLETED("completed") -
EXPIRED("expired") -
CANCELLING("cancelling") -
CANCELLED("cancelled")
-
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the batch was cancelled.
-
Optional<Long> cancellingAtThe Unix timestamp (in seconds) for when the batch started cancelling.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the batch was completed.
-
Optional<String> errorFileIdThe ID of the file containing the outputs of requests with errors.
-
Optional<Errors> errors-
Optional<List<BatchError>> data-
Optional<String> codeAn error code identifying the error type.
-
Optional<Long> lineThe line number of the input file where the error occurred, if applicable.
-
Optional<String> messageA human-readable message providing more details about the error.
-
Optional<String> paramThe name of the parameter that caused the error, if applicable.
-
-
Optional<String> object_The object type, which is always
list.
-
-
Optional<Long> expiredAtThe Unix timestamp (in seconds) for when the batch expired.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the batch will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the batch failed.
-
Optional<Long> finalizingAtThe Unix timestamp (in seconds) for when the batch started finalizing.
-
Optional<Long> inProgressAtThe Unix timestamp (in seconds) for when the batch started processing.
-
Optional<Metadata> metadataSet 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.
-
Optional<String> modelModel 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. -
Optional<String> outputFileIdThe ID of the file containing the outputs of successfully executed requests.
-
Optional<BatchRequestCounts> requestCountsThe request counts for different statuses within the batch.
-
long completedNumber of requests that have been completed successfully.
-
long failedNumber of requests that have failed.
-
long totalTotal number of requests in the batch.
-
-
Optional<BatchUsage> usageRepresents 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.
-
long inputTokensThe number of input tokens.
-
InputTokensDetails inputTokensDetailsA detailed breakdown of the input tokens.
-
long cachedTokensThe number of tokens that were retrieved from the cache. More on prompt caching.
-
-
long outputTokensThe number of output tokens.
-
OutputTokensDetails outputTokensDetailsA detailed breakdown of the output tokens.
-
long reasoningTokensThe number of reasoning tokens.
-
-
long totalTokensThe total number of tokens used.
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.batches.Batch;
import com.openai.models.batches.BatchRetrieveParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
Batch batch = client.batches().retrieve("batch_id");
}
}
Response
{
"id": "id",
"completion_window": "completion_window",
"created_at": 0,
"endpoint": "endpoint",
"input_file_id": "input_file_id",
"object": "batch",
"status": "validating",
"cancelled_at": 0,
"cancelling_at": 0,
"completed_at": 0,
"error_file_id": "error_file_id",
"errors": {
"data": [
{
"code": "code",
"line": 0,
"message": "message",
"param": "param"
}
],
"object": "object"
},
"expired_at": 0,
"expires_at": 0,
"failed_at": 0,
"finalizing_at": 0,
"in_progress_at": 0,
"metadata": {
"foo": "string"
},
"model": "model",
"output_file_id": "output_file_id",
"request_counts": {
"completed": 0,
"failed": 0,
"total": 0
},
"usage": {
"input_tokens": 0,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 0,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 0
}
}
Cancel batch
Batch batches().cancel(BatchCancelParamsparams = BatchCancelParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
post /batches/{batch_id}/cancel
Cancels an in-progress batch. The batch will be in status cancelling for up to 10 minutes, before changing to cancelled, where it will have partial results (if any) available in the output file.
Parameters
-
BatchCancelParams paramsOptional<String> batchId
Returns
-
class Batch:-
String id -
String completionWindowThe time frame within which the batch should be processed.
-
long createdAtThe Unix timestamp (in seconds) for when the batch was created.
-
String endpointThe OpenAI API endpoint used by the batch.
-
String inputFileIdThe ID of the input file for the batch.
-
JsonValue; object_ "batch"constantThe object type, which is always
batch.BATCH("batch")
-
Status statusThe current status of the batch.
-
VALIDATING("validating") -
FAILED("failed") -
IN_PROGRESS("in_progress") -
FINALIZING("finalizing") -
COMPLETED("completed") -
EXPIRED("expired") -
CANCELLING("cancelling") -
CANCELLED("cancelled")
-
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the batch was cancelled.
-
Optional<Long> cancellingAtThe Unix timestamp (in seconds) for when the batch started cancelling.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the batch was completed.
-
Optional<String> errorFileIdThe ID of the file containing the outputs of requests with errors.
-
Optional<Errors> errors-
Optional<List<BatchError>> data-
Optional<String> codeAn error code identifying the error type.
-
Optional<Long> lineThe line number of the input file where the error occurred, if applicable.
-
Optional<String> messageA human-readable message providing more details about the error.
-
Optional<String> paramThe name of the parameter that caused the error, if applicable.
-
-
Optional<String> object_The object type, which is always
list.
-
-
Optional<Long> expiredAtThe Unix timestamp (in seconds) for when the batch expired.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the batch will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the batch failed.
-
Optional<Long> finalizingAtThe Unix timestamp (in seconds) for when the batch started finalizing.
-
Optional<Long> inProgressAtThe Unix timestamp (in seconds) for when the batch started processing.
-
Optional<Metadata> metadataSet 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.
-
Optional<String> modelModel 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. -
Optional<String> outputFileIdThe ID of the file containing the outputs of successfully executed requests.
-
Optional<BatchRequestCounts> requestCountsThe request counts for different statuses within the batch.
-
long completedNumber of requests that have been completed successfully.
-
long failedNumber of requests that have failed.
-
long totalTotal number of requests in the batch.
-
-
Optional<BatchUsage> usageRepresents 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.
-
long inputTokensThe number of input tokens.
-
InputTokensDetails inputTokensDetailsA detailed breakdown of the input tokens.
-
long cachedTokensThe number of tokens that were retrieved from the cache. More on prompt caching.
-
-
long outputTokensThe number of output tokens.
-
OutputTokensDetails outputTokensDetailsA detailed breakdown of the output tokens.
-
long reasoningTokensThe number of reasoning tokens.
-
-
long totalTokensThe total number of tokens used.
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.batches.Batch;
import com.openai.models.batches.BatchCancelParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
Batch batch = client.batches().cancel("batch_id");
}
}
Response
{
"id": "id",
"completion_window": "completion_window",
"created_at": 0,
"endpoint": "endpoint",
"input_file_id": "input_file_id",
"object": "batch",
"status": "validating",
"cancelled_at": 0,
"cancelling_at": 0,
"completed_at": 0,
"error_file_id": "error_file_id",
"errors": {
"data": [
{
"code": "code",
"line": 0,
"message": "message",
"param": "param"
}
],
"object": "object"
},
"expired_at": 0,
"expires_at": 0,
"failed_at": 0,
"finalizing_at": 0,
"in_progress_at": 0,
"metadata": {
"foo": "string"
},
"model": "model",
"output_file_id": "output_file_id",
"request_counts": {
"completed": 0,
"failed": 0,
"total": 0
},
"usage": {
"input_tokens": 0,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 0,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 0
}
}
List batches
BatchListPage batches().list(BatchListParamsparams = BatchListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
get /batches
List your organization's batches.
Parameters
-
BatchListParams params-
Optional<String> afterA cursor for use in pagination.
afteris 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. -
Optional<Long> limitA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
-
Returns
-
class Batch:-
String id -
String completionWindowThe time frame within which the batch should be processed.
-
long createdAtThe Unix timestamp (in seconds) for when the batch was created.
-
String endpointThe OpenAI API endpoint used by the batch.
-
String inputFileIdThe ID of the input file for the batch.
-
JsonValue; object_ "batch"constantThe object type, which is always
batch.BATCH("batch")
-
Status statusThe current status of the batch.
-
VALIDATING("validating") -
FAILED("failed") -
IN_PROGRESS("in_progress") -
FINALIZING("finalizing") -
COMPLETED("completed") -
EXPIRED("expired") -
CANCELLING("cancelling") -
CANCELLED("cancelled")
-
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the batch was cancelled.
-
Optional<Long> cancellingAtThe Unix timestamp (in seconds) for when the batch started cancelling.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the batch was completed.
-
Optional<String> errorFileIdThe ID of the file containing the outputs of requests with errors.
-
Optional<Errors> errors-
Optional<List<BatchError>> data-
Optional<String> codeAn error code identifying the error type.
-
Optional<Long> lineThe line number of the input file where the error occurred, if applicable.
-
Optional<String> messageA human-readable message providing more details about the error.
-
Optional<String> paramThe name of the parameter that caused the error, if applicable.
-
-
Optional<String> object_The object type, which is always
list.
-
-
Optional<Long> expiredAtThe Unix timestamp (in seconds) for when the batch expired.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the batch will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the batch failed.
-
Optional<Long> finalizingAtThe Unix timestamp (in seconds) for when the batch started finalizing.
-
Optional<Long> inProgressAtThe Unix timestamp (in seconds) for when the batch started processing.
-
Optional<Metadata> metadataSet 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.
-
Optional<String> modelModel 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. -
Optional<String> outputFileIdThe ID of the file containing the outputs of successfully executed requests.
-
Optional<BatchRequestCounts> requestCountsThe request counts for different statuses within the batch.
-
long completedNumber of requests that have been completed successfully.
-
long failedNumber of requests that have failed.
-
long totalTotal number of requests in the batch.
-
-
Optional<BatchUsage> usageRepresents 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.
-
long inputTokensThe number of input tokens.
-
InputTokensDetails inputTokensDetailsA detailed breakdown of the input tokens.
-
long cachedTokensThe number of tokens that were retrieved from the cache. More on prompt caching.
-
-
long outputTokensThe number of output tokens.
-
OutputTokensDetails outputTokensDetailsA detailed breakdown of the output tokens.
-
long reasoningTokensThe number of reasoning tokens.
-
-
long totalTokensThe total number of tokens used.
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.batches.BatchListPage;
import com.openai.models.batches.BatchListParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
BatchListPage page = client.batches().list();
}
}
Response
{
"data": [
{
"id": "id",
"completion_window": "completion_window",
"created_at": 0,
"endpoint": "endpoint",
"input_file_id": "input_file_id",
"object": "batch",
"status": "validating",
"cancelled_at": 0,
"cancelling_at": 0,
"completed_at": 0,
"error_file_id": "error_file_id",
"errors": {
"data": [
{
"code": "code",
"line": 0,
"message": "message",
"param": "param"
}
],
"object": "object"
},
"expired_at": 0,
"expires_at": 0,
"failed_at": 0,
"finalizing_at": 0,
"in_progress_at": 0,
"metadata": {
"foo": "string"
},
"model": "model",
"output_file_id": "output_file_id",
"request_counts": {
"completed": 0,
"failed": 0,
"total": 0
},
"usage": {
"input_tokens": 0,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 0,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 0
}
}
],
"has_more": true,
"object": "list",
"first_id": "batch_abc123",
"last_id": "batch_abc456"
}
Domain Types
Batch
-
class Batch:-
String id -
String completionWindowThe time frame within which the batch should be processed.
-
long createdAtThe Unix timestamp (in seconds) for when the batch was created.
-
String endpointThe OpenAI API endpoint used by the batch.
-
String inputFileIdThe ID of the input file for the batch.
-
JsonValue; object_ "batch"constantThe object type, which is always
batch.BATCH("batch")
-
Status statusThe current status of the batch.
-
VALIDATING("validating") -
FAILED("failed") -
IN_PROGRESS("in_progress") -
FINALIZING("finalizing") -
COMPLETED("completed") -
EXPIRED("expired") -
CANCELLING("cancelling") -
CANCELLED("cancelled")
-
-
Optional<Long> cancelledAtThe Unix timestamp (in seconds) for when the batch was cancelled.
-
Optional<Long> cancellingAtThe Unix timestamp (in seconds) for when the batch started cancelling.
-
Optional<Long> completedAtThe Unix timestamp (in seconds) for when the batch was completed.
-
Optional<String> errorFileIdThe ID of the file containing the outputs of requests with errors.
-
Optional<Errors> errors-
Optional<List<BatchError>> data-
Optional<String> codeAn error code identifying the error type.
-
Optional<Long> lineThe line number of the input file where the error occurred, if applicable.
-
Optional<String> messageA human-readable message providing more details about the error.
-
Optional<String> paramThe name of the parameter that caused the error, if applicable.
-
-
Optional<String> object_The object type, which is always
list.
-
-
Optional<Long> expiredAtThe Unix timestamp (in seconds) for when the batch expired.
-
Optional<Long> expiresAtThe Unix timestamp (in seconds) for when the batch will expire.
-
Optional<Long> failedAtThe Unix timestamp (in seconds) for when the batch failed.
-
Optional<Long> finalizingAtThe Unix timestamp (in seconds) for when the batch started finalizing.
-
Optional<Long> inProgressAtThe Unix timestamp (in seconds) for when the batch started processing.
-
Optional<Metadata> metadataSet 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.
-
Optional<String> modelModel 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. -
Optional<String> outputFileIdThe ID of the file containing the outputs of successfully executed requests.
-
Optional<BatchRequestCounts> requestCountsThe request counts for different statuses within the batch.
-
long completedNumber of requests that have been completed successfully.
-
long failedNumber of requests that have failed.
-
long totalTotal number of requests in the batch.
-
-
Optional<BatchUsage> usageRepresents 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.
-
long inputTokensThe number of input tokens.
-
InputTokensDetails inputTokensDetailsA detailed breakdown of the input tokens.
-
long cachedTokensThe number of tokens that were retrieved from the cache. More on prompt caching.
-
-
long outputTokensThe number of output tokens.
-
OutputTokensDetails outputTokensDetailsA detailed breakdown of the output tokens.
-
long reasoningTokensThe number of reasoning tokens.
-
-
long totalTokensThe total number of tokens used.
-
-
Batch Error
-
class BatchError:-
Optional<String> codeAn error code identifying the error type.
-
Optional<Long> lineThe line number of the input file where the error occurred, if applicable.
-
Optional<String> messageA human-readable message providing more details about the error.
-
Optional<String> paramThe name of the parameter that caused the error, if applicable.
-
Batch Request Counts
-
class BatchRequestCounts:The request counts for different statuses within the batch.
-
long completedNumber of requests that have been completed successfully.
-
long failedNumber of requests that have failed.
-
long totalTotal number of requests in the batch.
-
Batch Usage
-
class BatchUsage: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.
-
long inputTokensThe number of input tokens.
-
InputTokensDetails inputTokensDetailsA detailed breakdown of the input tokens.
-
long cachedTokensThe number of tokens that were retrieved from the cache. More on prompt caching.
-
-
long outputTokensThe number of output tokens.
-
OutputTokensDetails outputTokensDetailsA detailed breakdown of the output tokens.
-
long reasoningTokensThe number of reasoning tokens.
-
-
long totalTokensThe total number of tokens used.
-