To receive webhook events, specify a `webhook` URL in the request body when creating a prediction or a training.

Here’s an example using the Replicate client to create a prediction and request a webhook event when the prediction is completed:

[](#webhook-events-filter)Webhook events filter
-----------------------------------------------

By default, we will send requests to your webhook URL whenever there are new outputs or the prediction has finished. You can change which events trigger webhook requests by specifying `webhook_events_filter` in the prediction request:

*   `start`: immediately on prediction start
*   `output`: each time a prediction generates an output (note that predictions can generate multiple outputs)
*   `logs`: each time log output is generated by a prediction
*   `completed`: when the prediction reaches a terminal state (succeeded/canceled/failed)

For example, if you only wanted requests to be sent at the start and end of the prediction, you would provide:

```json
{
  "input": {
    "text": "Alice"
  },
  "webhook": "https://example.com/my-webhook",
  "webhook_events_filter": ["start", "completed"]
}
```

Requests for event types `output` and `logs` will be sent at most once every 500ms.

If you request `start` and `completed` webhooks, then they’ll always be sent regardless of throttling.

[](#webhooks-for-trainings)Webhooks for trainings
-------------------------------------------------

In addition to predictions, you can also receive webhooks when [fine-tuning models with the training API](/docs/get-started/fine-tune-with-flux):

Tip

**Add query params to your webhook URL** to pass along extra metadata, like an internal ID you’re using for a prediction. For example: `https://example.com/replicate-webhook?customId=123`

[](#example-resources)Example resources
---------------------------------------

*   See the [Node.js client](https://github.com/replicate/replicate-javascript#replicatepredictionscreate) webhook docs.
*   See the [Python client](https://github.com/replicate/replicate-python#run-a-model-in-the-background-and-get-a-webhook) webhook docs.
*   See [predictions.create](https://replicate.com/docs/reference/http#predictions.create) and [trainings.create](https://replicate.com/docs/reference/http#trainings.create) API docs.
*   See [Scribble Diffusion’s codebase](https://github.com/replicate/scribble-diffusion/pull/27/commits/627c872c78aad89cadd02798d37d4696e3278a12) for a reference implementation in JavaScript.
*   Read our [streaming guide](/docs/streaming) to learn how to consume server-sent events (SSEs) from language models.