---
title: "Create a prediction using a deployment"
method: POST
path: "/deployments/{deployment_owner}/{deployment_name}/predictions"
---

# Create a prediction using a deployment

`POST /deployments/{deployment_owner}/{deployment_name}/predictions`

Create a prediction for the deployment and inputs you provide.

Example cURL request:

```console
curl -s -X POST -H 'Prefer: wait' \
  -d '{"input": {"prompt": "A photo of a bear riding a bicycle over the moon"}}' \
  -H "Authorization: Bearer $REPLICATE_API_TOKEN" \
  -H 'Content-Type: application/json' \
  https://api.replicate.com/v1/deployments/acme/my-app-image-generator/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](https://replicate.com/docs/topics/predictions/create-a-prediction) which covers a variety of use cases.

## Path parameters

- `deployment_owner` string, required
- `deployment_name` string, required

## Headers

- `Prefer` string
- `Cancel-After` string

## Request body

- SchemasPredictionRequest
  - `input` object, 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](#models.versions.get) and look at its `openapi_schema` property. For example, [stability-ai/sdxl](https://replicate.com/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)
  - `stream` boolean — **This field is deprecated.** Request a URL to receive streaming output using [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). 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.
  - `webhook` string — 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](#predictions.get) 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_filter` string[] — 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.

## Response `201`

Prediction has been created. If the `Prefer: wait` header is provided it will contain the final output.

- SchemasPredictionResponse
  - `completed_at` string, date-time — The time that the model completed the prediction and all outputs were uploaded
  - `created_at` string, date-time, required — The time that the prediction was created
  - `data_removed` boolean, required — Whether the prediction output has been deleted
  - `deadline` string, date-time — The absolute time at which the prediction will be automatically canceled if it has not completed
  - `deployment` string — The name of the deployment that created the prediction
  - `error` string, nullable, required — An error string if the model status is `"failed"`
  - `id` string, required
  - `input` object, required — The prediction input
  - `logs` string — The log output from the model
  - `metrics` object — Additional metrics associated with the prediction
    - `total_time` number — The total time, in seconds, that the prediction took to complete
  - `model` string, required — The name of the model that created the prediction
  - `output` unknown, required
  - `started_at` string, date-time — The time that the model began the prediction
  - `status` 'starting' | 'processing' | 'succeeded' | 'failed' | 'canceled', required
  - `urls` object, required — URLs for working with the prediction
    - `cancel` string, uri, required — Cancel the prediction via API
    - `get` string, uri, required — Retrieve the latest state of the prediction via API
    - `stream` string, uri — An event source to stream the output of the prediction via API
    - `web` string, uri, required — View the prediction in a browser
  - `version` union, required
    - string — The ID of the model version that created the prediction
    - 'hidden' — The model does not support versions, used by official models.

## Other responses

- `202` — Prediction has been created but does not yet have all outputs

---

[API](https://skmtc.net/replicate/apis/replicate-http-api.md) · [All operations](https://skmtc.net/replicate/apis/replicate-http-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/replicate/replicate-http-api/versions/7a537f433b0b/schema)
