Skip to main content

Predictions API

The client.predictions component provides methods to retrieve, list, and manage predictions across all content types. This is the central hub for tracking the status of all processing jobs in the platform.

Quick Examples

Get a Prediction

List Predictions

Wait for Completion

Core Operations

Retrieving Predictions

Get details about a specific prediction:

Listing Predictions

List predictions you’ve created (with pagination):

Waiting for Completion

Wait for long-running predictions to complete:
The wait() method will throw a TimeoutError if the prediction doesn’t complete within the specified timeout.

Prediction Statuses

Predictions can have the following statuses:

Feedback Operations

Get Feedbacks for a Prediction

Create Feedback

Media-Specific APIs

The base Predictions class is extended by specialized prediction classes for different media types:

Image Predictions

Document, Audio, and Video Predictions

These specialized APIs follow a consistent pattern:

Response Structure

The PredictionResponse object includes these key fields:
The usage field contains a CreditUsage object:

Common Patterns

Process and Wait

A common pattern is to start a prediction and wait for it to complete:

Batch Processing

For batch operations, use the batch parameter and track multiple predictions:

Error Handling

Implement robust error handling:

TypeScript Interfaces

Best Practices

Efficient Polling

Use appropriate intervals when waiting for predictions:

Using Callbacks for Long-Running Jobs

For very long-running predictions, consider using callback URLs: