Skip to content

Commit 46903bf

Browse files
Merge pull request #4209 from mrbullwinkle/mrb_04_17_2025_batch
[Azure OpenAI] Batch updates file expiration + fail fast region changes
2 parents 824dbaa + 06dbf69 commit 46903bf

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

articles/ai-services/openai/includes/batch/batch-python.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ client = AzureOpenAI(
102102
file = client.files.create(
103103
file=open("test.jsonl", "rb"),
104104
purpose="batch",
105-
#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
105+
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
106106
)
107107

108108

109109
print(file.model_dump_json(indent=2))
110110

111-
#print(f"File expiration: {datetime.fromtimestamp(file.expires_at) if file.expires_at is not None else 'Not set'}")
111+
print(f"File expiration: {datetime.fromtimestamp(file.expires_at) if file.expires_at is not None else 'Not set'}")
112112

113113
file_id = file.id
114114
```
@@ -131,20 +131,20 @@ client = AzureOpenAI(
131131
file = client.files.create(
132132
file=open("test.jsonl", "rb"),
133133
purpose="batch",
134-
#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
134+
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
135135
)
136136

137137

138138
print(file.model_dump_json(indent=2))
139139

140-
#print(f"File expiration: {datetime.fromtimestamp(file.expires_at) if file.expires_at is not None else 'Not set'}")
140+
print(f"File expiration: {datetime.fromtimestamp(file.expires_at) if file.expires_at is not None else 'Not set'}")
141141

142142
file_id = file.id
143143
```
144144

145145
---
146146

147-
By uncommenting and adding `extra_body={"expires_after":{"seconds": 1209600, "anchor": "created_at"}}` you're setting our upload file to expire in 14 days. There's 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. This feature isn't currently available in all regions. Output when file upload expiration is set:
147+
By uncommenting and adding `extra_body={"expires_after":{"seconds": 1209600, "anchor": "created_at"}}` you're setting our upload file to expire in 14 days. There's 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.
148148

149149
**Output:**
150150

@@ -175,7 +175,7 @@ batch_response = client.batches.create(
175175
input_file_id=file_id,
176176
endpoint="/chat/completions",
177177
completion_window="24h",
178-
#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
178+
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
179179
)
180180

181181

@@ -186,7 +186,7 @@ print(batch_response.model_dump_json(indent=2))
186186

187187
```
188188

189-
The default 500 max file limit per resource also applies to output files. Here you can uncomment this line to 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. This feature isn't currently available in all regions.
189+
The default 500 max file limit per resource also applies to output files. Here you can uncomment this line to 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.
190190

191191
> [!NOTE]
192192
> 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.
@@ -674,6 +674,7 @@ The following regions support the new fail fast behavior:
674674
- northcentralus
675675
- polandcentral
676676
- swedencentral
677+
- switzerlandnorth
677678
- eastus2
678679
- westus
679680

articles/ai-services/openai/includes/batch/batch-rest.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ curl -X POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/files?api-versio
8686

8787
The above code assumes a particular file path for your test.jsonl file. Adjust this file path as necessary for your local system.
8888

89-
By adding the optional `"expires_after.seconds=1209600"` and `"expires_after.anchor=created_at"` parameters you're setting your upload file to expire in 14 days. There's 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. This feature isn't currently available in all regions.
89+
By adding the optional `"expires_after.seconds=1209600"` and `"expires_after.anchor=created_at"` parameters you're setting your upload file to expire in 14 days. There's 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.
9090

9191

9292

@@ -151,7 +151,7 @@ curl -X POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/batches?api-vers
151151
}'
152152
```
153153

154-
The default 500 max file limit per resource also applies to output files. Here you can optionally 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. The file expiration feature is currently not available in all regions.
154+
The default 500 max file limit per resource also applies to output files. Here you can optionally 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.
155155

156156
> [!NOTE]
157157
> 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

Comments
 (0)