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:
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}}
EOF2. 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.
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
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
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:
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_window | Deadline | Price multiplier |
|---|---|---|
5m | 5 minutes | 1.50 |
20m | 20 minutes | 1.25 |
1h | 1 hour | 1.00 |
2h | 2 hours | 0.85 |
6h | 6 hours | 0.70 |
24h | 24 hours | 0.50 |
auto | 24 hours | 0.50 |
- The multiplier is fixed when the batch is created, so later price changes do not affect it.