Skip to content

Commit c97c707

Browse files
Merge pull request #1022 from mrbullwinkle/mrb_10_24_2024_pagination
[Azure OpenAI] Pagination
2 parents aaa0ee7 + 18ca678 commit c97c707

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,27 @@ client.batches.cancel("batch_abc123") # set to your batch_id for the job you wan
401401

402402
### List batch
403403

404-
List all batch jobs for a particular Azure OpenAI resource.
404+
List batch jobs for a particular Azure OpenAI resource.
405405

406406
```python
407407
client.batches.list()
408408
```
409409

410+
List methods in the Python library are paginated.
411+
412+
To list all jobs:
413+
414+
```python
415+
all_jobs = []
416+
# Automatically fetches more pages as needed.
417+
for job in client.batches.list(
418+
limit=20,
419+
):
420+
# Do something with job here
421+
all_jobs.append(job)
422+
print(all_jobs)
423+
```
424+
410425
### List batch (Preview)
411426

412427
Use the REST API to list all batch jobs with additional sorting/filtering options.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,15 @@ curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/batches/{batch_id}/cance
245245

246246
### List batch
247247

248-
List all existing batch jobs for a given Azure OpenAI resource.
248+
List existing batch jobs for a given Azure OpenAI resource.
249249

250250
```http
251251
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/batches?api-version=2024-10-21 \
252252
-H "api-key: $AZURE_OPENAI_API_KEY"
253253
```
254254

255+
The list API call is paginated. The response contains a boolean `has_more` to indicate when there are more results to iterate through.
256+
255257
<a id="List"></a>
256258

257259
### List batch (Preview)

0 commit comments

Comments
 (0)