Table of Contents

Class GoogleGenAIExtensions

Namespace
Microsoft.Extensions.AI
Assembly
Google.GenAI.dll

Provides implementations of Microsoft.Extensions.AI abstractions based on Client.

public static class GoogleGenAIExtensions
Inheritance
GoogleGenAIExtensions
Inherited Members

Methods

AsIChatClient(Client, string?)

Creates an Microsoft.Extensions.AI.IChatClient wrapper around the specified Client.

public static IChatClient AsIChatClient(this Client client, string? defaultModelId = null)

Parameters

client Client

The Client to wrap.

defaultModelId string

The default model ID to use for chat requests if not specified in Microsoft.Extensions.AI.ChatOptions.ModelId.

Returns

IChatClient

An Microsoft.Extensions.AI.IChatClient that wraps the specified client.

Exceptions

ArgumentNullException

client is null.

AsIChatClient(Models, string?)

Creates an Microsoft.Extensions.AI.IChatClient wrapper around the specified Models.

public static IChatClient AsIChatClient(this Models models, string? defaultModelId = null)

Parameters

models Models

The Models client to wrap.

defaultModelId string

The default model ID to use for chat requests if not specified in Microsoft.Extensions.AI.ChatOptions.ModelId.

Returns

IChatClient

An Microsoft.Extensions.AI.IChatClient that wraps the specified Models client.

Exceptions

ArgumentNullException

models is null.

AsIEmbeddingGenerator(Client, string?, int?)

Creates an Microsoft.Extensions.AI.IEmbeddingGenerator wrapper around the specified Client.

public static IEmbeddingGenerator<string, Embedding<float>> AsIEmbeddingGenerator(this Client client, string? defaultModelId = null, int? defaultModelDimensions = null)

Parameters

client Client

The Client to wrap.

defaultModelId string

The default model ID to use for image generation requests if not specified in Microsoft.Extensions.AI.ImageGenerationOptions.ModelId.

defaultModelDimensions int?

The number of dimensions to generate in each embedding.

Returns

IEmbeddingGenerator<string, Embedding<float>>

An Microsoft.Extensions.AI.IEmbeddingGenerator that wraps the specified client.

Exceptions

ArgumentNullException

client is null.

AsIEmbeddingGenerator(Models, string?, int?)

Creates an Microsoft.Extensions.AI.IEmbeddingGenerator wrapper around the specified Models.

public static IEmbeddingGenerator<string, Embedding<float>> AsIEmbeddingGenerator(this Models models, string? defaultModelId = null, int? defaultModelDimensions = null)

Parameters

models Models

The Models client to wrap.

defaultModelId string

The default model ID to use for image generation requests if not specified in Microsoft.Extensions.AI.ImageGenerationOptions.ModelId.

defaultModelDimensions int?

The number of dimensions to generate in each embedding.

Returns

IEmbeddingGenerator<string, Embedding<float>>

An Microsoft.Extensions.AI.IEmbeddingGenerator that wraps the specified Models client.

Exceptions

ArgumentNullException

models is null.

AsIHostedFileClient(Client)

Creates an Microsoft.Extensions.AI.IHostedFileClient wrapper around the specified Client.

public static IHostedFileClient AsIHostedFileClient(this Client client)

Parameters

client Client

The Client to wrap.

Returns

IHostedFileClient

An Microsoft.Extensions.AI.IHostedFileClient that wraps the specified client.

Remarks

The hosted file client is only supported with the Gemini Developer API, not Vertex AI.

Exceptions

ArgumentNullException

client is null.

AsIHostedFileClient(Files)

Creates an Microsoft.Extensions.AI.IHostedFileClient wrapper around the specified Files.

public static IHostedFileClient AsIHostedFileClient(this Files files)

Parameters

files Files

The Files client to wrap.

Returns

IHostedFileClient

An Microsoft.Extensions.AI.IHostedFileClient that wraps the specified Files client.

Remarks

The hosted file client is only supported with the Gemini Developer API, not Vertex AI.

Exceptions

ArgumentNullException

files is null.

AsIImageGenerator(Client, string?)

Creates an Microsoft.Extensions.AI.IImageGenerator wrapper around the specified Client.

public static IImageGenerator AsIImageGenerator(this Client client, string? defaultModelId = null)

Parameters

client Client

The Client to wrap.

defaultModelId string

The default model ID to use for image generation requests if not specified in Microsoft.Extensions.AI.ImageGenerationOptions.ModelId.

Returns

IImageGenerator

An Microsoft.Extensions.AI.IImageGenerator that wraps the specified client.

Exceptions

ArgumentNullException

client is null.

AsIImageGenerator(Models, string?)

Creates an Microsoft.Extensions.AI.IImageGenerator wrapper around the specified Models.

public static IImageGenerator AsIImageGenerator(this Models models, string? defaultModelId = null)

Parameters

models Models

The Models client to wrap.

defaultModelId string

The default model ID to use for image generation requests if not specified in Microsoft.Extensions.AI.ImageGenerationOptions.ModelId.

Returns

IImageGenerator

An Microsoft.Extensions.AI.IImageGenerator that wraps the specified Models client.

Exceptions

ArgumentNullException

models is null.

AsIRealtimeClient(Client, string?)

Creates an Microsoft.Extensions.AI.IRealtimeClient wrapper around the specified Client for use with the Google GenAI Live API.

public static IRealtimeClient AsIRealtimeClient(this Client client, string? defaultModelId = null)

Parameters

client Client

The Client to wrap.

defaultModelId string

The default model ID to use for realtime sessions.

Returns

IRealtimeClient

An Microsoft.Extensions.AI.IRealtimeClient that wraps the specified client.

Exceptions

ArgumentNullException

client is null.