Skip to content

A (nice to use) Go library for ML cloud provider Replicate.

Notifications You must be signed in to change notification settings

dkgv/go-replicate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-replicate

go-replicate is a Go client library for Replicate.

Installation

go get github.com/dkgv/go-replicate

Usage

Get started by creating an API token on Replicate and instantiating a new client:

client := replicate.NewClient("REPLICATE_TOKEN")

Models

Retrieving a model

model, err := client.Models.Get(ctx, "OWNER", "MODEL_NAME")

Predictions

Creating a prediction

var input any
// ...
prediction, err := client.Predictions.Create(ctx, "MODEL_ID", input)

Creating a prediction with a webhook

webhook := replicate.Webook{
    CallbackURL: "https://example.com/callback",
    Events: []replicate.PredictionEvent{
        replicate.EventPredictionStarted,
        replicate.EventPredictionCompleted,
    },
}
prediction, err := client.Predictions.CreateWithWebhook(ctx, "MODEL_ID", input, webhook)

Getting a prediction

prediction, err := client.Predictions.Get(ctx, "PREDICTION_ID")

Awaiting a prediction

type Destination struct {
    // ...
}

var destination Destination
err := client.Predictions.Await(ctx, "PREDICTION_ID", &destination)

Cancelling a prediction

err := client.Predictions.Cancel(ctx, "PREDICTION_ID")

About

A (nice to use) Go library for ML cloud provider Replicate.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages