client.predictions
Manage predictions with the VLM Run Python SDK
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 raise a TimeoutError
if the prediction doesn’t complete within the specified timeout.
Prediction Statuses
Predictions can have the following statuses:
Status | Description |
---|---|
enqueued | The prediction is waiting to be processed |
pending | The prediction is preparing to start |
running | The prediction is actively being processed |
completed | The prediction has completed successfully |
failed | The prediction encountered an error |
paused | The prediction has been paused |
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:
Auto-casting Responses
All specialized prediction classes support auto-casting responses to their appropriate schema types:
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:
Best Practices
Efficient Polling
Use appropriate intervals when waiting for predictions:
Using Appropriate Timeouts
Set timeouts based on the expected processing time:
Progress Reporting with tqdm
For better user experience, use the tqdm
library for progress reporting: