Skip to content

ReplicateImageModel

Namespace: Vercel.AI.Replicate

public sealed class ReplicateImageModel : IImageModel, IImageCaller

Replicate image model. It creates a prediction, polls it when the sync wait expires, and downloads each output image. A model:version id posts to /predictions; other ids post to /models/{model}/predictions.

Inheritance: object

Implements: IImageModel, IImageCaller

View source

ReplicateImageModel(ReplicateProvider, string, Func<DateTime>?)

Section titled “ReplicateImageModel(ReplicateProvider, string, Func<DateTime>?)”
public ReplicateImageModel(ReplicateProvider provider, string modelId, Func<DateTime>? clock = null)

Creates an image model. <code class=“paramref”>clock</code> sets the response timestamp.

Parameters

Name Type Description
provider ReplicateProvider
modelId string
clock Func<DateTime>

View source

public int? MaxImagesPerCall { get; }

Flux-2 models accept up to 8 input images; other models return one image per call.

Value: int?

View source

public string ModelId { get; }

Model id.

Value: string

View source

public string Provider { get; }

Provider id.

Value: string

View source

DoGenerateAsync(ImageModelCall, CancellationToken)

Section titled “DoGenerateAsync(ImageModelCall, CancellationToken)”
public Task<ImageModelResult> DoGenerateAsync(ImageModelCall call, CancellationToken cancellationToken)

Generates images.

Parameters

Name Type Description
call ImageModelCall
cancellationToken CancellationToken

Returns: Task<ImageModelResult>

View source

DoGenerateAsync(ImageCallOptions, CancellationToken)

Section titled “DoGenerateAsync(ImageCallOptions, CancellationToken)”
public Task<ImageGenerationResult> DoGenerateAsync(ImageCallOptions options, CancellationToken cancellationToken)

Generates images. Maps to doGenerate on an image model.

Parameters

Name Type Description
options ImageCallOptions
cancellationToken CancellationToken

Returns: Task<ImageGenerationResult>

View source

ResolveMaxImagesPerCallAsync(CancellationToken)

Section titled “ResolveMaxImagesPerCallAsync(CancellationToken)”
public Task<int?> ResolveMaxImagesPerCallAsync(CancellationToken cancellationToken)

Resolves a functional per-call limit. The default returns MaxImagesPerCall.

Parameters

Name Type Description
cancellationToken CancellationToken

Returns: Task<int?>

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product