Batch API

A batch runs many chat requests as one job: you upload them as a file, and collect a file of results when the job is done. The longer the window you allow, the lower the price multiplier. It follows the OpenAI Batch API.

Batches and their files are visible only to the account that made them: GET /v1/batches lists only yours, and another account's batch or file answers 404.

1. Write the requests

One JSON object per line. Each line needs a unique custom_id, a model the network serves, and stream left off:

Terminal
cat > batch.jsonl <<'EOF'
{"custom_id":"req-1","method":"POST","url":"/v1/chat/completions","body":{"model":"qwen3.8-27b-8k","messages":[{"role":"user","content":"Say hi. /no_think"}],"max_tokens":20}}
{"custom_id":"req-2","method":"POST","url":"/v1/chat/completions","body":{"model":"qwen3.8-27b-8k","messages":[{"role":"user","content":"Name a color. /no_think"}],"max_tokens":20}}
EOF

2. Upload the file

Every Batch API call needs your API key in the Authorization header, as in Use the network; without it, it fails with 401.

Terminal
curl https://coordinator.holonear.app/v1/files \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F purpose=batch \
  -F [email protected]

The reply carries the file id, for example file-9ab864e6-….

3. Create the batch

Terminal
curl https://coordinator.holonear.app/v1/batches \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input_file_id": "<file id>", "endpoint": "/v1/chat/completions", "completion_window": "24h"}'

The reply is the batch object: its id, status and the price_multiplier fixed for this batch.

4. Wait, then collect the results

Terminal
curl https://coordinator.holonear.app/v1/batches/<batch id> \
  -H "Authorization: Bearer YOUR_API_KEY"

When status is completed, download the results from output_file_id. Each line holds the custom_id and the full chat response:

Terminal
curl https://coordinator.holonear.app/v1/files/<output file id>/content \
  -H "Authorization: Bearer YOUR_API_KEY"

Requests in a batch are served by the same nodes as real-time requests, so a batch finishes only while a node is serving its model. In our test, two requests finished in 2 seconds.

Completion windows and price

completion_window sets how long the batch may take, and the multiplier applied to the model's per-token price for every request in it:

completion_windowDeadlinePrice multiplier
5m5 minutes1.50
20m20 minutes1.25
1h1 hour1.00
2h2 hours0.85
6h6 hours0.70
24h24 hours0.50
auto24 hours0.50
  • The multiplier is fixed when the batch is created, so later price changes do not affect it.