You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extra_body={"expires_after":{"seconds": 1209600, "anchor": "created_at"}} # Optional you can set to a number between 1209600-2592000. This is equivalent to 14-30 days
extra_body={"expires_after":{"seconds": 1209600, "anchor": "created_at"}} # Optional you can set to a number between 1209600-2592000. This is equivalent to 14-30 days
By adding `extra_body={"expires_after":{"seconds": 1209600, "anchor": "created_at"}}` you are setting our upload file to expire in 14 days. There is a max limit of 500 batch files per resource when no expiration is set. By setting a value for expiration the number of batch files per resource is increased to 10,000 files per resource.
148
+
137
149
**Output:**
138
150
139
151
```json
140
152
{
141
-
"id": "file-9f3a81d899b4442f98b640e4bc3535dd",
142
-
"bytes": 815,
143
-
"created_at": 1722476551,
153
+
"id": "file-655111ec9cfc44489d9af078f08116ef",
154
+
"bytes": 176064,
155
+
"created_at": 1743391067,
144
156
"filename": "test.jsonl",
145
157
"object": "file",
146
158
"purpose": "batch",
147
-
"status": null,
159
+
"status": "processed",
160
+
"expires_at": 1744600667,
148
161
"status_details": null
149
162
}
163
+
File expiration: 2025-04-13 23:17:47
150
164
```
151
165
166
+
167
+
152
168
## Create batch job
153
169
154
170
Once your file has uploaded successfully you can submit the file for batch processing.
extra_body={"output_expires_after":{"seconds": 1209600, "anchor": "created_at"}} # Optional you can set to a number between 1209600-2592000. This is equivalent to 14-30 days
179
+
)
162
180
)
163
181
164
182
# Save batch ID for later use
165
183
batch_id = batch_response.id
166
184
167
185
print(batch_response.model_dump_json(indent=2))
186
+
168
187
```
169
188
189
+
The default 500 max file limit per resource also applies to output files. Here you add `extra_body={"output_expires_after":{"seconds": 1209600, "anchor": "created_at"}}` so that your output files expire in 14 days. By setting a value for expiration the number of batch files per resource is increased to 10,000 files per resource.
190
+
170
191
> [!NOTE]
171
192
> Currently the completion window must be set to 24h. If you set any other value than 24h your job will fail. Jobs taking longer than 24 hours will continue to execute until canceled.
The above code assumes a particular file path for your test.jsonl file. Adjust this file path as necessary for your local system.
87
+
The above code assumes a particular file path for your test.jsonl file. Adjust this file path as necessary for your local system.
88
+
89
+
By adding `"expires_after.seconds=1209600"` and `"expires_after.anchor=created_at"` you are setting your upload file to expire in 14 days. There is a max limit of 500 batch files per resource when no expiration is set. By setting a value for expiration the number of batch files per resource is increased to 10,000 files per resource. You can set to a number between 1209600-2592000. This is equivalent to 14-30 days.
90
+
91
+
85
92
86
93
**Output:**
87
94
88
95
```json
89
96
{
90
-
"status": "pending",
91
-
"bytes": 686,
97
+
"status": "processed",
98
+
"bytes": 817,
92
99
"purpose": "batch",
93
100
"filename": "test.jsonl",
94
-
"id": "file-21006e70789246658b86a1fc205899a4",
95
-
"created_at": 1721408291,
101
+
"expires_at": 1744607747,
102
+
"id": "file-7733bc35e32841e297a62a9ee50b3461",
103
+
"created_at": 1743398147,
96
104
"object": "file"
97
105
}
98
106
@@ -104,7 +112,7 @@ The above code assumes a particular file path for your test.jsonl file. Adjust t
104
112
Depending on the size of your upload file it might take some time before it's fully uploaded and processed. To check on your file upload status run:
Once your file has uploaded successfully you can submit the file for batch processing.
129
138
130
139
```http
131
-
curl -X POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/batches?api-version=2024-10-21 \
140
+
curl -X POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/batches?api-version=2025-03-01-preview \
132
141
-H "api-key: $AZURE_OPENAI_API_KEY" \
133
142
-H "Content-Type: application/json" \
134
143
-d '{
135
144
"input_file_id": "file-abc123",
136
145
"endpoint": "/chat/completions",
137
-
"completion_window": "24h"
146
+
"completion_window": "24h",
147
+
"output_expires_after": {
148
+
"seconds": 1209600
149
+
},
150
+
"anchor": "created_at"
138
151
}'
139
152
```
140
153
154
+
The default 500 max file limit per resource also applies to output files. Here you add `"output_expires_after":{"seconds": 1209600},` and `"anchor": "created_at"` so that your output files expire in 14 days. By setting a value for expiration the number of batch files per resource is increased to 10,000 files per resource.
155
+
141
156
> [!NOTE]
142
157
> Currently the completion window must be set to 24h. If you set any other value than 24h your job will fail. Jobs taking longer than 24 hours will continue to execute until canceled.
0 commit comments