cli/resources/batches/methods/retrieve/index.md +0 −253 deleted
File Deleted View Diff
1## Retrieve batch
2
3`$ openai batches retrieve`
4
5**get** `/batches/{batch_id}`
6
7Retrieves a batch.
8
9### Parameters
10
11- `--batch-id: string`
12
13 The ID of the batch to retrieve.
14
15### Returns
16
17- `batch: object { id, completion_window, created_at, 19 more }`
18
19 - `id: string`
20
21 - `completion_window: string`
22
23 The time frame within which the batch should be processed.
24
25 - `created_at: number`
26
27 The Unix timestamp (in seconds) for when the batch was created.
28
29 - `endpoint: string`
30
31 The OpenAI API endpoint used by the batch.
32
33 - `input_file_id: string`
34
35 The ID of the input file for the batch.
36
37 - `object: "batch"`
38
39 The object type, which is always `batch`.
40
41 - `status: "validating" or "failed" or "in_progress" or 5 more`
42
43 The current status of the batch.
44
45 - `"validating"`
46
47 - `"failed"`
48
49 - `"in_progress"`
50
51 - `"finalizing"`
52
53 - `"completed"`
54
55 - `"expired"`
56
57 - `"cancelling"`
58
59 - `"cancelled"`
60
61 - `cancelled_at: optional number`
62
63 The Unix timestamp (in seconds) for when the batch was cancelled.
64
65 - `cancelling_at: optional number`
66
67 The Unix timestamp (in seconds) for when the batch started cancelling.
68
69 - `completed_at: optional number`
70
71 The Unix timestamp (in seconds) for when the batch was completed.
72
73 - `error_file_id: optional string`
74
75 The ID of the file containing the outputs of requests with errors.
76
77 - `errors: optional object { data, object }`
78
79 - `data: optional array of BatchError`
80
81 - `code: optional string`
82
83 An error code identifying the error type.
84
85 - `line: optional number`
86
87 The line number of the input file where the error occurred, if applicable.
88
89 - `message: optional string`
90
91 A human-readable message providing more details about the error.
92
93 - `param: optional string`
94
95 The name of the parameter that caused the error, if applicable.
96
97 - `object: optional string`
98
99 The object type, which is always `list`.
100
101 - `expired_at: optional number`
102
103 The Unix timestamp (in seconds) for when the batch expired.
104
105 - `expires_at: optional number`
106
107 The Unix timestamp (in seconds) for when the batch will expire.
108
109 - `failed_at: optional number`
110
111 The Unix timestamp (in seconds) for when the batch failed.
112
113 - `finalizing_at: optional number`
114
115 The Unix timestamp (in seconds) for when the batch started finalizing.
116
117 - `in_progress_at: optional number`
118
119 The Unix timestamp (in seconds) for when the batch started processing.
120
121 - `metadata: optional map[string]`
122
123 Set of 16 key-value pairs that can be attached to an object. This can be
124 useful for storing additional information about the object in a structured
125 format, and querying for objects via API or the dashboard.
126
127 Keys are strings with a maximum length of 64 characters. Values are strings
128 with a maximum length of 512 characters.
129
130 - `model: optional string`
131
132 Model ID used to process the batch, like `gpt-5-2025-08-07`. OpenAI
133 offers a wide range of models with different capabilities, performance
134 characteristics, and price points. Refer to the [model
135 guide](https://platform.openai.com/docs/models) to browse and compare available models.
136
137 - `output_file_id: optional string`
138
139 The ID of the file containing the outputs of successfully executed requests.
140
141 - `request_counts: optional object { completed, failed, total }`
142
143 The request counts for different statuses within the batch.
144
145 - `completed: number`
146
147 Number of requests that have been completed successfully.
148
149 - `failed: number`
150
151 Number of requests that have failed.
152
153 - `total: number`
154
155 Total number of requests in the batch.
156
157 - `usage: optional object { input_tokens, input_tokens_details, output_tokens, 2 more }`
158
159 Represents token usage details including input tokens, output tokens, a
160 breakdown of output tokens, and the total tokens used. Only populated on
161 batches created after September 7, 2025.
162
163 - `input_tokens: number`
164
165 The number of input tokens.
166
167 - `input_tokens_details: object { cached_tokens }`
168
169 A detailed breakdown of the input tokens.
170
171 - `cached_tokens: number`
172
173 The number of tokens that were retrieved from the cache. [More on
174 prompt caching](https://platform.openai.com/docs/guides/prompt-caching).
175
176 - `output_tokens: number`
177
178 The number of output tokens.
179
180 - `output_tokens_details: object { reasoning_tokens }`
181
182 A detailed breakdown of the output tokens.
183
184 - `reasoning_tokens: number`
185
186 The number of reasoning tokens.
187
188 - `total_tokens: number`
189
190 The total number of tokens used.
191
192### Example
193
194```cli
195openai batches retrieve \
196 --api-key 'My API Key' \
197 --batch-id batch_id
198```
199
200#### Response
201
202```json
203{
204 "id": "id",
205 "completion_window": "completion_window",
206 "created_at": 0,
207 "endpoint": "endpoint",
208 "input_file_id": "input_file_id",
209 "object": "batch",
210 "status": "validating",
211 "cancelled_at": 0,
212 "cancelling_at": 0,
213 "completed_at": 0,
214 "error_file_id": "error_file_id",
215 "errors": {
216 "data": [
217 {
218 "code": "code",
219 "line": 0,
220 "message": "message",
221 "param": "param"
222 }
223 ],
224 "object": "object"
225 },
226 "expired_at": 0,
227 "expires_at": 0,
228 "failed_at": 0,
229 "finalizing_at": 0,
230 "in_progress_at": 0,
231 "metadata": {
232 "foo": "string"
233 },
234 "model": "model",
235 "output_file_id": "output_file_id",
236 "request_counts": {
237 "completed": 0,
238 "failed": 0,
239 "total": 0
240 },
241 "usage": {
242 "input_tokens": 0,
243 "input_tokens_details": {
244 "cached_tokens": 0
245 },
246 "output_tokens": 0,
247 "output_tokens_details": {
248 "reasoning_tokens": 0
249 },
250 "total_tokens": 0
251 }
252}
253```