Microsoft.Extensions.AI Namespace

Contains types for building and managing AI-related functionality, including chat clients, embedding generators, tools, and utilities for working with AI services.

Classes

AdditionalPropertiesDictionary

Provides a dictionary used as the AdditionalProperties dictionary on Microsoft.Extensions.AI objects.

AdditionalPropertiesDictionary<TValue>

Provides a dictionary used as the AdditionalProperties dictionary on Microsoft.Extensions.AI objects.

AIContent

Provides a base class for all content used with AI services.

AIFunction

Represents a function that can be described to an AI service and invoked.

AIFunctionArguments

Represents arguments to be used with InvokeAsync(AIFunctionArguments, CancellationToken).

AIFunctionFactory

Provides factory methods for creating commonly used implementations of AIFunction.

AIFunctionFactoryOptions

Represents options that can be provided when creating an AIFunction from a method.

AIJsonSchemaCreateOptions

Provides options for configuring the behavior of AIJsonUtilities JSON schema creation functionality.

AIJsonUtilities

Provides a collection of utility methods for marshalling JSON data.

AITool

Represents a tool that can be specified to an AI service.

AutoChatToolMode

Indicates that an IChatClient is free to select any of the available tools, or none at all.

AzureAIInferenceExtensions

Provides extension methods for working with Azure AI Inference.

CachingChatClient

Represents a delegating chat client that caches the results of chat calls.

CachingEmbeddingGenerator<TInput,TEmbedding>

Represents a delegating embedding generator that caches the results of embedding generation calls.

ChatClientBuilder

A builder for creating pipelines of IChatClient.

ChatClientBuilderChatClientExtensions

Provides extension methods for working with IChatClient in the context of ChatClientBuilder.

ChatClientExtensions

Provides a collection of static methods for extending IChatClient instances.

ChatClientMetadata

Provides metadata about an IChatClient.

ChatClientStructuredOutputExtensions

Provides extension methods on IChatClient that simplify working with structured output.

ChatFinishReason.Converter

Provides a JsonConverter<T> for serializing ChatFinishReason instances.

ChatMessage

Represents a chat message used by an IChatClient.

ChatOptions

Represents the options for a chat request.

ChatResponse

Represents the response to a chat request.

ChatResponse<T>

Represents the response to a chat request with structured output.

ChatResponseExtensions

Provides extension methods for working with ChatResponse and ChatResponseUpdate instances.

ChatResponseFormat

Represents the response format that is desired by the caller.

ChatResponseFormatJson

Represents a response format for structured JSON data.

ChatResponseFormatText

Represents a response format with no constraints around the format.

ChatResponseUpdate

Represents a single streaming response chunk from an IChatClient.

ChatRole.Converter

Provides a JsonConverter<T> for serializing ChatRole instances.

ChatToolMode

Describes how tools should be selected by a IChatClient.

ConfigureOptionsChatClient

Represents a delegating chat client that configures a ChatOptions instance used by the remainder of the pipeline.

ConfigureOptionsChatClientBuilderExtensions

Provides extensions for configuring ConfigureOptionsChatClient instances.

ConfigureOptionsEmbeddingGenerator<TInput,TEmbedding>

Represents a delegating embedding generator that configures a EmbeddingGenerationOptions instance used by the remainder of the pipeline.

ConfigureOptionsEmbeddingGeneratorBuilderExtensions

Provides extensions for configuring ConfigureOptionsEmbeddingGenerator<TInput,TEmbedding> instances.

ConfigureOptionsSpeechToTextClient

Represents a delegating chat client that configures a SpeechToTextOptions instance used by the remainder of the pipeline.

ConfigureOptionsSpeechToTextClientBuilderExtensions

Provides extensions for configuring ConfigureOptionsSpeechToTextClient instances.

DataContent

Represents binary content with an associated media type (also known as MIME type).

DelegatingChatClient

Provides an optional base class for an IChatClient that passes through calls to another instance.

DelegatingEmbeddingGenerator<TInput,TEmbedding>

Provides an optional base class for an IEmbeddingGenerator<TInput,TEmbedding> that passes through calls to another instance.

DelegatingSpeechToTextClient

Provides an optional base class for an ISpeechToTextClient that passes through calls to another instance.

DistributedCachingChatClient

A delegating chat client that caches the results of response calls, storing them as JSON in an IDistributedCache.

DistributedCachingChatClientBuilderExtensions

Extension methods for adding a DistributedCachingChatClient to an IChatClient pipeline.

DistributedCachingEmbeddingGenerator<TInput,TEmbedding>

Represents a delegating embedding generator that caches the results of embedding generation calls, storing them as JSON in an IDistributedCache.

DistributedCachingEmbeddingGeneratorBuilderExtensions

Extension methods for adding a DistributedCachingEmbeddingGenerator<TInput,TEmbedding> to an IEmbeddingGenerator<TInput,TEmbedding> pipeline.

Embedding

Represents an embedding generated by a IEmbeddingGenerator<TInput,TEmbedding>.

Embedding<T>

Represents an embedding composed of a vector of T values.

EmbeddingGenerationOptions

Represents the options for an embedding generation request.

EmbeddingGeneratorBuilder<TInput,TEmbedding>

A builder for creating pipelines of IEmbeddingGenerator<TInput,TEmbedding>.

EmbeddingGeneratorBuilderEmbeddingGeneratorExtensions

Provides extension methods for working with IEmbeddingGenerator<TInput,TEmbedding> in the context of EmbeddingGeneratorBuilder<TInput,TEmbedding>.

EmbeddingGeneratorExtensions

Provides a collection of static methods for extending IEmbeddingGenerator<TInput,TEmbedding> instances.

EmbeddingGeneratorMetadata

Provides metadata about an IEmbeddingGenerator<TInput,TEmbedding>.

ErrorContent

Represents an error.

FunctionCallContent

Represents a function call request.

FunctionInvocationContext

Provides context for an in-flight function invocation.

FunctionInvokingChatClient

A delegating chat client that invokes functions defined on ChatOptions. Include this in a chat pipeline to resolve function calls automatically.

FunctionInvokingChatClient.FunctionInvocationResult

Provides information about the invocation of a function call.

FunctionInvokingChatClientBuilderExtensions

Provides extension methods for attaching a FunctionInvokingChatClient to a chat pipeline.

FunctionResultContent

Represents the result of a function call.

GeneratedEmbeddings<TEmbedding>

Represents the result of an operation to generate embeddings.

HostedCodeInterpreterTool

Represents a hosted tool that can be specified to an AI service to enable it to execute code it generates.

HostedWebSearchTool

Represents a hosted tool that can be specified to an AI service to enable it to perform web searches.

LoggingChatClient

A delegating chat client that logs chat operations to an ILogger.

LoggingChatClientBuilderExtensions

Provides extensions for configuring LoggingChatClient instances.

LoggingEmbeddingGenerator<TInput,TEmbedding>

A delegating embedding generator that logs embedding generation operations to an ILogger.

LoggingEmbeddingGeneratorBuilderExtensions

Provides extensions for configuring LoggingEmbeddingGenerator<TInput,TEmbedding> instances.

LoggingSpeechToTextClient

A delegating speech to text client that logs speech to text operations to an ILogger.

NoneChatToolMode

Indicates that an IChatClient should not request the invocation of any tools.

OllamaChatClient

Represents an IChatClient for Ollama.

OllamaEmbeddingGenerator

Represents an IEmbeddingGenerator<TInput,TEmbedding> for Ollama.

OpenAIClientExtensions

Provides extension methods for working with OpenAIClients.

OpenTelemetryChatClient

Represents a delegating chat client that implements the OpenTelemetry Semantic Conventions for Generative AI systems.

OpenTelemetryChatClientBuilderExtensions

Provides extensions for configuring OpenTelemetryChatClient instances.

OpenTelemetryEmbeddingGenerator<TInput,TEmbedding>

Represents a delegating embedding generator that implements the OpenTelemetry Semantic Conventions for Generative AI systems.

OpenTelemetryEmbeddingGeneratorBuilderExtensions

Provides extensions for configuring OpenTelemetryEmbeddingGenerator<TInput,TEmbedding> instances.

RequiredChatToolMode

Represents a mode where a chat tool must be called. This class can optionally nominate a specific function or indicate that any of the functions can be selected.

SpeechToTextClientBuilder

A builder for creating pipelines of ISpeechToTextClient.

SpeechToTextClientBuilderExtensions

Provides extensions for configuring LoggingSpeechToTextClient instances.

SpeechToTextClientBuilderSpeechToTextClientExtensions

Provides extension methods for working with ISpeechToTextClient in the context of SpeechToTextClientBuilder.

SpeechToTextClientExtensions

Extensions for ISpeechToTextClient.

SpeechToTextClientMetadata

Provides metadata about an ISpeechToTextClient.

SpeechToTextOptions

Represents the options for an speech to text request.

SpeechToTextResponse

Represents the result of an speech to text request.

SpeechToTextResponseUpdate

Represents a single streaming response chunk from an ISpeechToTextClient.

SpeechToTextResponseUpdateExtensions

Provides extension methods for working with SpeechToTextResponseUpdate instances.

SpeechToTextResponseUpdateKind.Converter

Provides a JsonConverter<T> for serializing SpeechToTextResponseUpdateKind instances.

TextContent

Represents text content in a chat.

TextReasoningContent

Represents text reasoning content in a chat.

UriContent

Represents a URL, typically to hosted content such as an image, audio, or video.

UsageContent

Represents usage information associated with a chat request and response.

UsageDetails

Provides usage details about a request/response.

Structs

AdditionalPropertiesDictionary<TValue>.Enumerator

Enumerates the elements of an AdditionalPropertiesDictionary<TValue>.

AIFunctionFactoryOptions.ParameterBindingOptions

Provides configuration options produced by the ConfigureParameterBinding delegate.

AIJsonSchemaCreateContext

Defines the context in which a JSON schema within a type graph is being generated.

ChatFinishReason

Represents the reason a chat response completed.

ChatRole

Describes the intended purpose of a message within a chat interaction.

SpeechToTextResponseUpdateKind

Describes the intended purpose of a specific update during streaming of speech to text updates.

Interfaces

IChatClient

Represents a chat client.

IEmbeddingGenerator

Represents a generator of embeddings.

IEmbeddingGenerator<TInput,TEmbedding>

Represents a generator of embeddings.

ISpeechToTextClient

Represents a speech to text client.

Enums

FunctionInvokingChatClient.FunctionInvocationStatus

Provides error codes for when errors occur as part of the function calling loop.