Webhooks reference
Payload structures, headers, retry timing, and response codes for asynchronous inference webhooks.
Payloads, headers, and delivery rules for asynchronous inference webhooks. For a step-by-step setup, see Webhooks.
Dashboard management
Manage webhooks in Settings → Webhooks:
- Create a webhook with a name and HTTPS URL.
- Send a test event, disable or enable, or delete a webhook, and see its recent invocation stats.
- Copy the webhook identifier to use in generation requests.
Payload structures
generation.completed
{
"event": "generation.completed",
"timestamp": "ISO 8601 timestamp",
"webhookId": "webhook identifier",
"data": {
"id": "generation ID",
"state": "Success|Failed|Queued|In Progress",
"stateMessage": "Human readable status",
"request": { /* Original request or null */ },
"response": { /* OpenAI format response or null */ },
"model": "model ID",
"createdAt": "ISO 8601 timestamp",
"dispatchedAt": "ISO 8601 timestamp or null",
"firstChunkAt": "ISO 8601 timestamp or null",
"finishedAt": "ISO 8601 timestamp or null",
"deadlineAt": "ISO 8601 timestamp or null",
"usage": { /* Token usage */ },
"error": { "status": 400, "type": "context_length_exceeded" }
}
}The generation ID is data.id. The response object is compatible with the
OpenAI SDK types.
data.error is set when a failed generation's cause is known, and null
otherwise. error.status is the HTTP status the request failed with and
error.type a short error code. A 4xx status other than 429 means the request
itself was rejected: it fails again if you resend it unchanged. A 429 or 5xx
status is temporary, so retrying the same request can succeed. Queued requests continue processing
after the submitting client disconnects; disconnecting does not cancel
asynchronous work. With Zero Data Retention on, stateMessage has no error
text, but error is still set.
async-embedding.completed
{
"event": "async-embedding.completed",
"timestamp": "ISO 8601 timestamp",
"webhookId": "webhook identifier",
"data": {
"id": "generation ID",
"state": "Success|Failed|Queued|In Progress",
"stateMessage": "Human readable status",
"request": { /* Original embeddings request or null */ },
"response": { /* OpenAI format embeddings response or null */ },
"model": "model ID",
"createdAt": "ISO 8601 timestamp",
"dispatchedAt": "ISO 8601 timestamp or null",
"firstChunkAt": "ISO 8601 timestamp or null",
"finishedAt": "ISO 8601 timestamp or null",
"deadlineAt": "ISO 8601 timestamp or null",
"usage": { /* Token usage */ },
"error": null
}
}slow-group.completed
{
"event": "slow-group.completed",
"timestamp": "ISO 8601 timestamp",
"groupId": "group ID",
"data": {
"groupSize": 2,
"status": "completed|failed",
"generations": [
{
"id": "generation ID",
"state": "Success|Failed|Queued|In Progress",
"stateMessage": "Human readable status",
"request": { /* Original request or null */ },
"response": { /* OpenAI format response or null */ },
"model": "model ID",
"createdAt": "ISO 8601 timestamp",
"dispatchedAt": "ISO 8601 timestamp or null",
"firstChunkAt": "ISO 8601 timestamp or null",
"finishedAt": "ISO 8601 timestamp or null",
"deadlineAt": "ISO 8601 timestamp or null",
"usage": { /* Token usage */ },
"error": null
}
]
}
}data.status is failed when the group could not finish: processing failed,
or the group passed its 72-hour completion window. Check each entry's state
in generations to see which requests finished.
Dashboard test events
A test from
Settings → Webhooks sends a sample payload
for the event type you choose (generation.completed, slow-group.completed, or
async-embedding.completed). The payload has the same
shape and headers as a real delivery, with test-model as the model (test-embedding-model for
async-embedding.completed) and IDs that
start with test- (for example test-generation-1767225600000), so your
endpoint can tell a test from a real event.
Headers
| Header | Description | Example |
|---|---|---|
X-Inference-Event | Event type | generation.completed, async-embedding.completed, or slow-group.completed |
X-Inference-Webhook-ID | Webhook identifier | AhALzdz8S |
X-Inference-Generation-ID | Generation ID (generation events) | XBKcs7F1s2oJ_AHiLMbF4 |
X-Inference-Embedding-ID | Generation ID (embedding events) | XBKcs7F1s2oJ_AHiLMbF4 |
X-Inference-Group-ID | Group ID (group events) | GRP_XYZ123 |
X-Inference-Delivery-Attempt | Delivery attempt, starting at 1 | 1 |
User-Agent | Inference.net webhook agent | Kuzco-Webhook/1.0 |
Content-Type | Always application/json | application/json |
Use a webhook in a generation
Include the webhook identifier in the request metadata:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.inference.net/v1/slow",
apiKey: process.env.INFERENCE_API_KEY,
});
const response = await client.chat.completions.create({
model: "kimi-k3-fast",
messages: [{ role: "user", content: "Hello!" }],
// @ts-expect-error metadata is not in the OpenAI SDK types
metadata: { webhook_id: "YOUR_WEBHOOK_IDENTIFIER" },
});For groups, pass webhook_id at the top level of the request body. See
Group API.
If webhook_id does not match a webhook in your team, the request fails with
400 and error type WebhookNotFound.
With Zero Data Retention
With the Zero Data Retention (ZDR) team setting on:
- A
/v1/slowrequest must setmetadata.webhook_id, or it fails with400. - A disabled webhook fails with
400and error typeWebhookDisabled. - The result is delivered only through the webhook. Its request and response content is purged once delivery succeeds, its 24 attempts (about 3 days) run out, or the webhook can no longer be delivered (deleted, disabled, or its URL is not allowed).
See Data retention.
Minimal handlers
app.post("/webhook", express.json(), (req, res) => {
res.status(200).json({ received: true });
if (req.body.event === "generation.completed") {
setImmediate(() => {
console.log("Generation completed:", req.body.data.id);
// Your processing logic here
});
} else if (req.body.event === "async-embedding.completed") {
setImmediate(() => {
console.log("Embedding completed:", req.body.data.id);
console.log("Number of embeddings:", req.body.data.response.data.length);
});
} else if (req.body.event === "slow-group.completed") {
setImmediate(() => {
console.log("Group completed:", req.body.groupId);
console.log("Group size:", req.body.data.groupSize);
req.body.data.generations.forEach((gen: any) => {
console.log(`Generation ${gen.id}: ${gen.state}`);
});
});
}
});Retries and delivery
Each delivery attempt is one POST to your URL, with no OPTIONS preflight.
Your response body is ignored. Payload size scales with the generation; there is
no fixed limit.
Attempt outcomes
| Outcome | Result |
|---|---|
2xx response within 30 seconds | Delivered; no more tries |
307 or 308 redirect | Followed, up to 4 hops |
Any other status, including 301, 302, and 303 | Failed; retried |
| No response within 30 seconds | Failed; retried |
| Connection error (DNS, TLS, refused, reset) | Failed; retried |
| URL not allowed (private address, over 4 redirects, bad target) | Not delivered; no retries |
| Webhook disabled or deleted | Not delivered; no retries |
A 307 or 308 redirect re-sends the same POST body to the new location.
The 30-second timeout covers the whole redirect chain. A redirect to a different
origin (scheme, host, or port) keeps only Content-Type, Accept, and
User-Agent: the X-Inference-* headers are not sent to the new origin.
There, deduplicate on data.id or groupId in the payload, and verify
generation events with their webhookId field; group events carry no webhook
ID in the payload, so don't redirect a webhook that receives them across
origins.
Retry schedule
An event gets at most 24 attempts, the first one included. The waits are the configured values; each varies by up to 20% either way. The times are nominal: they leave out that jitter, the time your endpoint takes to answer, and queueing, which can make a wait longer.
| Attempt | Wait before it | Time since the first attempt |
|---|---|---|
| 1 | None | 0 |
| 2 | 5 seconds | 5 seconds |
| 3 | 30 seconds | 35 seconds |
| 4 | 2 minutes | 2 minutes 35 seconds |
| 5 | 10 minutes | 12 minutes 35 seconds |
| 6 | 30 minutes | 42 minutes 35 seconds |
| 7 | 1 hour | About 1 hour 43 minutes |
| 8 | 2 hours | About 3 hours 43 minutes |
| 9 | 4 hours | About 7 hours 43 minutes |
| 10 to 23 | 4 hours each | 4 hours more per attempt |
| 24 | 4 hours | About 67 hours 43 minutes |
If attempt 24 fails, the event is dropped, nominally about 68 hours (3 days) after the first attempt. With jitter alone, that is between about 54 and 81 hours; queueing can make it later. A dropped event's request and response content is deleted, so its result cannot be fetched from the generation status endpoint. See Data retention.
When your endpoint answers 2xx again after failing, the events still waiting
in this schedule usually start to be resent within minutes, a few at a time,
instead of at their next scheduled attempt. With Zero Data Retention on,
generation.completed and async-embedding.completed events keep this
schedule.
A request sent with a metadata.completion_window of 1 hour or less retries
faster inside that window: each wait is half the time left to the deadline, at
least 1/16 of the window, and never longer than the wait above. After the
deadline, the schedule above resumes at the current attempt. See the
worked example.
Delivery guarantee
Retryable failures follow an at-least-once policy: an event is retried until a
2xx or until attempt 24. Events that are not delivered and not retried (see
Attempt outcomes) may never reach your endpoint. After a
delivery succeeds, later redeliveries of the same event are not sent, but your
endpoint can still get an event twice: for example, when it processed a request
but answered after the 30-second timeout. Deduplicate on:
X-Inference-Generation-ID(the same value asdata.id) forgeneration.completedandasync-embedding.completedevents.X-Inference-Group-ID(the same value asgroupId) forslow-group.completedevents.
X-Inference-Delivery-Attempt is the attempt number, starting at 1. The
payload timestamp is the same on every attempt for an event.
Content purge with Zero Data Retention
With the Zero Data Retention (ZDR) team setting on, the request and response
content of a generation.completed or async-embedding.completed event is
purged when the event is delivered, dropped after attempt 24, or not delivered
because the URL is not allowed or the webhook is disabled or deleted. A dropped
event's result cannot be fetched. A group submitted with ZDR on is delivered
only in its slow-group.completed event, and its requests, responses, and
input are purged on the same terms. For a group already in progress when ZDR is
turned on, each request's request content is purged when it finishes. For
every team, ZDR on or off, a finished request's content is deleted once its
delivery finishes. See
Retention and groups and
Data retention.
Recommendations
- Return a
2xxas soon as you receive the event, well within 30 seconds, and process it asynchronously. - Make processing idempotent with the IDs above.
- Don't redirect the webhook URL. If you must, use
307or308.
Checklist
- Respond with 200 OK immediately
- Process webhook data asynchronously
- Make processing idempotent with
data.id(generation events) orgroupId(group events) - Validate the webhook source with headers
- Handle errors gracefully
- Monitor webhook processing
- Use an HTTPS endpoint
- Set up error logging
- Test the webhook from the dashboard
- Handle timeouts
- Handle both individual and group completions
Common issues
| Issue | Solution |
|---|---|
| Not receiving webhooks | Check the webhook is not disabled in the dashboard, test connectivity, check URL |
| Duplicate webhooks | Make processing idempotent, return 200 OK |
| Webhooks timing out | Respond immediately, process asynchronously |
| Invalid payload | Validate against the documented schema |
| Test webhook fails | Check the endpoint is publicly reachable and returns 200 OK |
Support
Email support@inference.net.