Share via


ImageGeneratorExtensions.GenerateImagesAsync Method

Definition

Generates images based on a text prompt.

public static System.Threading.Tasks.Task<Microsoft.Extensions.AI.ImageGenerationResponse> GenerateImagesAsync(this Microsoft.Extensions.AI.IImageGenerator generator, string prompt, Microsoft.Extensions.AI.ImageGenerationOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
static member GenerateImagesAsync : Microsoft.Extensions.AI.IImageGenerator * string * Microsoft.Extensions.AI.ImageGenerationOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Extensions.AI.ImageGenerationResponse>
<Extension()>
Public Function GenerateImagesAsync (generator As IImageGenerator, prompt As String, Optional options As ImageGenerationOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ImageGenerationResponse)

Parameters

generator
IImageGenerator

The image generator.

prompt
String

The prompt to guide the image generation.

options
ImageGenerationOptions

The image generation options to configure the request.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

The images generated by the generator.

Exceptions

generator or prompt is null.

Applies to