Prerequisites

Setup

  1. Add the Replicate API key to your environment variables
.env
REPLICATE_API_TOKEN=your-api-key
  1. The boilerplate already includes the necessary configuration for Replicate in src/lib/ai/replicate.ts. This file initializes the Replicate client with your API token.

Usage

To use Replicate AI in your application, you can create an API route that interacts with the Replicate client. This route can be used to generate images, text, and more using the AI models provided by Replicate. Create a new file in your API routes directory (e.g., app/api/replicate/route.ts). This file will contain the logic for interacting with the Replicate client. Here’s an example of how to set up a route that uses the Flux model:

Model Selection

Replicate provides a wide range of AI models that you can use in your application. You can find the full list of models on the Replicate website.