v22

latestOpenAPI 3.1.0raw.githubusercontent.com2025-10-15361989.5 KB

Create a prediction using an official model

Create a prediction using an official model.

If you're not running an official model, use the predictions.create operation instead.

Example cURL request:

curl -s -X POST -H 'Prefer: wait' \
  -d '{"input": {"prompt": "Write a short poem about the weather."}}' \
  -H "Authorization: Bearer $REPLICATE_API_TOKEN" \
  -H 'Content-Type: application/json' \
  https://api.replicate.com/v1/models/meta/meta-llama-3-70b-instruct/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 deployments.predictions.create API check out our documentation on creating a prediction which covers a variety of use cases.

post/models/{model_owner}/{model_name}/predictions

Path parameters

model_ownerstring required

The name of the user or organization that owns the model.

model_namestring required

The name of the model.

Headers

Preferstring
Example:wait=5

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.

Cancel-Afterstring
Example:5m

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

inputobject required

The model's input as a JSON object. The input schema depends on what model you are running. To see the available inputs, click the "API" tab on the model you are running or get the model version and look at its openapi_schema property. For example, stability-ai/sdxl takes prompt as an input.

Files should be passed as HTTP URLs or data URLs.

Use an HTTP URL when:

  • you have a large file > 256kb
  • you want to be able to use the file multiple times
  • you want your prediction metadata to be associable with your input files

Use a data URL when:

  • you have a small file <= 256kb
  • you don't want to upload and host the file somewhere
  • you don't need to use the file again (Replicate will not store it)
streamboolean

This field is deprecated.

Request a URL to receive streaming output using server-sent events (SSE).

This field is no longer needed as the returned prediction will always have a stream entry in its urls property if the model supports streaming.

webhookstring

An HTTPS URL for receiving a webhook when the prediction has new output. The webhook will be a POST request where the request body is the same as the response body of the get prediction operation. If there are network problems, we will retry the webhook a few times, so make sure it can be safely called more than once. Replicate will not follow redirects when sending webhook requests to your service, so be sure to specify a URL that will resolve without redirecting.

webhook_events_filterstring[]

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:

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

Example request

{
  "input": {
    "prompt": "Tell me a joke",
    "system_prompt": "You are a helpful assistant"
  },
  "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.

completed_atstring date-time

The time that the model completed the prediction and all outputs were uploaded

created_atstring date-time required

The time that the prediction was created

data_removedboolean required

Whether the prediction output has been deleted

deadlinestring date-time

The absolute time at which the prediction will be automatically canceled if it has not completed

deploymentstring

The name of the deployment that created the prediction

errorstring nullable required

An error string if the model status is "failed"

idstring required
inputobject required

The prediction input

logsstring

The log output from the model

modelstring required

The name of the model that created the prediction

{"stackTrail":"components:schemas:schemas_prediction_response:properties:output","oasType":"schema","type":"unknown","description":"The prediction output, which can be any JSON-serializable value, depending on the model"}
started_atstring date-time

The time that the model began the prediction

status'starting' | 'processing' | 'succeeded' | 'failed' | 'canceled' required