npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

replicate-mini

v1.0.4

Published

A low-level Node.js client for Replicate's HTTP API

Downloads

73

Readme

replicate-mini ✨

A low-level Node.js client for Replicate's HTTP API, autogenerated from an OpenAPI schema.

This library works, but it's experimental. If you're looking for something more stable, check out Replicate's official JavaScript client.

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


Get the authenticated account

List collections of models

Get a collection of models

Params:

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

List deployments

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

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.

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.

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

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
  • Prefer: Leave the request open and wait for the model to finish generating output. Set to wait=n where n is a number of seconds between 1 and 60.

See https://replicate.com/docs/topics/predictions/create-a-prediction#sync-mode for more information.

  • 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

List available hardware for models

List public models

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

Search public models

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.

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.

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
  • Prefer: Leave the request open and wait for the model to finish generating output. Set to wait=n where n is a number of seconds between 1 and 60.

See https://replicate.com/docs/topics/predictions/create-a-prediction#sync-mode for more information.

  • 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

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.

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.

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.

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

List predictions

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
  • Prefer: Leave the request open and wait for the model to finish generating output. Set to wait=n where n is a number of seconds between 1 and 60.

See https://replicate.com/docs/topics/predictions/create-a-prediction#sync-mode for more information.

  • 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

Get a prediction

Params:

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

Cancel a prediction

Params:

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

List trainings

Get a training

Params:

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

Cancel a training

Params:

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

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.