Skip to content

OpenAIImageModel

Namespace: Vercel.AI.OpenAI

public sealed class OpenAIImageModel : IImageModel

OpenAI image generation and edit model.

Inheritance: object

Implements: IImageModel

View source

OpenAIImageModel(OpenAIProvider, string, Func<DateTimeOffset>?)

Section titled “OpenAIImageModel(OpenAIProvider, string, Func<DateTimeOffset>?)”
public OpenAIImageModel(OpenAIProvider provider, string modelId, Func<DateTimeOffset>? clock = null)

Creates an image model.

Parameters

Name Type Description
provider OpenAIProvider
modelId string
clock Func<DateTimeOffset>

View source

public int MaxImagesPerCall { get; }

Maximum images accepted by one call for this model id.

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(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

GenerateAsync(OpenAIImageCall, CancellationToken)

Section titled “GenerateAsync(OpenAIImageCall, CancellationToken)”
public Task<OpenAIImageGeneration> GenerateAsync(OpenAIImageCall call, CancellationToken cancellationToken)

Generates or edits images.

Parameters

Name Type Description
call OpenAIImageCall
cancellationToken CancellationToken

Returns: Task<OpenAIImageGeneration>

View source

public static int MaxImages(string modelId)

Maximum images for <code class=“paramref”>modelId</code>.

Parameters

Name Type Description
modelId string

Returns: int

View source

public static bool OmitsResponseFormat(string modelId)

True when the model rejects an explicit response_format.

Parameters

Name Type Description
modelId string

Returns: bool

View source

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