Dela via


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.

AIAnnotation

Represents an annotation on content.

AIContent

Represents content used by 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).

AIFunctionDeclaration

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

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.

AIJsonSchemaTransformCache

Defines a cache for JSON schemas transformed according to the specified AIJsonSchemaTransformOptions policy.

AIJsonSchemaTransformOptions

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

AIJsonUtilities

Provides a collection of utility methods for marshalling JSON data.

AITool

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

AnnotatedRegion

Describes the portion of an associated AIContent to which an annotation applies.

ApprovalRequiredAIFunction

Represents an AIFunction that can be described to an AI service and invoked, but for which the invoker should obtain user approval before the function is actually invoked.

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.

BinaryEmbedding

Represents an embedding composed of a bit vector.

BinaryEmbedding.VectorConverter

Provides a JsonConverter<T> for serializing BitArray instances.

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.

CitationAnnotation

Represents an annotation that links content to source references, such as documents, URLs, files, or tool outputs.

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.

ConfigureOptionsImageGenerator

Represents a delegating image generator that configures a ImageGenerationOptions instance used by the remainder of the pipeline.

ConfigureOptionsImageGeneratorBuilderExtensions

Provides extensions for configuring ConfigureOptionsImageGenerator 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).

DelegatingAIFunction

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

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.

DelegatingImageGenerator

Provides an optional base class for an IImageGenerator 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.

FunctionApprovalRequestContent

Represents a request for user approval of a function call.

FunctionApprovalResponseContent

Represents a response to a function approval request.

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.

HostedFileContent

Represents a file that is hosted by the AI service.

HostedFileSearchTool

Represents a hosted tool that can be specified to an AI service to enable it to perform file search operations.

HostedMcpServerTool

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

HostedMcpServerToolAlwaysRequireApprovalMode

Indicates that approval is always required for tool calls to a hosted MCP server.

HostedMcpServerToolApprovalMode

Describes how approval is required for tool calls to a hosted MCP server.

HostedMcpServerToolNeverRequireApprovalMode

Indicates that approval is never required for tool calls to a hosted MCP server.

HostedMcpServerToolRequireSpecificApprovalMode

Represents a mode where approval behavior is specified for individual tool names.

HostedVectorStoreContent

Represents a vector store that is hosted by the AI service.

HostedWebSearchTool

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

ImageGenerationOptions

Represents the options for an image generation request.

ImageGenerationRequest

Represents a request for image generation.

ImageGenerationResponse

Represents the result of an image generation request.

ImageGeneratorBuilder

A builder for creating pipelines of IImageGenerator.

ImageGeneratorBuilderImageGeneratorExtensions

Provides extension methods for working with IImageGenerator in the context of ImageGeneratorBuilder.

ImageGeneratorExtensions

Provides extension methods for IImageGenerator.

ImageGeneratorMetadata

Provides metadata about an IImageGenerator.

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.

LoggingImageGenerator

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

LoggingImageGeneratorBuilderExtensions

Provides extensions for configuring LoggingImageGenerator instances.

LoggingSpeechToTextClient

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

LoggingSpeechToTextClientBuilderExtensions

Provides extensions for configuring LoggingSpeechToTextClient instances.

McpServerToolApprovalRequestContent

Represents a request for user approval of an MCP server tool call.

McpServerToolApprovalResponseContent

Represents a response to an MCP server tool approval request.

McpServerToolCallContent

Represents a tool call request to a MCP server.

McpServerToolResultContent

Represents the result of a MCP server tool call.

MessageCountingChatReducer

Provides a chat reducer that limits the number of non-system messages in a conversation to a specified maximum count, preserving the most recent messages and the first system message if present.

NoneChatToolMode

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

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.

OpenTelemetryImageGenerator

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

OpenTelemetryImageGeneratorBuilderExtensions

Provides extensions for configuring OpenTelemetryImageGenerator instances.

OpenTelemetrySpeechToTextClient

Represents a delegating speech-to-text client that implements the OpenTelemetry Semantic Conventions for Generative AI systems.

OpenTelemetrySpeechToTextClientBuilderExtensions

Provides extensions for configuring OpenTelemetrySpeechToTextClient instances.

ReducingChatClient

A chat client that reduces the size of a message list.

ReducingChatClientBuilderExtensions

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

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.

ResponseContinuationToken

Represents a token used to resume, continue, or rehydrate an operation across multiple scenarios/calls, such as resuming a streamed response from a specific point or retrieving the result of a background operation. Subclasses of this class encapsulate all necessary information within the token to facilitate these actions.

ResponseContinuationToken.Converter

Provides a JsonConverter<T> for serializing ResponseContinuationToken instances.

SpeechToTextClientBuilder

A builder for creating pipelines of ISpeechToTextClient.

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.

SummarizingChatReducer

Provides functionality to reduce a collection of chat messages into a summarized form.

TextContent

Represents text content in a chat.

TextReasoningContent

Represents text reasoning content in a chat.

TextSpanAnnotatedRegion

Describes a location in the associated AIContent based on starting and ending character indices.

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.

UserInputRequestContent

Represents a request for user input.

UserInputResponseContent

Represents the response to a request for user input.

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.

AIJsonSchemaTransformContext

Defines the context for transforming a schema node withing a larger schema document.

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.

IChatReducer

Represents a reducer capable of shrinking the size of a list of chat messages.

IEmbeddingGenerator

Represents a generator of embeddings.

IEmbeddingGenerator<TInput,TEmbedding>

Represents a generator of embeddings.

IImageGenerator

Represents a generator of images.

ISpeechToTextClient

Represents a speech to text client.

Enums

FunctionInvokingChatClient.FunctionInvocationStatus

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

ImageGenerationResponseFormat

Represents the requested response format of the generated image.