Skip to main content

Class: ReplicateImageProvider

Defined in: packages/agentos/src/io/media/images/providers/ReplicateImageProvider.ts:138

Implements​

Constructors​

Constructor​

new ReplicateImageProvider(): ReplicateImageProvider

Returns​

ReplicateImageProvider

Properties​

defaultModelId?​

optional defaultModelId: string

Defined in: packages/agentos/src/io/media/images/providers/ReplicateImageProvider.ts:141

Implementation of​

IImageProvider.defaultModelId


isInitialized​

isInitialized: boolean = false

Defined in: packages/agentos/src/io/media/images/providers/ReplicateImageProvider.ts:140

Implementation of​

IImageProvider.isInitialized


providerId​

readonly providerId: "replicate" = 'replicate'

Defined in: packages/agentos/src/io/media/images/providers/ReplicateImageProvider.ts:139

Implementation of​

IImageProvider.providerId

Methods​

editImage()​

editImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/io/media/images/providers/ReplicateImageProvider.ts:366

Edits an image using a Replicate model that supports image-to-image input.

Uses black-forest-labs/flux-fill for inpainting (when a mask is provided) or falls back to stability-ai/sdxl for generic img2img transforms. The source image goes in the model input as a data URL of its type, or, from 1 MB, as a file uploaded to Replicate's Files API.

Parameters​

request​

ImageEditRequest

Edit request with source image, prompt, and optional mask.

Returns​

Promise<ImageGenerationResult>

Generation result with the edited image(s).

Throws​

When the provider is not initialised or the API fails.

Implementation of​

IImageProvider.editImage


generateImage()​

generateImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/io/media/images/providers/ReplicateImageProvider.ts:168

Parameters​

request​

ImageGenerationRequest

Returns​

Promise<ImageGenerationResult>

Implementation of​

IImageProvider.generateImage


initialize()​

initialize(config): Promise<void>

Defined in: packages/agentos/src/io/media/images/providers/ReplicateImageProvider.ts:146

Parameters​

config​

Record<string, unknown>

Returns​

Promise<void>

Implementation of​

IImageProvider.initialize


listAvailableModels()​

listAvailableModels(): Promise<ImageModelInfo[]>

Defined in: packages/agentos/src/io/media/images/providers/ReplicateImageProvider.ts:712

Returns​

Promise<ImageModelInfo[]>

Implementation of​

IImageProvider.listAvailableModels


styleTransferModel()​

styleTransferModel(modelId): string

Defined in: packages/agentos/src/io/media/images/providers/ReplicateImageProvider.ts:569

The model a style transfer runs on for modelId, or a refusal. An empty id takes the configured default when it is one of REPLICATE_STYLE_TRANSFER_MODELS, else FLUX.2 Pro. A named model must be one of them, unless the provider's base URL is not Replicate's; it is run by its name on the model endpoint, so a pinned version (owner/name:version) is refused.

Parameters​

modelId​

string

The model the call names, or an empty string.

Returns​

string

Throws​

For a model the style transfer does not run.

Implementation of​

IImageProvider.styleTransferModel


transferStyle()​

transferStyle(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/io/media/images/providers/ReplicateImageProvider.ts:606

Restyles an image after a style reference on a FLUX.2 model, which takes both as input_images, the source first, with an instruction that names them by index ("point to other reference images by their index number", https://replicate.com/black-forest-labs/flux-2-pro). FLUX.2 takes no strength and no negative prompt: strength picks the instruction (see styleTransfer.ts), and the output keeps the source's aspect ratio (match_input_image) unless providerOptions.input sets another.

The call's prompt and its two images are what it sends, so a providerOptions.input naming prompt, input_images, image or input_image is refused, and so is providerOptions.extraBody, which could pin another version or replace the input. The prediction must end succeeded; a failed, canceled or unfinished one throws.

Parameters​

request​

ImageStyleTransferRequest

The source, the reference and the prompt.

Returns​

Promise<ImageGenerationResult>

Generation result with the restyled image(s).

Throws​

When the provider is not initialised, the model, an image or an option is refused, the API fails, the prediction does not succeed, or its output holds no image.

Implementation of​

IImageProvider.transferStyle


upscaleImage()​

upscaleImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/io/media/images/providers/ReplicateImageProvider.ts:517

Upscales an image using a Replicate upscaling model.

Defaults to nightmareai/real-esrgan which supports 2x and 4x upscaling via the scale input parameter.

Parameters​

request​

ImageUpscaleRequest

Upscale request with source image and desired scale factor.

Returns​

Promise<ImageGenerationResult>

Generation result with the upscaled image.

Throws​

When the provider is not initialised or the API fails.

Implementation of​

IImageProvider.upscaleImage