Crate replicate_rs

source ·
Expand description

A simple http client for interacting with Replicate.
Provides simple async functionality for interacting with Replicate via serde and isahc.

Getting Started

Add the following to your cargo toml

replicate-rs = "0.7.0"

Examples

Create a Prediction

Create a prediction, and get refreshed prediction data.

use replicate_rs::config::ReplicateConfig;
use replicate_rs::predictions::PredictionClient;
use serde::Serialize;
use serde_json::json;

// The library is runtime agnostic, so you should be able to use any async runtime you please
#[tokio::main]
async fn main() {
    tokio::spawn(async move {

        let config = ReplicateConfig::new().unwrap();
        let prediction_client = PredictionClient::from(config);

        // Create the prediction
        let mut prediction = prediction_client
            .create(
                "replicate",
                "hello-world",
                json!({"text": "kyle"}),
                false
            )
            .await
            .unwrap();

        // Refresh the data
        prediction.reload().await;
    });
}

Modules

  • Utilities for high level configuration for Replicate clients.
  • Utilities for interacting with models endpoints.
  • Utilities for interacting with all prediction endpoints.