List Batches
List all batches in the current project with pagination support.Query Parameters
Number of batches to skip (default: 0)
Number of batches to return (default: 100, max: 100)
Sort order for results (default: “desc”)
asc- Ascending order (oldest first)desc- Descending order (newest first)
Response
Array of batch objects
Create Batch
Create a new batch for processing large volumes of AI tasks asynchronously.Request Body
Descriptive name for the batch
Optional description of the batch purpose
Type of batch processing:
COMPLETIONS- For text completion/generation tasksEMBEDDINGS- For vector embedding generation
URL of the input file containing batch requests (JSONL format)
URL to receive webhook notification when batch completes
Response
Returns the created batch object with status “validating”.Get Batch
Get detailed information about a specific batch, including error details if any processing failures occurred.Path Parameters
The unique identifier of the batch
Response
Complete batch object including error details
Download Batch Files
Download the output and error files for a completed batch.Path Parameters
The unique identifier of the completed batch
Response
Pre-signed URL to download the batch output file (JSONL format)
Pre-signed URL to download the batch errors file (if any errors occurred)
Download URLs are temporary and expire after a short period. Download the files immediately after receiving the URLs.
Check Batch Status
Administrative endpoint to check and update the status of all batches. This endpoint is typically used by system administrators or automated processes.Response
Returns the result of the batch status check operation.Input File Format
Batch input files must be in JSONL (JSON Lines) format, with each line containing a valid JSON object representing a single request.Completions Batch Format
For text completion tasks, each line should contain:Embeddings Batch Format
For embedding generation tasks, each line should contain:Output File Format
Output files are also in JSONL format, with each line containing the response for the corresponding input request:Webhook Notifications
When your batch completes, PLai will send a webhook notification to thecallback_url you specified:
Webhook Payload
Webhook Events
batch.completed
batch.completed
Sent when a batch finishes processing successfully
batch.failed
batch.failed
Sent when a batch fails due to validation or processing errors
batch.expired
batch.expired
Sent when a batch expires before completion
batch.cancelled
batch.cancelled
Sent when a batch is cancelled manually
Best Practices
1
File Size Optimization
Keep input files under 100MB for optimal processing speed. Split larger datasets into multiple batches.
2
Custom IDs
Use meaningful custom IDs that help you correlate responses with your original requests.
3
Error Handling
Always check for both output and error files. Handle partial failures gracefully.
4
Webhook Security
Implement webhook signature verification to ensure notifications come from PLai.
5
Rate Limiting
Batch processing helps avoid rate limits, but don’t submit too many concurrent batches.
Cost Optimization
Monitoring and Troubleshooting
Monitor Progress
Check batch status regularly and set up proper webhook handling for notifications
Error Recovery
Download error files to identify failed requests and reprocess them if needed
Performance Tuning
Optimize batch size and request complexity based on processing times
Backup Strategy
Keep copies of input files and download output files promptly before they expire