Batch API

View as Markdown

The Batch API is for asynchronous, high-volume inference jobs where you do not need an answer immediately.

Workflow

  1. Prepare a request bundle
  2. Create a batch with POST /v1/batches
  3. Poll GET /v1/batches/{batch_id} — results are included inline once complete

1 & 2. Create the batch

Pass your requests inline — no separate file upload required.

$curl https://api.meshapi.ai/v1/batches \
> -H "Authorization: Bearer <YOUR_RSK_KEY>" \
> -H "Content-Type: application/json" \
> -d '{
> "requests": [
> {
> "custom_id": "doc-001",
> "body": {
> "model": "openai/gpt-5.4",
> "messages": [{ "role": "user", "content": "Summarize this note." }]
> }
> }
> ],
> "completion_window": "24h"
> }'

3. Poll and read results

Poll until status is a terminal value. When completed, the response includes a results array — no separate file download needed.

$curl https://api.meshapi.ai/v1/batches/batch_xyz789 \
> -H "Authorization: Bearer <YOUR_RSK_KEY>"
1{
2 "id": "batch_xyz789",
3 "status": "completed",
4 "request_counts": { "total": 1, "completed": 1, "failed": 0 },
5 "results": [
6 {
7 "custom_id": "doc-001",
8 "response": {
9 "status_code": 200,
10 "body": {
11 "choices": [{ "message": { "content": "The note says..." } }],
12 "usage": { "prompt_tokens": 12, "completion_tokens": 40 }
13 }
14 },
15 "error": null
16 }
17 ]
18}

Common statuses:

  • validating
  • in_progress
  • finalizing
  • completed
  • failed
  • cancelled
  • expired

Notes

  • All requests in a batch must use the same model.
  • Batch jobs are best for throughput, not low-latency interactive use.
  • Use GET /v1/batches to list recent batches and POST /v1/batches/{batch_id}/cancel to cancel one.
  • Results are matched by custom_id — the output order is not guaranteed.