Repository Public
1# Batches23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45## Cancel batch67**post** `/batches/{batch_id}/cancel`89Cancels 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.1011### Path Parameters1213- `batch_id: string`1415### Returns1617- `Batch object { id, completion_window, created_at, 19 more }`1819 - `id: string`2021 - `completion_window: string`2223 The time frame within which the batch should be processed.2425 - `created_at: number`2627 The Unix timestamp (in seconds) for when the batch was created.2829 - `endpoint: string`3031 The OpenAI API endpoint used by the batch.3233 - `input_file_id: string`3435 The ID of the input file for the batch.3637 - `object: "batch"`3839 The object type, which is always `batch`.4041 - `"batch"`4243 - `status: "validating" or "failed" or "in_progress" or 5 more`4445 The current status of the batch.4647 - `"validating"`4849 - `"failed"`5051 - `"in_progress"`5253 - `"finalizing"`5455 - `"completed"`5657 - `"expired"`5859 - `"cancelling"`6061 - `"cancelled"`6263 - `cancelled_at: optional number`6465 The Unix timestamp (in seconds) for when the batch was cancelled.6667 - `cancelling_at: optional number`6869 The Unix timestamp (in seconds) for when the batch started cancelling.7071 - `completed_at: optional number`7273 The Unix timestamp (in seconds) for when the batch was completed.7475 - `error_file_id: optional string`7677 The ID of the file containing the outputs of requests with errors.7879 - `errors: optional object { data, object }`8081 - `data: optional array of BatchError`8283 - `code: optional string`8485 An error code identifying the error type.8687 - `line: optional number or null`8889 The line number of the input file where the error occurred, if applicable.9091 - `message: optional string`9293 A human-readable message providing more details about the error.9495 - `param: optional string or null`9697 The name of the parameter that caused the error, if applicable.9899 - `object: optional string`100101 The object type, which is always `list`.102103 - `expired_at: optional number`104105 The Unix timestamp (in seconds) for when the batch expired.106107 - `expires_at: optional number`108109 The Unix timestamp (in seconds) for when the batch will expire.110111 - `failed_at: optional number`112113 The Unix timestamp (in seconds) for when the batch failed.114115 - `finalizing_at: optional number`116117 The Unix timestamp (in seconds) for when the batch started finalizing.118119 - `in_progress_at: optional number`120121 The Unix timestamp (in seconds) for when the batch started processing.122123 - `metadata: optional Metadata or null`124125 Set of 16 key-value pairs that can be attached to an object. This can be126 useful for storing additional information about the object in a structured127 format, and querying for objects via API or the dashboard.128129 Keys are strings with a maximum length of 64 characters. Values are strings130 with a maximum length of 512 characters.131132 - `model: optional string`133134 Model ID used to process the batch, like `gpt-6-astra`. OpenAI135 offers a wide range of models with different capabilities, performance136 characteristics, and price points. Refer to the [model137 guide](/api/docs/models) to browse and compare available models.138139 - `output_file_id: optional string`140141 The ID of the file containing the outputs of successfully executed requests.142143 - `request_counts: optional BatchRequestCounts`144145 The request counts for different statuses within the batch.146147 - `completed: number`148149 Number of requests that have been completed successfully.150151 - `failed: number`152153 Number of requests that have failed.154155 - `total: number`156157 Total number of requests in the batch.158159 - `usage: optional BatchUsage`160161 Represents token usage details including input tokens, output tokens, a162 breakdown of output tokens, and the total tokens used. Only populated on163 batches created after September 7, 2025.164165 - `input_tokens: number`166167 The number of input tokens.168169 - `input_tokens_details: object { cached_tokens }`170171 A detailed breakdown of the input tokens.172173 - `cached_tokens: number`174175 The number of tokens that were retrieved from the cache. [More on176 prompt caching](/api/docs/guides/prompt-caching).177178 - `output_tokens: number`179180 The number of output tokens.181182 - `output_tokens_details: object { reasoning_tokens }`183184 A detailed breakdown of the output tokens.185186 - `reasoning_tokens: number`187188 The number of reasoning tokens.189190 - `total_tokens: number`191192 The total number of tokens used.193194### Example195196```http197curl https://api.openai.com/v1/batches/$BATCH_ID/cancel \198 -X POST \199 -H "Authorization: Bearer $OPENAI_API_KEY"200```201202#### Response203204```json205{206 "id": "id",207 "completion_window": "completion_window",208 "created_at": 0,209 "endpoint": "endpoint",210 "input_file_id": "input_file_id",211 "object": "batch",212 "status": "validating",213 "cancelled_at": 0,214 "cancelling_at": 0,215 "completed_at": 0,216 "error_file_id": "error_file_id",217 "errors": {218 "data": [219 {220 "code": "code",221 "line": 0,222 "message": "message",223 "param": "param"224 }225 ],226 "object": "object"227 },228 "expired_at": 0,229 "expires_at": 0,230 "failed_at": 0,231 "finalizing_at": 0,232 "in_progress_at": 0,233 "metadata": {234 "foo": "string"235 },236 "model": "model",237 "output_file_id": "output_file_id",238 "request_counts": {239 "completed": 0,240 "failed": 0,241 "total": 0242 },243 "usage": {244 "input_tokens": 0,245 "input_tokens_details": {246 "cached_tokens": 0247 },248 "output_tokens": 0,249 "output_tokens_details": {250 "reasoning_tokens": 0251 },252 "total_tokens": 0253 }254}255```256257### Example258259```http260curl https://api.openai.com/v1/batches/batch_abc123/cancel \261 -H "Authorization: Bearer $OPENAI_API_KEY" \262 -H "Content-Type: application/json" \263 -X POST264```265266#### Response267268```json269{270 "id": "batch_abc123",271 "object": "batch",272 "endpoint": "/v1/chat/completions",273 "errors": null,274 "input_file_id": "file-abc123",275 "completion_window": "24h",276 "status": "cancelling",277 "output_file_id": null,278 "error_file_id": null,279 "created_at": 1711471533,280 "in_progress_at": 1711471538,281 "expires_at": 1711557933,282 "finalizing_at": null,283 "completed_at": null,284 "failed_at": null,285 "expired_at": null,286 "cancelling_at": 1711475133,287 "cancelled_at": null,288 "request_counts": {289 "total": 100,290 "completed": 23,291 "failed": 1292 },293 "metadata": {294 "customer_id": "user_123456789",295 "batch_description": "Nightly eval job",296 }297}298```299300## Create batch301302**post** `/batches`303304Creates and executes a batch from an uploaded file of requests305306### Body Parameters307308- `completion_window: "24h"`309310 The time frame within which the batch should be processed. Currently only `24h` is supported.311312 - `"24h"`313314- `endpoint: "/v1/responses" or "/v1/chat/completions" or "/v1/embeddings" or 5 more`315316 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.317318 - `"/v1/responses"`319320 - `"/v1/chat/completions"`321322 - `"/v1/embeddings"`323324 - `"/v1/completions"`325326 - `"/v1/moderations"`327328 - `"/v1/images/generations"`329330 - `"/v1/images/edits"`331332 - `"/v1/videos"`333334- `input_file_id: string`335336 The ID of an uploaded file that contains requests for the new batch.337338 See [upload file](/api/reference/resources/files/methods/create) for how to upload a file.339340 Your input file must be formatted as a [JSONL file](/api/docs/guides/batch#1-prepare-your-batch-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.341342- `metadata: optional Metadata or null`343344 Set of 16 key-value pairs that can be attached to an object. This can be345 useful for storing additional information about the object in a structured346 format, and querying for objects via API or the dashboard.347348 Keys are strings with a maximum length of 64 characters. Values are strings349 with a maximum length of 512 characters.350351- `output_expires_after: optional object { anchor, seconds }`352353 The expiration policy for the output and/or error file that are generated for a batch.354355 - `anchor: "created_at"`356357 Anchor 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.358359 - `"created_at"`360361 - `seconds: number`362363 The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).364365### Returns366367- `Batch object { id, completion_window, created_at, 19 more }`368369 - `id: string`370371 - `completion_window: string`372373 The time frame within which the batch should be processed.374375 - `created_at: number`376377 The Unix timestamp (in seconds) for when the batch was created.378379 - `endpoint: string`380381 The OpenAI API endpoint used by the batch.382383 - `input_file_id: string`384385 The ID of the input file for the batch.386387 - `object: "batch"`388389 The object type, which is always `batch`.390391 - `"batch"`392393 - `status: "validating" or "failed" or "in_progress" or 5 more`394395 The current status of the batch.396397 - `"validating"`398399 - `"failed"`400401 - `"in_progress"`402403 - `"finalizing"`404405 - `"completed"`406407 - `"expired"`408409 - `"cancelling"`410411 - `"cancelled"`412413 - `cancelled_at: optional number`414415 The Unix timestamp (in seconds) for when the batch was cancelled.416417 - `cancelling_at: optional number`418419 The Unix timestamp (in seconds) for when the batch started cancelling.420421 - `completed_at: optional number`422423 The Unix timestamp (in seconds) for when the batch was completed.424425 - `error_file_id: optional string`426427 The ID of the file containing the outputs of requests with errors.428429 - `errors: optional object { data, object }`430431 - `data: optional array of BatchError`432433 - `code: optional string`434435 An error code identifying the error type.436437 - `line: optional number or null`438439 The line number of the input file where the error occurred, if applicable.440441 - `message: optional string`442443 A human-readable message providing more details about the error.444445 - `param: optional string or null`446447 The name of the parameter that caused the error, if applicable.448449 - `object: optional string`450451 The object type, which is always `list`.452453 - `expired_at: optional number`454455 The Unix timestamp (in seconds) for when the batch expired.456457 - `expires_at: optional number`458459 The Unix timestamp (in seconds) for when the batch will expire.460461 - `failed_at: optional number`462463 The Unix timestamp (in seconds) for when the batch failed.464465 - `finalizing_at: optional number`466467 The Unix timestamp (in seconds) for when the batch started finalizing.468469 - `in_progress_at: optional number`470471 The Unix timestamp (in seconds) for when the batch started processing.472473 - `metadata: optional Metadata or null`474475 Set of 16 key-value pairs that can be attached to an object. This can be476 useful for storing additional information about the object in a structured477 format, and querying for objects via API or the dashboard.478479 Keys are strings with a maximum length of 64 characters. Values are strings480 with a maximum length of 512 characters.481482 - `model: optional string`483484 Model ID used to process the batch, like `gpt-6-astra`. OpenAI485 offers a wide range of models with different capabilities, performance486 characteristics, and price points. Refer to the [model487 guide](/api/docs/models) to browse and compare available models.488489 - `output_file_id: optional string`490491 The ID of the file containing the outputs of successfully executed requests.492493 - `request_counts: optional BatchRequestCounts`494495 The request counts for different statuses within the batch.496497 - `completed: number`498499 Number of requests that have been completed successfully.500501 - `failed: number`502503 Number of requests that have failed.504505 - `total: number`506507 Total number of requests in the batch.508509 - `usage: optional BatchUsage`510511 Represents token usage details including input tokens, output tokens, a512 breakdown of output tokens, and the total tokens used. Only populated on513 batches created after September 7, 2025.514515 - `input_tokens: number`516517 The number of input tokens.518519 - `input_tokens_details: object { cached_tokens }`520521 A detailed breakdown of the input tokens.522523 - `cached_tokens: number`524525 The number of tokens that were retrieved from the cache. [More on526 prompt caching](/api/docs/guides/prompt-caching).527528 - `output_tokens: number`529530 The number of output tokens.531532 - `output_tokens_details: object { reasoning_tokens }`533534 A detailed breakdown of the output tokens.535536 - `reasoning_tokens: number`537538 The number of reasoning tokens.539540 - `total_tokens: number`541542 The total number of tokens used.543544### Example545546```http547curl https://api.openai.com/v1/batches \548 -H 'Content-Type: application/json' \549 -H "Authorization: Bearer $OPENAI_API_KEY" \550 -d '{551 "completion_window": "24h",552 "endpoint": "/v1/responses",553 "input_file_id": "input_file_id"554 }'555```556557#### Response558559```json560{561 "id": "id",562 "completion_window": "completion_window",563 "created_at": 0,564 "endpoint": "endpoint",565 "input_file_id": "input_file_id",566 "object": "batch",567 "status": "validating",568 "cancelled_at": 0,569 "cancelling_at": 0,570 "completed_at": 0,571 "error_file_id": "error_file_id",572 "errors": {573 "data": [574 {575 "code": "code",576 "line": 0,577 "message": "message",578 "param": "param"579 }580 ],581 "object": "object"582 },583 "expired_at": 0,584 "expires_at": 0,585 "failed_at": 0,586 "finalizing_at": 0,587 "in_progress_at": 0,588 "metadata": {589 "foo": "string"590 },591 "model": "model",592 "output_file_id": "output_file_id",593 "request_counts": {594 "completed": 0,595 "failed": 0,596 "total": 0597 },598 "usage": {599 "input_tokens": 0,600 "input_tokens_details": {601 "cached_tokens": 0602 },603 "output_tokens": 0,604 "output_tokens_details": {605 "reasoning_tokens": 0606 },607 "total_tokens": 0608 }609}610```611612### Example613614```http615curl https://api.openai.com/v1/batches \616 -H "Authorization: Bearer $OPENAI_API_KEY" \617 -H "Content-Type: application/json" \618 -d '{619 "input_file_id": "file-abc123",620 "endpoint": "/v1/chat/completions",621 "completion_window": "24h"622 }'623```624625#### Response626627```json628{629 "id": "batch_abc123",630 "object": "batch",631 "endpoint": "/v1/chat/completions",632 "errors": null,633 "input_file_id": "file-abc123",634 "completion_window": "24h",635 "status": "validating",636 "output_file_id": null,637 "error_file_id": null,638 "created_at": 1711471533,639 "in_progress_at": null,640 "expires_at": null,641 "finalizing_at": null,642 "completed_at": null,643 "failed_at": null,644 "expired_at": null,645 "cancelling_at": null,646 "cancelled_at": null,647 "request_counts": {648 "total": 0,649 "completed": 0,650 "failed": 0651 },652 "metadata": {653 "customer_id": "user_123456789",654 "batch_description": "Nightly eval job",655 }656}657```658659## List batches660661**get** `/batches`662663List your organization's batches.664665### Query Parameters666667- `after: optional string`668669 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.670671- `limit: optional number`672673 A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.674675### Returns676677- `data: array of Batch`678679 - `id: string`680681 - `completion_window: string`682683 The time frame within which the batch should be processed.684685 - `created_at: number`686687 The Unix timestamp (in seconds) for when the batch was created.688689 - `endpoint: string`690691 The OpenAI API endpoint used by the batch.692693 - `input_file_id: string`694695 The ID of the input file for the batch.696697 - `object: "batch"`698699 The object type, which is always `batch`.700701 - `"batch"`702703 - `status: "validating" or "failed" or "in_progress" or 5 more`704705 The current status of the batch.706707 - `"validating"`708709 - `"failed"`710711 - `"in_progress"`712713 - `"finalizing"`714715 - `"completed"`716717 - `"expired"`718719 - `"cancelling"`720721 - `"cancelled"`722723 - `cancelled_at: optional number`724725 The Unix timestamp (in seconds) for when the batch was cancelled.726727 - `cancelling_at: optional number`728729 The Unix timestamp (in seconds) for when the batch started cancelling.730731 - `completed_at: optional number`732733 The Unix timestamp (in seconds) for when the batch was completed.734735 - `error_file_id: optional string`736737 The ID of the file containing the outputs of requests with errors.738739 - `errors: optional object { data, object }`740741 - `data: optional array of BatchError`742743 - `code: optional string`744745 An error code identifying the error type.746747 - `line: optional number or null`748749 The line number of the input file where the error occurred, if applicable.750751 - `message: optional string`752753 A human-readable message providing more details about the error.754755 - `param: optional string or null`756757 The name of the parameter that caused the error, if applicable.758759 - `object: optional string`760761 The object type, which is always `list`.762763 - `expired_at: optional number`764765 The Unix timestamp (in seconds) for when the batch expired.766767 - `expires_at: optional number`768769 The Unix timestamp (in seconds) for when the batch will expire.770771 - `failed_at: optional number`772773 The Unix timestamp (in seconds) for when the batch failed.774775 - `finalizing_at: optional number`776777 The Unix timestamp (in seconds) for when the batch started finalizing.778779 - `in_progress_at: optional number`780781 The Unix timestamp (in seconds) for when the batch started processing.782783 - `metadata: optional Metadata or null`784785 Set of 16 key-value pairs that can be attached to an object. This can be786 useful for storing additional information about the object in a structured787 format, and querying for objects via API or the dashboard.788789 Keys are strings with a maximum length of 64 characters. Values are strings790 with a maximum length of 512 characters.791792 - `model: optional string`793794 Model ID used to process the batch, like `gpt-6-astra`. OpenAI795 offers a wide range of models with different capabilities, performance796 characteristics, and price points. Refer to the [model797 guide](/api/docs/models) to browse and compare available models.798799 - `output_file_id: optional string`800801 The ID of the file containing the outputs of successfully executed requests.802803 - `request_counts: optional BatchRequestCounts`804805 The request counts for different statuses within the batch.806807 - `completed: number`808809 Number of requests that have been completed successfully.810811 - `failed: number`812813 Number of requests that have failed.814815 - `total: number`816817 Total number of requests in the batch.818819 - `usage: optional BatchUsage`820821 Represents token usage details including input tokens, output tokens, a822 breakdown of output tokens, and the total tokens used. Only populated on823 batches created after September 7, 2025.824825 - `input_tokens: number`826827 The number of input tokens.828829 - `input_tokens_details: object { cached_tokens }`830831 A detailed breakdown of the input tokens.832833 - `cached_tokens: number`834835 The number of tokens that were retrieved from the cache. [More on836 prompt caching](/api/docs/guides/prompt-caching).837838 - `output_tokens: number`839840 The number of output tokens.841842 - `output_tokens_details: object { reasoning_tokens }`843844 A detailed breakdown of the output tokens.845846 - `reasoning_tokens: number`847848 The number of reasoning tokens.849850 - `total_tokens: number`851852 The total number of tokens used.853854- `has_more: boolean`855856- `object: "list"`857858 - `"list"`859860- `first_id: optional string`861862- `last_id: optional string`863864### Example865866```http867curl https://api.openai.com/v1/batches \868 -H "Authorization: Bearer $OPENAI_API_KEY"869```870871#### Response872873```json874{875 "data": [876 {877 "id": "id",878 "completion_window": "completion_window",879 "created_at": 0,880 "endpoint": "endpoint",881 "input_file_id": "input_file_id",882 "object": "batch",883 "status": "validating",884 "cancelled_at": 0,885 "cancelling_at": 0,886 "completed_at": 0,887 "error_file_id": "error_file_id",888 "errors": {889 "data": [890 {891 "code": "code",892 "line": 0,893 "message": "message",894 "param": "param"895 }896 ],897 "object": "object"898 },899 "expired_at": 0,900 "expires_at": 0,901 "failed_at": 0,902 "finalizing_at": 0,903 "in_progress_at": 0,904 "metadata": {905 "foo": "string"906 },907 "model": "model",908 "output_file_id": "output_file_id",909 "request_counts": {910 "completed": 0,911 "failed": 0,912 "total": 0913 },914 "usage": {915 "input_tokens": 0,916 "input_tokens_details": {917 "cached_tokens": 0918 },919 "output_tokens": 0,920 "output_tokens_details": {921 "reasoning_tokens": 0922 },923 "total_tokens": 0924 }925 }926 ],927 "has_more": true,928 "object": "list",929 "first_id": "batch_abc123",930 "last_id": "batch_abc456"931}932```933934### Example935936```http937curl https://api.openai.com/v1/batches?limit=2 \938 -H "Authorization: Bearer $OPENAI_API_KEY" \939 -H "Content-Type: application/json"940```941942#### Response943944```json945{946 "object": "list",947 "data": [948 {949 "id": "batch_abc123",950 "object": "batch",951 "endpoint": "/v1/chat/completions",952 "errors": null,953 "input_file_id": "file-abc123",954 "completion_window": "24h",955 "status": "completed",956 "output_file_id": "file-cvaTdG",957 "error_file_id": "file-HOWS94",958 "created_at": 1711471533,959 "in_progress_at": 1711471538,960 "expires_at": 1711557933,961 "finalizing_at": 1711493133,962 "completed_at": 1711493163,963 "failed_at": null,964 "expired_at": null,965 "cancelling_at": null,966 "cancelled_at": null,967 "request_counts": {968 "total": 100,969 "completed": 95,970 "failed": 5971 },972 "metadata": {973 "customer_id": "user_123456789",974 "batch_description": "Nightly job",975 }976 },977 { ... },978 ],979 "first_id": "batch_abc123",980 "last_id": "batch_abc456",981 "has_more": true982}983```984985## Retrieve batch986987**get** `/batches/{batch_id}`988989Retrieves a batch.990991### Path Parameters992993- `batch_id: string`994995### Returns996997- `Batch object { id, completion_window, created_at, 19 more }`998999 - `id: string`10001001 - `completion_window: string`10021003 The time frame within which the batch should be processed.10041005 - `created_at: number`10061007 The Unix timestamp (in seconds) for when the batch was created.10081009 - `endpoint: string`10101011 The OpenAI API endpoint used by the batch.10121013 - `input_file_id: string`10141015 The ID of the input file for the batch.10161017 - `object: "batch"`10181019 The object type, which is always `batch`.10201021 - `"batch"`10221023 - `status: "validating" or "failed" or "in_progress" or 5 more`10241025 The current status of the batch.10261027 - `"validating"`10281029 - `"failed"`10301031 - `"in_progress"`10321033 - `"finalizing"`10341035 - `"completed"`10361037 - `"expired"`10381039 - `"cancelling"`10401041 - `"cancelled"`10421043 - `cancelled_at: optional number`10441045 The Unix timestamp (in seconds) for when the batch was cancelled.10461047 - `cancelling_at: optional number`10481049 The Unix timestamp (in seconds) for when the batch started cancelling.10501051 - `completed_at: optional number`10521053 The Unix timestamp (in seconds) for when the batch was completed.10541055 - `error_file_id: optional string`10561057 The ID of the file containing the outputs of requests with errors.10581059 - `errors: optional object { data, object }`10601061 - `data: optional array of BatchError`10621063 - `code: optional string`10641065 An error code identifying the error type.10661067 - `line: optional number or null`10681069 The line number of the input file where the error occurred, if applicable.10701071 - `message: optional string`10721073 A human-readable message providing more details about the error.10741075 - `param: optional string or null`10761077 The name of the parameter that caused the error, if applicable.10781079 - `object: optional string`10801081 The object type, which is always `list`.10821083 - `expired_at: optional number`10841085 The Unix timestamp (in seconds) for when the batch expired.10861087 - `expires_at: optional number`10881089 The Unix timestamp (in seconds) for when the batch will expire.10901091 - `failed_at: optional number`10921093 The Unix timestamp (in seconds) for when the batch failed.10941095 - `finalizing_at: optional number`10961097 The Unix timestamp (in seconds) for when the batch started finalizing.10981099 - `in_progress_at: optional number`11001101 The Unix timestamp (in seconds) for when the batch started processing.11021103 - `metadata: optional Metadata or null`11041105 Set of 16 key-value pairs that can be attached to an object. This can be1106 useful for storing additional information about the object in a structured1107 format, and querying for objects via API or the dashboard.11081109 Keys are strings with a maximum length of 64 characters. Values are strings1110 with a maximum length of 512 characters.11111112 - `model: optional string`11131114 Model ID used to process the batch, like `gpt-6-astra`. OpenAI1115 offers a wide range of models with different capabilities, performance1116 characteristics, and price points. Refer to the [model1117 guide](/api/docs/models) to browse and compare available models.11181119 - `output_file_id: optional string`11201121 The ID of the file containing the outputs of successfully executed requests.11221123 - `request_counts: optional BatchRequestCounts`11241125 The request counts for different statuses within the batch.11261127 - `completed: number`11281129 Number of requests that have been completed successfully.11301131 - `failed: number`11321133 Number of requests that have failed.11341135 - `total: number`11361137 Total number of requests in the batch.11381139 - `usage: optional BatchUsage`11401141 Represents token usage details including input tokens, output tokens, a1142 breakdown of output tokens, and the total tokens used. Only populated on1143 batches created after September 7, 2025.11441145 - `input_tokens: number`11461147 The number of input tokens.11481149 - `input_tokens_details: object { cached_tokens }`11501151 A detailed breakdown of the input tokens.11521153 - `cached_tokens: number`11541155 The number of tokens that were retrieved from the cache. [More on1156 prompt caching](/api/docs/guides/prompt-caching).11571158 - `output_tokens: number`11591160 The number of output tokens.11611162 - `output_tokens_details: object { reasoning_tokens }`11631164 A detailed breakdown of the output tokens.11651166 - `reasoning_tokens: number`11671168 The number of reasoning tokens.11691170 - `total_tokens: number`11711172 The total number of tokens used.11731174### Example11751176```http1177curl https://api.openai.com/v1/batches/$BATCH_ID \1178 -H "Authorization: Bearer $OPENAI_API_KEY"1179```11801181#### Response11821183```json1184{1185 "id": "id",1186 "completion_window": "completion_window",1187 "created_at": 0,1188 "endpoint": "endpoint",1189 "input_file_id": "input_file_id",1190 "object": "batch",1191 "status": "validating",1192 "cancelled_at": 0,1193 "cancelling_at": 0,1194 "completed_at": 0,1195 "error_file_id": "error_file_id",1196 "errors": {1197 "data": [1198 {1199 "code": "code",1200 "line": 0,1201 "message": "message",1202 "param": "param"1203 }1204 ],1205 "object": "object"1206 },1207 "expired_at": 0,1208 "expires_at": 0,1209 "failed_at": 0,1210 "finalizing_at": 0,1211 "in_progress_at": 0,1212 "metadata": {1213 "foo": "string"1214 },1215 "model": "model",1216 "output_file_id": "output_file_id",1217 "request_counts": {1218 "completed": 0,1219 "failed": 0,1220 "total": 01221 },1222 "usage": {1223 "input_tokens": 0,1224 "input_tokens_details": {1225 "cached_tokens": 01226 },1227 "output_tokens": 0,1228 "output_tokens_details": {1229 "reasoning_tokens": 01230 },1231 "total_tokens": 01232 }1233}1234```12351236### Example12371238```http1239curl https://api.openai.com/v1/batches/batch_abc123 \1240 -H "Authorization: Bearer $OPENAI_API_KEY" \1241 -H "Content-Type: application/json" \1242```12431244#### Response12451246```json1247{1248 "id": "batch_abc123",1249 "object": "batch",1250 "endpoint": "/v1/completions",1251 "errors": null,1252 "input_file_id": "file-abc123",1253 "completion_window": "24h",1254 "status": "completed",1255 "output_file_id": "file-cvaTdG",1256 "error_file_id": "file-HOWS94",1257 "created_at": 1711471533,1258 "in_progress_at": 1711471538,1259 "expires_at": 1711557933,1260 "finalizing_at": 1711493133,1261 "completed_at": 1711493163,1262 "failed_at": null,1263 "expired_at": null,1264 "cancelling_at": null,1265 "cancelled_at": null,1266 "request_counts": {1267 "total": 100,1268 "completed": 95,1269 "failed": 51270 },1271 "metadata": {1272 "customer_id": "user_123456789",1273 "batch_description": "Nightly eval job",1274 }1275}1276```12771278## Domain Types12791280### Batch12811282- `Batch object { id, completion_window, created_at, 19 more }`12831284 - `id: string`12851286 - `completion_window: string`12871288 The time frame within which the batch should be processed.12891290 - `created_at: number`12911292 The Unix timestamp (in seconds) for when the batch was created.12931294 - `endpoint: string`12951296 The OpenAI API endpoint used by the batch.12971298 - `input_file_id: string`12991300 The ID of the input file for the batch.13011302 - `object: "batch"`13031304 The object type, which is always `batch`.13051306 - `"batch"`13071308 - `status: "validating" or "failed" or "in_progress" or 5 more`13091310 The current status of the batch.13111312 - `"validating"`13131314 - `"failed"`13151316 - `"in_progress"`13171318 - `"finalizing"`13191320 - `"completed"`13211322 - `"expired"`13231324 - `"cancelling"`13251326 - `"cancelled"`13271328 - `cancelled_at: optional number`13291330 The Unix timestamp (in seconds) for when the batch was cancelled.13311332 - `cancelling_at: optional number`13331334 The Unix timestamp (in seconds) for when the batch started cancelling.13351336 - `completed_at: optional number`13371338 The Unix timestamp (in seconds) for when the batch was completed.13391340 - `error_file_id: optional string`13411342 The ID of the file containing the outputs of requests with errors.13431344 - `errors: optional object { data, object }`13451346 - `data: optional array of BatchError`13471348 - `code: optional string`13491350 An error code identifying the error type.13511352 - `line: optional number or null`13531354 The line number of the input file where the error occurred, if applicable.13551356 - `message: optional string`13571358 A human-readable message providing more details about the error.13591360 - `param: optional string or null`13611362 The name of the parameter that caused the error, if applicable.13631364 - `object: optional string`13651366 The object type, which is always `list`.13671368 - `expired_at: optional number`13691370 The Unix timestamp (in seconds) for when the batch expired.13711372 - `expires_at: optional number`13731374 The Unix timestamp (in seconds) for when the batch will expire.13751376 - `failed_at: optional number`13771378 The Unix timestamp (in seconds) for when the batch failed.13791380 - `finalizing_at: optional number`13811382 The Unix timestamp (in seconds) for when the batch started finalizing.13831384 - `in_progress_at: optional number`13851386 The Unix timestamp (in seconds) for when the batch started processing.13871388 - `metadata: optional Metadata or null`13891390 Set of 16 key-value pairs that can be attached to an object. This can be1391 useful for storing additional information about the object in a structured1392 format, and querying for objects via API or the dashboard.13931394 Keys are strings with a maximum length of 64 characters. Values are strings1395 with a maximum length of 512 characters.13961397 - `model: optional string`13981399 Model ID used to process the batch, like `gpt-6-astra`. OpenAI1400 offers a wide range of models with different capabilities, performance1401 characteristics, and price points. Refer to the [model1402 guide](/api/docs/models) to browse and compare available models.14031404 - `output_file_id: optional string`14051406 The ID of the file containing the outputs of successfully executed requests.14071408 - `request_counts: optional BatchRequestCounts`14091410 The request counts for different statuses within the batch.14111412 - `completed: number`14131414 Number of requests that have been completed successfully.14151416 - `failed: number`14171418 Number of requests that have failed.14191420 - `total: number`14211422 Total number of requests in the batch.14231424 - `usage: optional BatchUsage`14251426 Represents token usage details including input tokens, output tokens, a1427 breakdown of output tokens, and the total tokens used. Only populated on1428 batches created after September 7, 2025.14291430 - `input_tokens: number`14311432 The number of input tokens.14331434 - `input_tokens_details: object { cached_tokens }`14351436 A detailed breakdown of the input tokens.14371438 - `cached_tokens: number`14391440 The number of tokens that were retrieved from the cache. [More on1441 prompt caching](/api/docs/guides/prompt-caching).14421443 - `output_tokens: number`14441445 The number of output tokens.14461447 - `output_tokens_details: object { reasoning_tokens }`14481449 A detailed breakdown of the output tokens.14501451 - `reasoning_tokens: number`14521453 The number of reasoning tokens.14541455 - `total_tokens: number`14561457 The total number of tokens used.14581459### Batch Error14601461- `BatchError object { code, line, message, param }`14621463 - `code: optional string`14641465 An error code identifying the error type.14661467 - `line: optional number or null`14681469 The line number of the input file where the error occurred, if applicable.14701471 - `message: optional string`14721473 A human-readable message providing more details about the error.14741475 - `param: optional string or null`14761477 The name of the parameter that caused the error, if applicable.14781479### Batch Request Counts14801481- `BatchRequestCounts object { completed, failed, total }`14821483 The request counts for different statuses within the batch.14841485 - `completed: number`14861487 Number of requests that have been completed successfully.14881489 - `failed: number`14901491 Number of requests that have failed.14921493 - `total: number`14941495 Total number of requests in the batch.14961497### Batch Usage14981499- `BatchUsage object { input_tokens, input_tokens_details, output_tokens, 2 more }`15001501 Represents token usage details including input tokens, output tokens, a1502 breakdown of output tokens, and the total tokens used. Only populated on1503 batches created after September 7, 2025.15041505 - `input_tokens: number`15061507 The number of input tokens.15081509 - `input_tokens_details: object { cached_tokens }`15101511 A detailed breakdown of the input tokens.15121513 - `cached_tokens: number`15141515 The number of tokens that were retrieved from the cache. [More on1516 prompt caching](/api/docs/guides/prompt-caching).15171518 - `output_tokens: number`15191520 The number of output tokens.15211522 - `output_tokens_details: object { reasoning_tokens }`15231524 A detailed breakdown of the output tokens.15251526 - `reasoning_tokens: number`15271528 The number of reasoning tokens.15291530 - `total_tokens: number`15311532 The total number of tokens used.1533