Batch processing
When you need to process a large number of items — classify support tickets, summarize articles, extract entities — you want concurrency and rate-limit awareness. This example shows how to do it safely and efficiently.Read a dataset
Assume you have areviews.jsonl file with one JSON object per line:
reviews.jsonl
Process with async and semaphores
batch.py
Run it
Output
results.jsonl
Adding retries and backoff
Production scripts should handle transient failures:batch_with_retries.py
Choosing a model
Next steps
Structured extraction
Extract JSON from each document
Rate limits
Understand limits and headers