| File: Image\IImageGenerator.cs | Web Access |
| Project: src\src\Libraries\Microsoft.Extensions.AI.Abstractions\Microsoft.Extensions.AI.Abstractions.csproj (Microsoft.Extensions.AI.Abstractions) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Diagnostics.CodeAnalysis; using System.Threading; using System.Threading.Tasks; using Microsoft.Shared.DiagnosticIds; namespace Microsoft.Extensions.AI; /// <summary> /// Represents a generator of images. /// </summary> [Experimental(DiagnosticIds.Experiments.AIImageGeneration, UrlFormat = DiagnosticIds.UrlFormat)] public interface IImageGenerator : IDisposable { /// <summary> /// Sends an image generation request and returns the generated image as a <see cref="ImageGenerationResponse"/>. /// </summary> /// <param name="request">The image generation request containing the prompt and optional original images for editing.</param> /// <param name="options">The image generation options to configure the request.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="request"/> is <see langword="null"/>.</exception> /// <returns>The images generated by the <see cref="ImageGenerationRequest"/>.</returns> Task<ImageGenerationResponse> GenerateAsync(ImageGenerationRequest request, ImageGenerationOptions? options = null, CancellationToken cancellationToken = default); /// <summary>Asks the <see cref="IImageGenerator"/> for an object of the specified type <paramref name="serviceType"/>.</summary> /// <param name="serviceType">The type of object being requested.</param> /// <param name="serviceKey">An optional key that can be used to help identify the target service.</param> /// <returns>The found object, otherwise <see langword="null"/>.</returns> /// <exception cref="ArgumentNullException"><paramref name="serviceType"/> is <see langword="null"/>.</exception> /// <remarks> /// The purpose of this method is to allow for the retrieval of strongly typed services that might be provided by the <see cref="IImageGenerator"/>, /// including itself or any services it might be wrapping. /// </remarks> object? GetService(Type serviceType, object? serviceKey = null); }