Batch Processing
Submit your first batch job in five lines of Python. Batch processing is 50% off serverless pricing.
1. Get an API key
export PARASAIL_API_KEY="your-api-key-here"2. Install the batch helper library
pip install openai-batch3. Submit your first batch
import random
from openai_batch import Batch
with Batch() as batch:
objects = ["cat", "robot", "coffee mug", "spaceship", "banana"]
for i in range(100):
batch.add_to_batch(
model="NousResearch/DeepHermes-3-Mistral-24B-Preview",
messages=[{"role": "user", "content": f"Tell me a joke about a {random.choice(objects)}"}]
)
result, output_path, error_path = batch.submit_wait_download()
print(f"Batch completed with status {result.status} and stored in {output_path}")4. Monitor via the Batch UI
Key features
Next steps
Last updated