Webhooks
Get a POST when an Async request or a batch finishes.
Enable
Add these headers when you send an Async request or create a batch:
x-qlo-webhook-url: anhttpsURL.x-qlo-webhook-secret: optional, 16 to 256 characters. Use it to sign each call.
Event
{
"id": "evt_batch_...",
"object": "event",
"type": "batch.completed",
"created_at": 1763686400,
"data": { "id": "batch_..." }
}type is one of: chat.completion.completed, chat.completion.failed, chat.completion.cancelled, batch.completed, batch.cancelled.
The event does not contain the result. Get the result with data.id.
Return a 2xx status within 10 seconds. If not, the API tries again for approximately 6 hours. Use the webhook-id header to find repeated calls.
Verify the signature
Signatures use the Standard Webhooks format. Standard Webhooks libraries verify them.
import base64, hashlib, hmac
def verify(secret: str, headers: dict, body: bytes) -> bool:
key = base64.b64decode(secret[6:]) if secret.startswith("whsec_") else secret.encode()
signed = f"{headers['webhook-id']}.{headers['webhook-timestamp']}.".encode() + body
expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
return any(hmac.compare_digest(s.split(",", 1)[-1], expected) for s in headers["webhook-signature"].split())