Skip to contentNewKimi K3.1 Pro is now availableTry it now
Docs / Webhooks reference

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:

  1. Create a webhook with a name and HTTPS URL.
  2. Send a test event, disable or enable, or delete a webhook, and see its recent invocation stats.
  3. Copy the webhook identifier to use in generation requests.

Payload structures

generation.completed

json
{
  "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

json
{
  "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

json
{
  "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

HeaderDescriptionExample
X-Inference-EventEvent typegeneration.completed, async-embedding.completed, or slow-group.completed
X-Inference-Webhook-IDWebhook identifierAhALzdz8S
X-Inference-Generation-IDGeneration ID (generation events)XBKcs7F1s2oJ_AHiLMbF4
X-Inference-Embedding-IDGeneration ID (embedding events)XBKcs7F1s2oJ_AHiLMbF4
X-Inference-Group-IDGroup ID (group events)GRP_XYZ123
X-Inference-Delivery-AttemptDelivery attempt, starting at 11
User-AgentInference.net webhook agentKuzco-Webhook/1.0
Content-TypeAlways application/jsonapplication/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/slow request must set metadata.webhook_id, or it fails with 400.
  • A disabled webhook fails with 400 and error type WebhookDisabled.
  • 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

OutcomeResult
2xx response within 30 secondsDelivered; no more tries
307 or 308 redirectFollowed, up to 4 hops
Any other status, including 301, 302, and 303Failed; retried
No response within 30 secondsFailed; 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 deletedNot 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.

AttemptWait before itTime since the first attempt
1None0
25 seconds5 seconds
330 seconds35 seconds
42 minutes2 minutes 35 seconds
510 minutes12 minutes 35 seconds
630 minutes42 minutes 35 seconds
71 hourAbout 1 hour 43 minutes
82 hoursAbout 3 hours 43 minutes
94 hoursAbout 7 hours 43 minutes
10 to 234 hours each4 hours more per attempt
244 hoursAbout 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 as data.id) for generation.completed and async-embedding.completed events.
  • X-Inference-Group-ID (the same value as groupId) for slow-group.completed events.

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 2xx as 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 307 or 308.

Checklist

  • Respond with 200 OK immediately
  • Process webhook data asynchronously
  • Make processing idempotent with data.id (generation events) or groupId (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

IssueSolution
Not receiving webhooksCheck the webhook is not disabled in the dashboard, test connectivity, check URL
Duplicate webhooksMake processing idempotent, return 200 OK
Webhooks timing outRespond immediately, process asynchronously
Invalid payloadValidate against the documented schema
Test webhook failsCheck the endpoint is publicly reachable and returns 200 OK

Support

Email support@inference.net.