An Unofficial Rust client for Replicate. Provides a type-safe interface by deserializing API responses into Rust structs.
Getting Started
Add replicate_rust
to Cargo.toml
:
[]
= "0.0.5"
Grab your token from replicate.com/account and set it as an environment variable:
Here's an example using replicate_rust
to run a model:
use ;
Usage
See the reference docs for detailed API documentation.
Examples
-
Run a model in the background:
// Construct the inputs. let mut inputs = new; inputs.insert; let version = "stability-ai/stable-diffusion:27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478"; // Run the model. let mut prediction = replicate.predictions.create?; println!; // 'starting' prediction.reload?; println!; // 'processing' println!; // Some("Using seed: 3599 // 0%| | 0/50 [00:00<?, ?it/s] // 4%|▍ | 2/50 [00:00<00:04, 10.00it/s] // 8%|▊ | 4/50 [00:00<00:03, 11.56it/s] let prediction = prediction.wait?; println!; // 'succeeded' println!;
-
Cancel a prediction:
// Construct the inputs. let mut inputs = new; inputs.insert; let version = "stability-ai/stable-diffusion:27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478"; // Run the model. let mut prediction = replicate.predictions.create?; println!; // 'starting' prediction.cancel?; prediction.reload?; println!; // 'cancelled'
-
List predictions:
let predictions = replicate.predictions.list?; println!; // ListPredictions { ... }
-
Get model Information:
let model = replicate.models.get?; println!; // GetModel { ... }
-
Get Versions List:
let versions = replicate.models.versions.list?; println!; // ListModelVersions { ... }
-
Get Model Version Information:
let model = replicate.models.versions.get?; println!; // GetModelVersion { ... }
-
Get Collection Information:
let collection = replicate.collections.get?; println!; // GetCollectionModels { ... }//! ```
-
Get Collection Lists:
let collections = replicate.collections.list?; println!; // ListCollectionModels { ... }