🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More
Socket
Book a DemoInstallSign in
Socket

replicate-mini

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

replicate-mini

A low-level client for Replicate's HTTP API

Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
2
100%
Maintainers
0
Weekly downloads
 
Created
Source

Replicate Mini Node.js Client 🐢🚀

This is a low-level Node.js client for Replicate's HTTP API.

It is dynamically generated from Replicate's OpenAPI schema.

Installation

npm install replicate-mini

Usage

Create a Replicate API token and set the REPLICATE_API_TOKEN environment variable:

export REPLICATE_API_TOKEN=r8_...

Then create the client:

import Replicate from 'replicate-mini'

const replicate = new Replicate()

Then make requests:

const prediction = await replicate.predictions.create({
  version: '5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa',
  input: { text: 'whirled peas' }
})

console.log({ prediction })

Operations

account.get()

Get the authenticated account

collections.list()

List collections of models

collections.get({collection_slug})

Get a collection of models

Params:

  • collection_slug: Required. The slug of the collection, like super-resolution or image-restoration. See replicate.com/collections.

deployments.list()

List deployments

deployments.create({hardware, max_instances, min_instances, model, name, version})

Create a deployment

Params:

  • hardware: Required. The SKU for the hardware used to run the model
  • max_instances: Required. The maximum number of instances for scaling
  • min_instances: Required. The minimum number of instances for scaling
  • model: Required. The full name of the model that you want to deploy e
  • name: Required. The name of the deployment
  • version: Required. The 64-character string ID of the model version that you want to deploy

deployments.delete({deployment_owner, deployment_name})

Delete a deployment

Params:

  • deployment_owner: Required. The name of the user or organization that owns the deployment.
  • deployment_name: Required. The name of the deployment.

deployments.get({deployment_owner, deployment_name})

Get a deployment

Params:

  • deployment_owner: Required. The name of the user or organization that owns the deployment.
  • deployment_name: Required. The name of the deployment.

deployments.update({deployment_owner, deployment_name})

Update a deployment

Params:

  • deployment_owner: Required. The name of the user or organization that owns the deployment.
  • deployment_name: Required. The name of the deployment.
  • hardware: The SKU for the hardware used to run the model
  • max_instances: The maximum number of instances for scaling
  • min_instances: The minimum number of instances for scaling
  • version: The ID of the model version that you want to deploy

deployments.predictions.create({deployment_owner, deployment_name, input})

Create a prediction using a deployment

Params:

  • deployment_owner: Required. The name of the user or organization that owns the deployment.
  • deployment_name: Required. The name of the deployment.
  • input: Required. The model's input as a JSON object
  • stream: **This field is deprecated
  • webhook: An HTTPS URL for receiving a webhook when the prediction has new output
  • webhook_events_filter: By default, we will send requests to your webhook URL whenever there are new outputs or the prediction has finished

hardware.list()

List available hardware for models

models.list()

List public models

models.create({hardware, name, owner, visibility})

Create a model

Params:

  • hardware: Required. The SKU for the hardware used to run the model
  • name: Required. The name of the model
  • owner: Required. The name of the user or organization that will own the model
  • visibility: Required. Whether the model should be public or private
  • cover_image_url: A URL for the model's cover image
  • description: A description of the model
  • github_url: A URL for the model's source code on GitHub
  • license_url: A URL for the model's license
  • paper_url: A URL for the model's paper

models.search()

Search public models

models.delete({model_owner, model_name})

Delete a model

Params:

  • model_owner: Required. The name of the user or organization that owns the model.
  • model_name: Required. The name of the model.

models.get({model_owner, model_name})

Get a model

Params:

  • model_owner: Required. The name of the user or organization that owns the model.
  • model_name: Required. The name of the model.

models.predictions.create({model_owner, model_name, input})

Create a prediction using an official model

Params:

  • model_owner: Required. The name of the user or organization that owns the model.
  • model_name: Required. The name of the model.
  • input: Required. The model's input as a JSON object
  • stream: **This field is deprecated
  • webhook: An HTTPS URL for receiving a webhook when the prediction has new output
  • webhook_events_filter: By default, we will send requests to your webhook URL whenever there are new outputs or the prediction has finished

models.versions.list({model_owner, model_name})

List model versions

Params:

  • model_owner: Required. The name of the user or organization that owns the model.
  • model_name: Required. The name of the model.

models.versions.delete({model_owner, model_name, version_id})

Delete a model version

Params:

  • model_owner: Required. The name of the user or organization that owns the model.
  • model_name: Required. The name of the model.
  • version_id: Required. The ID of the version.

models.versions.get({model_owner, model_name, version_id})

Get a model version

Params:

  • model_owner: Required. The name of the user or organization that owns the model.
  • model_name: Required. The name of the model.
  • version_id: Required. The ID of the version.

trainings.create({model_owner, model_name, version_id, destination, input})

Create a training

Params:

  • model_owner: Required. The name of the user or organization that owns the model.
  • model_name: Required. The name of the model.
  • version_id: Required. The ID of the version.
  • destination: Required. A string representing the desired model to push to in the format {destination_model_owner}/{destination_model_name}
  • input: Required. An object containing inputs to the Cog model's train() function
  • webhook: An HTTPS URL for receiving a webhook when the training completes
  • webhook_events_filter: By default, we will send requests to your webhook URL whenever there are new outputs or the training has finished

predictions.list()

List predictions

predictions.create({input, version})

Create a prediction

Params:

  • input: Required. The model's input as a JSON object
  • version: Required. The ID of the model version that you want to run
  • stream: **This field is deprecated
  • webhook: An HTTPS URL for receiving a webhook when the prediction has new output
  • webhook_events_filter: By default, we will send requests to your webhook URL whenever there are new outputs or the prediction has finished

predictions.get({prediction_id})

Get a prediction

Params:

  • prediction_id: Required. The ID of the prediction to get.

predictions.cancel({prediction_id})

Cancel a prediction

Params:

  • prediction_id: Required. The ID of the prediction to cancel.

trainings.list()

List trainings

trainings.get({training_id})

Get a training

Params:

  • training_id: Required. The ID of the training to get.

trainings.cancel({training_id})

Cancel a training

Params:

  • training_id: Required. The ID of the training you want to cancel.

webhooks.default.secret.get()

Get the signing secret for the default webhook

How it works

  • The OpenAPI schema is downloaded and dereferenced at build time.
  • The tree-shaped OpenAPI schema is flattened into a an array of "operations".
  • Each operation object is massaged a bit to make it easier to generate the docs and client.
  • Every method has the same signature:
    • It takes a single params object as its only argument.
    • Some of the params are required and some are optional.
    • The params may be part of the request body, the URL path, query params, or headers. But you don't think about that. You just pass in an object and the library constructs the proper request for you.

FAQs

Package last updated on 30 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts