---
title: predictions
description: Predictions module.
---

# predictions module

Predictions module.

<a id="wriftai.predictions.ErrorSource"></a>

### *class* ErrorSource(StrEnum)

Bases: [`StrEnum`](wriftai.common_types.md#wriftai.common_types.StrEnum)

Enumeration of possible error sources.

<a id="wriftai.predictions.ErrorSource.internal"></a>

#### internal *= 'internal'*

<a id="wriftai.predictions.ErrorSource.external"></a>

#### external *= 'external'*

<a id="wriftai.predictions.Status"></a>

### *class* Status(StrEnum)

Bases: [`StrEnum`](wriftai.common_types.md#wriftai.common_types.StrEnum)

Enumeration of possible prediction statuses.

<a id="wriftai.predictions.Status.pending"></a>

#### pending *= 'pending'*

<a id="wriftai.predictions.Status.started"></a>

#### started *= 'started'*

<a id="wriftai.predictions.Status.failed"></a>

#### failed *= 'failed'*

<a id="wriftai.predictions.Status.succeeded"></a>

#### succeeded *= 'succeeded'*

<a id="wriftai.predictions.TaskError"></a>

### *class* TaskError

Bases: `TypedDict`

Represents an error that occurred during a prediction.

<a id="wriftai.predictions.TaskError.source"></a>

#### source *: [ErrorSource](#wriftai.predictions.ErrorSource)*

<a id="wriftai.predictions.TaskError.message"></a>

#### message *: str*

<a id="wriftai.predictions.TaskError.detail"></a>

#### detail *: list[JsonValue] | Mapping[str, JsonValue] | str | bool | int | float | None*

<a id="wriftai.predictions.Prediction"></a>

### *class* Prediction

Bases: `TypedDict`

Represents a prediction.

<a id="wriftai.predictions.Prediction.url"></a>

#### url *: str*

URL to access the prediction resource.

<a id="wriftai.predictions.Prediction.id"></a>

#### id *: str*

Unique identifier for the prediction.

<a id="wriftai.predictions.Prediction.version_id"></a>

#### version_id *: str*

Identifier of the model version used.

<a id="wriftai.predictions.Prediction.created_at"></a>

#### created_at *: str*

Timestamp when the prediction was created.

<a id="wriftai.predictions.Prediction.status"></a>

#### status *: [Status](#wriftai.predictions.Status)*

Current status of the prediction.

<a id="wriftai.predictions.Prediction.webhook_url"></a>

#### webhook_url *: str | None*

URL for webhook callbacks, if any.

<a id="wriftai.predictions.Prediction.updated_at"></a>

#### updated_at *: str*

Timestamp of the last update to the prediction.

<a id="wriftai.predictions.Prediction.setup_time"></a>

#### setup_time *: str | None*

Time taken to set up the prediction environment.

<a id="wriftai.predictions.Prediction.execution_time"></a>

#### execution_time *: str | None*

Time taken to execute the prediction.

<a id="wriftai.predictions.Prediction.hardware_id"></a>

#### hardware_id *: str*

Identifier of the hardware used for prediction.

<a id="wriftai.predictions.Prediction.error"></a>

#### error *: [TaskError](#wriftai.predictions.TaskError) | None*

Error details if the prediction failed.

<a id="wriftai.predictions.PredictionWithIO"></a>

### *class* PredictionWithIO

Bases: [`Prediction`](#wriftai.predictions.Prediction)

Represents a prediction with I/O details.

<a id="wriftai.predictions.PredictionWithIO.input"></a>

#### input *: list[JsonValue] | Mapping[str, JsonValue] | str | bool | int | float | None*

Input data provided for the prediction.

<a id="wriftai.predictions.PredictionWithIO.output"></a>

#### output *: list[JsonValue] | Mapping[str, JsonValue] | str | bool | int | float | None*

Output generated by the prediction.

<a id="wriftai.predictions.PredictionWithIO.logs"></a>

#### logs *: list[str] | None*

Logs generated during prediction execution.

<a id="wriftai.predictions.PredictionWithIO.setup_logs"></a>

#### setup_logs *: list[str] | None*

Logs generated during setup.

<a id="wriftai.predictions.PredictionWithIO.url"></a>

#### url *: str*

<a id="wriftai.predictions.PredictionWithIO.id"></a>

#### id *: str*

<a id="wriftai.predictions.PredictionWithIO.version_id"></a>

#### version_id *: str*

<a id="wriftai.predictions.PredictionWithIO.created_at"></a>

#### created_at *: str*

<a id="wriftai.predictions.PredictionWithIO.status"></a>

#### status *: [Status](#wriftai.predictions.Status)*

<a id="wriftai.predictions.PredictionWithIO.webhook_url"></a>

#### webhook_url *: str | None*

<a id="wriftai.predictions.PredictionWithIO.updated_at"></a>

#### updated_at *: str*

<a id="wriftai.predictions.PredictionWithIO.setup_time"></a>

#### setup_time *: str | None*

<a id="wriftai.predictions.PredictionWithIO.execution_time"></a>

#### execution_time *: str | None*

<a id="wriftai.predictions.PredictionWithIO.hardware_id"></a>

#### hardware_id *: str*

<a id="wriftai.predictions.PredictionWithIO.error"></a>

#### error *: [TaskError](#wriftai.predictions.TaskError) | None*

<a id="wriftai.predictions.CreatePredictionParams"></a>

### *class* CreatePredictionParams

Bases: `TypedDict`

Prediction creation params.

<a id="wriftai.predictions.CreatePredictionParams.input"></a>

#### input *: list[JsonValue] | Mapping[str, JsonValue] | str | bool | int | float | None*

Input data provided for the prediction.

<a id="wriftai.predictions.CreatePredictionParams.webhook_url"></a>

#### webhook_url *: NotRequired[str]*

An HTTP URL to POST prediction updates to.

<a id="wriftai.predictions.CreatePredictionParams.validate_input"></a>

#### validate_input *: NotRequired[bool]*

Enable input validation against the schema before processing.

<a id="wriftai.predictions.WaitOptions"></a>

### *class* WaitOptions(poll_interval=1.0)

Bases: `object`

Options for customizing wait behaviour.

* **Parameters:**
  **poll_interval** (*float*)

<a id="wriftai.predictions.WaitOptions.poll_interval"></a>

#### poll_interval *: float* *= 1.0*

Time in seconds between polling attempts to check the prediction status.

<a id="wriftai.predictions.DEFAULT_WAIT_OPTIONS"></a>

### DEFAULT_WAIT_OPTIONS *= WaitOptions(poll_interval=1.0)*

Default wait options.

<a id="wriftai.predictions.Predictions"></a>

### *class* Predictions(api)

Bases: `Resource`

Initializes the Resource with an API instance.

* **Parameters:**
  **api** ([*API*](wriftai.api.md#wriftai.api.API)) – An instance of the API class.

<a id="wriftai.predictions.Predictions.get"></a>

#### get(prediction_id)

Get a prediction by id.

* **Parameters:**
  **prediction_id** (*str*) – The unique identifier of the prediction.
* **Returns:**
  The prediction object.
* **Return type:**
  [PredictionWithIO](#wriftai.predictions.PredictionWithIO)

<a id="wriftai.predictions.Predictions.async_get"></a>

#### *async* async_get(prediction_id)

Get a prediction by id.

* **Parameters:**
  **prediction_id** (*str*) – The unique identifier of the prediction.
* **Returns:**
  The prediction object.
* **Return type:**
  [PredictionWithIO](#wriftai.predictions.PredictionWithIO)

<a id="wriftai.predictions.Predictions.list"></a>

#### list(pagination_options=None)

List predictions.

* **Parameters:**
  **pagination_options** (*Optional* *[*[*PaginationOptions*](wriftai.md#wriftai.PaginationOptions) *]*) – Optional settings
  to control pagination behavior.
* **Returns:**
  Paginated response containing predictions
  : and navigation metadata.
* **Return type:**
  [PaginatedResponse](wriftai.pagination.md#wriftai.pagination.PaginatedResponse)[[Prediction](#wriftai.predictions.Prediction)]

<a id="wriftai.predictions.Predictions.async_list"></a>

#### *async* async_list(pagination_options=None)

List predictions.

* **Parameters:**
  **pagination_options** (*Optional* *[*[*PaginationOptions*](wriftai.md#wriftai.PaginationOptions) *]*) – Optional settings
  to control pagination behavior.
* **Returns:**
  Paginated response containing predictions
  : and navigation metadata.
* **Return type:**
  [PaginatedResponse](wriftai.pagination.md#wriftai.pagination.PaginatedResponse)[[Prediction](#wriftai.predictions.Prediction)]

<a id="wriftai.predictions.Predictions.create"></a>

#### create(, model_owner: str, model_name: str, wait: bool = False, wait_options: [WaitOptions](#wriftai.predictions.WaitOptions) = DEFAULT_WAIT_OPTIONS, params: [CreatePredictionParams](#wriftai.predictions.CreatePredictionParams)) → [PredictionWithIO](#wriftai.predictions.PredictionWithIO)

#### create(, version_id: str, wait: bool = False, wait_options: [WaitOptions](#wriftai.predictions.WaitOptions) = DEFAULT_WAIT_OPTIONS, params: [CreatePredictionParams](#wriftai.predictions.CreatePredictionParams)) → [PredictionWithIO](#wriftai.predictions.PredictionWithIO)

Create a prediction.

This method creates a prediction using either the latest version of a model
or a specific model version.

* **Parameters:**
  * **model_owner** (Optional[str]) – Username of the model’s owner.
  * **model_name** (Optional[str]) – Name of the model.
  * **version_id** (Optional[str]) – Unique identifier of the model’s version.
  * **params** ([*CreatePredictionParams*](#wriftai.predictions.CreatePredictionParams)) – Prediction creation params.
  * **wait** (*bool*) – If True, waits until the prediction reaches a terminal state.
    If False, returns the prediction immediately. Defaults to False.
  * **wait_options** ([*WaitOptions*](#wriftai.predictions.WaitOptions)) – Options for customizing wait behavior.
    If not provided, default options are used.
* **Returns:**
  The new prediction.
* **Return type:**
  [PredictionWithIO](#wriftai.predictions.PredictionWithIO)
* **Raises:**
  **TypeError** – When an invalid combination of version_id, model_owner,
      and model_name is provided.

<a id="wriftai.predictions.Predictions.async_create"></a>

#### *async* async_create(, model_owner: str, model_name: str, wait: bool = False, wait_options: [WaitOptions](#wriftai.predictions.WaitOptions) = DEFAULT_WAIT_OPTIONS, params: [CreatePredictionParams](#wriftai.predictions.CreatePredictionParams)) → [PredictionWithIO](#wriftai.predictions.PredictionWithIO)

#### *async* async_create(, version_id: str, wait: bool = False, wait_options: [WaitOptions](#wriftai.predictions.WaitOptions) = DEFAULT_WAIT_OPTIONS, params: [CreatePredictionParams](#wriftai.predictions.CreatePredictionParams)) → [PredictionWithIO](#wriftai.predictions.PredictionWithIO)

Create a prediction.

This method creates a prediction using either the latest version of a model
or a specific model version.

* **Parameters:**
  * **model_owner** (Optional[str]) – Username of the model’s owner.
  * **model_name** (Optional[str]) – Name of the model.
  * **version_id** (Optional[str]) – Unique identifier of the model’s version.
  * **params** ([*CreatePredictionParams*](#wriftai.predictions.CreatePredictionParams)) – Prediction creation params.
  * **wait** (*bool*) – If True, waits until the prediction reaches a terminal state.
    If False, returns the prediction immediately. Defaults to False.
  * **wait_options** ([*WaitOptions*](#wriftai.predictions.WaitOptions)) – Options for customizing wait behavior.
    If not provided, default options are used.
* **Returns:**
  The new prediction.
* **Return type:**
  [PredictionWithIO](#wriftai.predictions.PredictionWithIO)
* **Raises:**
  **TypeError** – When an invalid combination of version_id, model_owner,
      and model_name is provided.

<a id="wriftai.predictions.Predictions.wait"></a>

#### wait(predictionID, options=WaitOptions(poll_interval=1.0))

Wait for a prediction to complete.

This method uses short polling to check the prediction status at
regular intervals until it reaches a terminal state. It blocks
execution and waits until the prediction has finished processing.

* **Parameters:**
  * **predictionID** (*str*) – Unique identifier of the prediction.
  * **options** ([*WaitOptions*](#wriftai.predictions.WaitOptions)) – Options for customizing wait behavior.
    If not provided, default options are used.
* **Returns:**
  Prediction after completion.
* **Return type:**
  [PredictionWithIO](#wriftai.predictions.PredictionWithIO)

<a id="wriftai.predictions.Predictions.async_wait"></a>

#### *async* async_wait(predictionID, options=WaitOptions(poll_interval=1.0))

Wait for a prediction to complete.

This method uses short polling to check the prediction status at
regular intervals until it reaches a terminal state. It blocks
execution and waits until the prediction has finished processing.

* **Parameters:**
  * **predictionID** (*str*) – Unique identifier of the prediction.
  * **options** ([*WaitOptions*](#wriftai.predictions.WaitOptions)) – Options for customizing wait behavior.
    If not provided, default options are used.
* **Returns:**
  Prediction after completion.
* **Return type:**
  [PredictionWithIO](#wriftai.predictions.PredictionWithIO)