oelin / node-replicate

A Node.js client for Replicate.

Home Page:https://npmjs.com/node-replicate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node-replicate

A Node.js client for Replicate.

import replicate from "node-replicate"
const model = "stability-ai/stable-diffusion:db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf"
const input = { prompt: "an astronaut riding on a horse" }

await replicate.run(model, input)

Introduction

Replicate is an online platform for running machine learning models in the cloud. This package implements a lightweight client for their anonymous API, allowing you to run Stable Diffusion, Whisper and other cutting-edge models in just a few lines of code 😄🤏.

Features

  • Anonymous API 👻.
  • Lightweight - only 30 lines of code 🔥.

Installation

Install with npm.

npm i node-replicate

Usage

To run a model, just pass its identifier and prediction parameters to replicate.run().

const model = "owner/model:version"
const input = { prompt: "an astronaut riding on a horse" }

await replicate.run(model, input)

You can also monitor pending predictions with replicate.create().

let prediction = await replicate.create(model, input)

while (! prediction.status == "succeeded") {
  console.log(prediction.status)
  
  prediction = await replicate.get(prediction)
}

Contributing

Have a feature you'd like to see added? Create a pull request or open an issue.

About

A Node.js client for Replicate.

https://npmjs.com/node-replicate


Languages

Language:JavaScript 100.0%