Get Batch
Get batch status and details using GET /v1/batch/:id.
Get Batch
Retrieve the status and details of a specific batch job.
GET
/v1/batch/:idGet detailed information about a batch job including progress.
Path Parameters
Parameters
| Parameter | Type | Description |
|---|
Example Request
Response
Success Response (200)
{
"id": "batch_abc123def456",
"name": "Daily fact check",
"inputFormat": "json",
"originalFileName": null,
"status": "completed",
"totalItems": 50,
"processedItems": 50,
"successCount": 48,
"failureCount": 2,
"methodsConfig": {
"reasoning": 1,
"tool": 0.5
},
"context": {
"source": "news-aggregator"
},
"totalCostCents": 250,
"totalInputTokens": 12500,
"totalOutputTokens": 8700,
"errorMessage": null,
"validationErrors": null,
"createdAt": "2024-01-15T10:00:00Z",
"startedAt": "2024-01-15T10:00:01Z",
"completedAt": "2024-01-15T10:02:30Z",
"expiresAt": "2024-02-14T10:00:00Z"
}Processing Batch
{
"id": "batch_xyz789",
"name": "Article verification",
"status": "processing",
"totalItems": 100,
"processedItems": 45,
"successCount": 44,
"failureCount": 1,
"completedAt": null
// ... other fields
}Failed Batch (Validation Errors)
{
"id": "batch_failed123",
"status": "failed",
"totalItems": 10,
"processedItems": 0,
"errorMessage": "3 validation error(s)",
"validationErrors": [
{ "row": 1, "error": "Content is required" },
{ "row": 5, "error": "Content exceeds maximum length" },
{ "row": 8, "error": "Content is required" }
]
// ... other fields
}Response Fields
| Parameter | Type | Description |
|---|
Error Responses
404 Not Found
{
"error": {
"code": "not_found",
"message": "Batch not found"
}
}Polling for Completion
async function waitForBatch(client, batchId, intervalMs = 2000) {
while (true) {
const batch = await client.getBatch(batchId);
if (batch.status === 'completed' || batch.status === 'failed' || batch.status === 'cancelled') {
return batch;
}
console.log(`Progress: ${batch.processedItems}/${batch.totalItems}`);
await new Promise(resolve => setTimeout(resolve, intervalMs));
}
}Use the SDK's createBatchAndWait() method for automatic polling with exponential backoff.