Callbacks

Receive signed server-to-server notifications and completed async results.

Callbacks

Configure a callback URL in Profile → Callbacks and async results. Model Gate sends HTTPS POST requests for enabled account notifications and for completed asynchronous inference requests.

Callback URL

Use a publicly reachable HTTPS endpoint. The endpoint should read the raw request body, verify the signature, process the event idempotently, and return HTTP 200 as soon as the event has been accepted.

Events

Callbacks may include:

  • completed async inference results;
  • low account balance notifications when enabled;
  • API-key spending-limit notifications when enabled;
  • key-group spending-limit notifications when enabled.

Async result delivery is enabled whenever a callback URL is configured. The notification checkboxes in Profile control only the corresponding balance and limit alerts.

Request format

POST /model-gate/callback HTTP/1.1
Content-Type: application/json
X-Model-Gate-Signature: t=1710000000,v1=hex_hmac_sha256

Example async result payload:

{
  "event":"async.completed",
  "request_id":"01J...",
  "status":"completed",
  "response":{"id":"msg_...","type":"message"}
}

Payload fields can be extended over time. Ignore unknown fields.

Signature verification

The signature header has this format:

X-Model-Gate-Signature: t=<unix>,v1=<hmac_sha256>

Calculate HMAC-SHA256 over the exact string <timestamp>.<raw_body> using the callback secret shown in Profile. Compare the hexadecimal signature with a constant-time comparison and reject timestamps outside your accepted replay window.

Delivery and retries

Return HTTP 200 after safely accepting the event. Non-2xx responses and connection failures may be retried. Your endpoint must therefore be idempotent; use request_id together with event as a deduplication key.

Do not perform long-running work before responding. Queue the event internally, return 200, and process it asynchronously.