Batch and async requests
Some work does not need an answer at once. Queue it, and get the answers later. Queued work runs when replicas have free time.
Async requests#
An async request is one chat completion that runs later.
- Send
POST /control/v1/async/chat/completions. Put a normal chat request inrequest. - Keep the job ID of the response.
- Send
GET /control/v1/async/{job_id}to get the status, and the answer when it is done.
The answer is kept, encrypted with the key of your organization, for 24 hours or until you get it. After you get it, it is deleted.
Batches#
A batch is up to 1,000 chat completions of one model.
curl "$EMBER_API_URL/control/v1/batches" \
-H "Authorization: Bearer $EMBER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"requests": [
{"custom_id": "row-1", "request": {"model": "<model ID>", "messages": [{"role": "user", "content": "Summarize: ..."}]}},
{"custom_id": "row-2", "request": {"model": "<model ID>", "messages": [{"role": "user", "content": "Summarize: ..."}]}}
]}'
GET /control/v1/batches/{batch_id}gives the status and the counts.GET /control/v1/batches/{batch_id}/resultsgives the finished requests. Each result has yourcustom_id.
Batches run after async requests. The answers are kept, encrypted, for 7 days.
Webhooks#
Add webhook_url to get a call when the work is done. The URL must be a public https URL on port 443. The call has only the ID and the status, never the answer.
For a batch, the call is signed with webhook_secret. Check the signature before you trust the call.
Keys#
Async requests and batches need a key with the scope inference.