PredictionsResource
Resource class for interacting with predictions.
Class: PredictionsResource
Resource class for interacting with predictions.
Extends
Constructors
Constructor
new PredictionsResource(
api):PredictionsResource
Create a new resource.
Parameters
api
API client instance used to communicate with WriftAI's API.
Returns
PredictionsResource
Inherited from
Methods
create()
create(
options,wait,waitOptions,signal?):Promise<PredictionWithIO>
Create a prediction. This method creates a prediction using either the latest version of a model or a specific model version.
Parameters
options
Options for prediction creation.
wait
boolean = false
If True, waits until the prediction reaches a terminal state. If False, returns the prediction immediately. Defaults to False.
waitOptions
WaitOptions = DEFAULT_WAIT_OPTIONS
Options for customizing wait behavior. If not provided, DEFAULT_WAIT_OPTIONS are used.
signal?
AbortSignal
Optional AbortSignal to cancel the request.
Returns
Promise<PredictionWithIO>
The new prediction.
Throws
When the provided model reference is not in owner/name or owner/name:version_number format.
get()
get(
id,signal?):Promise<PredictionWithIO>
Get a prediction by its ID.
Parameters
id
string
The ID of the prediction to fetch.
signal?
AbortSignal
Optional AbortSignal to cancel the request.
Returns
Promise<PredictionWithIO>
The prediction object.
list()
list(
options?,signal?):Promise<PaginatedResponse<Prediction>>
List predictions.
Parameters
options?
Optional settings to control pagination behavior.
signal?
AbortSignal
Optional AbortSignal to cancel the request.
Returns
Promise<PaginatedResponse<Prediction>>
Paginated response containing predictions and navigation metadata.
wait()
wait(
predictionID,options,signal?):Promise<PredictionWithIO>
Waits for a prediction to complete. This method uses short polling to check the prediction status at regular intervals until it reaches a terminal state.
Parameters
predictionID
string
The ID of the prediction.
options
WaitOptions = DEFAULT_WAIT_OPTIONS
Options for customizing wait behavior. If not provided, DEFAULT_WAIT_OPTIONS are used.
signal?
AbortSignal
Optional AbortSignal that can be used to cancel the polling operation.
Returns
Promise<PredictionWithIO>
Prediction after completion.