replicate-javascript  by replicate

Node.js client for Replicate's API

Created 2 years ago
577 stars

Top 56.1% on SourcePulse

GitHubView on GitHub
Project Summary

This Node.js client library provides a programmatic interface for interacting with the Replicate API, enabling developers to run machine learning models directly from their JavaScript or TypeScript applications. It simplifies the process of integrating complex AI models into backend services, serverless functions, or command-line tools.

How It Works

The client leverages Replicate's HTTP API to manage model execution. It abstracts away the complexities of API requests, authentication, and handling model inputs/outputs. Key features include synchronous (run) and asynchronous (stream) model execution, webhook support for real-time updates, and utilities for managing models, predictions, and file uploads. The run method is optimized for low-latency file models, while stream allows for real-time output processing.

Quick Start & Requirements

  • Installation: npm install replicate
  • Requirements: Node.js >= 18, Bun >= 1.0, or Deno >= 1.28. Compatible with serverless platforms like Cloudflare Workers, Vercel functions, and AWS Lambda.
  • Usage: Import and instantiate the client with an API token, then use replicate.run() or replicate.stream() with model identifiers and input parameters.
  • Docs: https://github.com/replicate/replicate-javascript

Highlighted Details

  • Supports running models with file inputs (URLs or local file handles).
  • Provides robust webhook functionality for asynchronous event handling.
  • Includes TypeScript definitions for enhanced developer experience.
  • Offers methods for model discovery, prediction management, and file uploads.

Maintenance & Community

The library is maintained by Replicate. Further community engagement details are not explicitly provided in the README.

Licensing & Compatibility

The library is released under the MIT License, allowing for broad commercial use and integration with closed-source projects.

Limitations & Caveats

The client cannot interact directly with the Replicate API from a browser environment. For web applications, a server-side approach or a separate client-side guide is recommended. Node.js versions prior to 18 may require a polyfill for fetch.

Health Check
Last Commit

4 weeks ago

Responsiveness

1 day

Pull Requests (30d)
2
Issues (30d)
1
Star History
11 stars in the last 30 days

Explore Similar Projects

Starred by Eugene Yan Eugene Yan(AI Scientist at AWS), Jared Palmer Jared Palmer(Ex-VP AI at Vercel; Founder of Turborepo; Author of Formik, TSDX), and
4 more.

seldon-core by SeldonIO

0.2%
5k
MLOps framework for production model deployment on Kubernetes
Created 7 years ago
Updated 16 hours ago
Feedback? Help us improve.