Repository Public
1> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.23## Retrieve batch45**get** `/batches/{batch_id}`67Retrieves a batch.89### Path Parameters1011- `batch_id: string`1213### Returns1415- `Batch object { id, completion_window, created_at, 19 more }`1617 - `id: string`1819 - `completion_window: string`2021 The time frame within which the batch should be processed.2223 - `created_at: number`2425 The Unix timestamp (in seconds) for when the batch was created.2627 - `endpoint: string`2829 The OpenAI API endpoint used by the batch.3031 - `input_file_id: string`3233 The ID of the input file for the batch.3435 - `object: "batch"`3637 The object type, which is always `batch`.3839 - `"batch"`4041 - `status: "validating" or "failed" or "in_progress" or 5 more`4243 The current status of the batch.4445 - `"validating"`4647 - `"failed"`4849 - `"in_progress"`5051 - `"finalizing"`5253 - `"completed"`5455 - `"expired"`5657 - `"cancelling"`5859 - `"cancelled"`6061 - `cancelled_at: optional number`6263 The Unix timestamp (in seconds) for when the batch was cancelled.6465 - `cancelling_at: optional number`6667 The Unix timestamp (in seconds) for when the batch started cancelling.6869 - `completed_at: optional number`7071 The Unix timestamp (in seconds) for when the batch was completed.7273 - `error_file_id: optional string`7475 The ID of the file containing the outputs of requests with errors.7677 - `errors: optional object { data, object }`7879 - `data: optional array of BatchError`8081 - `code: optional string`8283 An error code identifying the error type.8485 - `line: optional number or null`8687 The line number of the input file where the error occurred, if applicable.8889 - `message: optional string`9091 A human-readable message providing more details about the error.9293 - `param: optional string or null`9495 The name of the parameter that caused the error, if applicable.9697 - `object: optional string`9899 The object type, which is always `list`.100101 - `expired_at: optional number`102103 The Unix timestamp (in seconds) for when the batch expired.104105 - `expires_at: optional number`106107 The Unix timestamp (in seconds) for when the batch will expire.108109 - `failed_at: optional number`110111 The Unix timestamp (in seconds) for when the batch failed.112113 - `finalizing_at: optional number`114115 The Unix timestamp (in seconds) for when the batch started finalizing.116117 - `in_progress_at: optional number`118119 The Unix timestamp (in seconds) for when the batch started processing.120121 - `metadata: optional Metadata or null`122123 Set of 16 key-value pairs that can be attached to an object. This can be124 useful for storing additional information about the object in a structured125 format, and querying for objects via API or the dashboard.126127 Keys are strings with a maximum length of 64 characters. Values are strings128 with a maximum length of 512 characters.129130 - `model: optional string`131132 Model ID used to process the batch, like `gpt-6-astra`. OpenAI133 offers a wide range of models with different capabilities, performance134 characteristics, and price points. Refer to the [model135 guide](/api/docs/models) to browse and compare available models.136137 - `output_file_id: optional string`138139 The ID of the file containing the outputs of successfully executed requests.140141 - `request_counts: optional BatchRequestCounts`142143 The request counts for different statuses within the batch.144145 - `completed: number`146147 Number of requests that have been completed successfully.148149 - `failed: number`150151 Number of requests that have failed.152153 - `total: number`154155 Total number of requests in the batch.156157 - `usage: optional BatchUsage`158159 Represents token usage details including input tokens, output tokens, a160 breakdown of output tokens, and the total tokens used. Only populated on161 batches created after September 7, 2025.162163 - `input_tokens: number`164165 The number of input tokens.166167 - `input_tokens_details: object { cached_tokens }`168169 A detailed breakdown of the input tokens.170171 - `cached_tokens: number`172173 The number of tokens that were retrieved from the cache. [More on174 prompt caching](/api/docs/guides/prompt-caching).175176 - `output_tokens: number`177178 The number of output tokens.179180 - `output_tokens_details: object { reasoning_tokens }`181182 A detailed breakdown of the output tokens.183184 - `reasoning_tokens: number`185186 The number of reasoning tokens.187188 - `total_tokens: number`189190 The total number of tokens used.191192### Example193194```http195curl https://api.openai.com/v1/batches/$BATCH_ID \196 -H "Authorization: Bearer $OPENAI_API_KEY"197```198199#### Response200201```json202{203 "id": "id",204 "completion_window": "completion_window",205 "created_at": 0,206 "endpoint": "endpoint",207 "input_file_id": "input_file_id",208 "object": "batch",209 "status": "validating",210 "cancelled_at": 0,211 "cancelling_at": 0,212 "completed_at": 0,213 "error_file_id": "error_file_id",214 "errors": {215 "data": [216 {217 "code": "code",218 "line": 0,219 "message": "message",220 "param": "param"221 }222 ],223 "object": "object"224 },225 "expired_at": 0,226 "expires_at": 0,227 "failed_at": 0,228 "finalizing_at": 0,229 "in_progress_at": 0,230 "metadata": {231 "foo": "string"232 },233 "model": "model",234 "output_file_id": "output_file_id",235 "request_counts": {236 "completed": 0,237 "failed": 0,238 "total": 0239 },240 "usage": {241 "input_tokens": 0,242 "input_tokens_details": {243 "cached_tokens": 0244 },245 "output_tokens": 0,246 "output_tokens_details": {247 "reasoning_tokens": 0248 },249 "total_tokens": 0250 }251}252```253254### Example255256```http257curl https://api.openai.com/v1/batches/batch_abc123 \258 -H "Authorization: Bearer $OPENAI_API_KEY" \259 -H "Content-Type: application/json" \260```261262#### Response263264```json265{266 "id": "batch_abc123",267 "object": "batch",268 "endpoint": "/v1/completions",269 "errors": null,270 "input_file_id": "file-abc123",271 "completion_window": "24h",272 "status": "completed",273 "output_file_id": "file-cvaTdG",274 "error_file_id": "file-HOWS94",275 "created_at": 1711471533,276 "in_progress_at": 1711471538,277 "expires_at": 1711557933,278 "finalizing_at": 1711493133,279 "completed_at": 1711493163,280 "failed_at": null,281 "expired_at": null,282 "cancelling_at": null,283 "cancelled_at": null,284 "request_counts": {285 "total": 100,286 "completed": 95,287 "failed": 5288 },289 "metadata": {290 "customer_id": "user_123456789",291 "batch_description": "Nightly eval job",292 }293}294```295