Text-to-image generation
Generate images from text prompts using supported Replicate image models.
AI Tools · Const
replicate is the default Replicate provider from @ai-sdk/replicate. Use replicate.image(modelId) to create an image model for AI SDK generation functions.
replicate is the default provider instance exported by @ai-sdk/replicate. Call its .image(modelId) factory to obtain a Replicate image model, then pass that model to the AI SDK image-generation function. Authentication uses the REPLICATE_API_TOKEN environment variable by default, or a custom provider can be created with createReplicate.
replicate.image(modelId)| Name | Type | Description |
|---|---|---|
modelId | string | Replicate model identifier, such as black-forest-labs/flux-schnell. |
A Replicate image model object suitable for use with AI SDK image-generation APIs.
replicate instance from @ai-sdk/replicate.replicate value is ready to use without constructing a provider.replicate.image(modelId) to create the image model passed to AI SDK generation APIs.createReplicate when the default provider configuration is not sufficient.REPLICATE_API_TOKEN environment variable unless you configure a custom token.import { replicate } from '@ai-sdk/replicate';
import { experimental_generateImage as generateImage } from 'ai';
const { image } = await generateImage({
model: replicate.image('black-forest-labs/flux-schnell'),
prompt: 'A lighthouse on a snowy island at sunrise',
aspectRatio: '16:9',
});
console.log(image.base64);Creates an image with a Replicate model and prints the returned image as base64 data.
Generate images from text prompts using supported Replicate image models.
Select different Replicate models by changing the model identifier.
Route API calls through a proxy or supply a token explicitly.
createReplicatereplicate.imageexperimental_generateImageproviderOptions.replicate