Create a prediction
Create a prediction for the model version and inputs you provide.
Example cURL request:
curl -s -X POST -H 'Prefer: wait' \
-d '{"version": "replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", "input": {"text": "Alice"}}' \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
-H 'Content-Type: application/json' \
https://api.replicate.com/v1/predictions
The request will wait up to 60 seconds for the model to run. If this time is exceeded the prediction will be returned in a "starting" state and need to be retrieved using the predictions.get endpoint.
For a complete overview of the predictions.create API check out our documentation on creating a prediction which covers a variety of use cases.
Headers
Leave the request open and wait for the model to finish generating output. Set to wait=n where n is a number of seconds between 1 and 60.
See https://replicate.com/docs/topics/predictions/create-a-prediction#sync-mode for more information.
The maximum time the prediction can run before it is automatically canceled. The lifetime is measured from when the prediction is created.
The duration can be specified as string with an optional unit suffix:
- s for seconds (e.g., 30s, 90s)
- m for minutes (e.g., 5m, 15m)
- h for hours (e.g., 1h, 2h30m)
- defaults to seconds if no unit suffix is provided (e.g. 30 is the same as 30s)
You can combine units for more precision (e.g., 1h30m45s).
The minimum allowed duration is 5 seconds.
Request body
Example request
{
"input": {
"text": "Alice"
},
"version": "replicate/hello-world:9dcd6d78e7c6560c340d916fe32e9f24aabfa331e5cce95fe31f77fb03121426",
"webhook": "https://example.com/my-webhook-handler",
"webhook_events_filter": [
"start",
"completed"
]
}Response
Prediction has been created. If the Prefer: wait header is provided it will contain the final output.