Docs menu
Optimization

Batches

For work that can wait, submit many requests at once. They run in the background on providers' discounted batch capacity — typically about half price.

Submit a batch

POST https://api.sluice.one/v1/batches with up to 10,000 requests. Each item has a custom_id (1–64 of A–Z a–z 0–9 _ -) and a body that's an ordinary chat completion. Streaming isn't available inside a batch. It returns a batch object immediately.

POST https://api.sluice.one/v1/batches

{
  "completion_window": "24h",
  "requests": [
    { "custom_id": "row-1", "body": { "model": "llama-3.3-70b", "messages": [{ "role": "user", "content": "Summarize: ..." }] } },
    { "custom_id": "row-2", "body": { "model": "llama-3.3-70b", "messages": [{ "role": "user", "content": "Summarize: ..." }] } }
  ]
}

Track & collect

Poll the batch, then fetch results when it's done. Each result carries its custom_id so you can line them up with your inputs.

GET /batches/:id
Status and request_counts (total / completed / failed).
GET /batches/:id/results
Per-request results: { custom_id, status, response, error }.
GET /batches
List your batches.
POST /batches/:id/cancel
Cancel a batch that's still running.
GET https://api.sluice.one/v1/batches/batch_.../results

{
  "object": "list",
  "batch": { "id": "batch_...", "status": "completed", "request_counts": { "total": 2, "completed": 2, "failed": 0 } },
  "data": [
    { "custom_id": "row-1", "status": "ok", "response": { "choices": [ ... ], "sluice": { ... } }, "error": null },
    { "custom_id": "row-2", "status": "ok", "response": { "choices": [ ... ], "sluice": { ... } }, "error": null }
  ]
}
Good to know
Batches need an account API key and enough balance to cover the worst case up front. Pricing uses discounted batch capacity where the provider offers it, so the final cost is at or below normal routing.