Skip to content

Programming-from-A-to-Z/Replicate-Examples

Repository files navigation

Node.js Replicate Example

This repo contains a "hello world" example demonstrating the how to prompt a machine learning model hosted by Replicate via node.js. This example is for the Programming from A to Z class at ITP, NYU. (Students in the class, contact me for your API key!)

import Replicate from 'replicate';
import * as dotenv from 'dotenv';
dotenv.config();

const replicate = new Replicate({
  auth: process.env.REPLICATE_API_TOKEN,
});

const version = '8e6975e5ed6174911a6ff3d60540dfd4844201974602551e10e9e87ab143d81e';
const model = 'meta/llama-2-7b-chat';
go();

async function go() {
  const input = {
    prompt: 'Help me with a thesis idea.',
    system_prompt: 'You are a student at ITP, Tisch School of the Arts, NYU.',
  };
  const output = await replicate.run(`${model}:${version}`, { input });
  console.log(output.join('').trim());
}

Replicate

Replicate is a platform for running machine learning models in the cloud from your own code.

Here are a few links to help you explore what is possible with generative AI models.

Getting Started

NOTE: models prefixed with ✨ are currently popular in the community.

Language Models

Images


For detailed usage, setup, and more, here is the official Replicate Documentation for Node.js.

About

Examples for Replicate API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published