Implementation:Groq Groq python Batches Retrieve
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Batch_Processing, Async_Patterns |
| Last Updated | 2026-02-15 16:00 GMT |
Overview
Concrete tool for retrieving batch job status provided by the Groq Python SDK.
Description
The Batches.retrieve() method GETs /openai/v1/batches/{batch_id} to check the current status of a batch processing job. Returns a BatchRetrieveResponse with status, output_file_id (when completed), error_file_id, and request counts.
Usage
Access via client.batches.retrieve(batch_id). Use in a polling loop to wait for completion.
Code Reference
Source Location
- Repository: groq-python
- File: src/groq/resources/batches.py
- Lines: L109-140 (sync), L274-305 (async)
Signature
class Batches(SyncAPIResource):
def retrieve(
self,
batch_id: str,
) -> BatchRetrieveResponse:
Import
from groq import Groq
# Access via: client.batches.retrieve(batch_id)
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| batch_id | str | Yes | The batch ID to check (positional) |
Outputs
| Name | Type | Description |
|---|---|---|
| (return).status | Literal["validating", "failed", "in_progress", "finalizing", "completed", "expired", "cancelling", "cancelled"] | Current batch status |
| (return).output_file_id | Optional[str] | File ID of results (available when completed) |
| (return).error_file_id | Optional[str] | File ID of errors (if any) |
| (return).request_counts | RequestCounts | Completed/failed/total request counts |
Usage Examples
import time
# Poll until completion
while True:
batch_status = client.batches.retrieve(batch.id)
print(f"Status: {batch_status.status}")
if batch_status.status == "completed":
output_file_id = batch_status.output_file_id
break
elif batch_status.status in ("failed", "expired", "cancelled"):
raise RuntimeError(f"Batch {batch_status.status}")
time.sleep(60)
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment