PredictionsResource
Resource class for interacting with predictions.
Class: PredictionsResource
Resource class for interacting with predictions.
Extends
Constructors
Constructor
new PredictionsResource(
api,files):PredictionsResource
Initializes the Predictions resource.
Parameters
api
API
An instance of the API class.
files
An instance of the Files class.
Returns
PredictionsResource
Overrides
Methods
cancel()
cancel(
id,signal?):Promise<void>
Cancel a prediction by its ID.
Parameters
id
string
The ID of the prediction to cancel.
signal?
AbortSignal
Optional AbortSignal to cancel the request.
Returns
Promise<void>
create()
create(
options,wait,waitOptions,signal?):Promise<PredictionWithDetails>
Create a prediction. This method creates a prediction using either the latest version of a model or a specific model version. Files in the input are uploaded concurrently before the prediction is created.
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<PredictionWithDetails>
The new prediction.
get()
get(
id,signal?):Promise<PredictionWithDetails>
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<PredictionWithDetails>
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<PredictionWithDetails>
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<PredictionWithDetails>
Prediction after completion.