Table of contents
Replicate can send an HTTP POST request to the URL you specified whenever the prediction is created, has new logs, new output, or is completed.
The request body is a prediction object in JSON format. This object has the same structure as the object returned by the get a prediction API. Here's an example of an unfinished prediction:
Refer to Prediction status for the list of possible status
values.
Here's an example of a Next.js webhook handler:
By default, Replicate sends requests to your webhook URL whenever there are new outputs or the prediction has finished. You can change which events trigger a webhook using the webhook_events_filter
property.
Your endpoint should respond with a 2xx status code within a few seconds; otherwise, the webhook might be retried.
When Replicate sends the final webhook for a prediction (where the status is succeeded
, failed
or canceled
), we check the response status we get. If we can't make the request at all, or if we get a 4xx or 5xx response, we'll retry the webhook. We retry several times on an exponential backoff. The final retry is sent about 1 minute after the prediction completed.
We do not retry any webhooks for intermediate states.
Make webhook handlers idempotent. Identical webhooks can be sent more than once, so you'll need handle potentially duplicate information.