Crate replicate_rust

source ·
Expand description

Rust Client for interacting with the Replicate API. Provides a type-safe interface by deserializing API responses into Rust structs.

Getting Started

Add replicate_rust to your Cargo.toml file.

[dependencies]
replicate_rust = "0.0.3"

Example

In this example we will run a model that generates a caption for an image using the Stable Diffusion model.

use replicate_rust::{Replicate, config::Config};

let config = Config::default();
let replicate = Replicate::new(config);

// Creating the inputs
let mut inputs = std::collections::HashMap::new();
inputs.insert("prompt", "a  19th century portrait of a wombat gentleman");

let version = String::from("stability-ai/stable-diffusion:27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478");

// Run the model.
let result = replicate.run(version, inputs);

// Print the result
match result {
    Ok(result) => println!("Success : {:?}", result.output),
    Err(e) => println!("Error : {}", e),
}

Modules

Structs