ai library

AI extension library

Classes

AIAnnotation
Base class for annotations on AI content.
AIContent
Base class for all AI content types.
AIFunction
Represents a function that can be invoked by an AI model.
AIFunctionArguments
Represents the arguments passed to an AI function invocation.
AIFunctionFactory
A factory for creating AIFunction instances from simple callbacks.
AITool
Base class for tools that can be provided to an AI model.
AnnotatedRegion
Base class for annotated regions.
AnonymousDelegatingChatClient
A DelegatingChatClient that uses anonymous delegates to implement its functionality.
AutoChatToolMode
Tools may optionally be used by the model.
CachingChatClient
An abstract DelegatingChatClient that caches chat responses.
ChatClient
Represents a chat client.
ChatClientBuilder
Builds a pipeline of chat client middleware.
ChatClientMetadata
Provides metadata about a chat client.
ChatFinishReason
Represents the reason a chat response finished being generated.
ChatMessage
Represents a chat message used by a chat client.
ChatOptions
Represents the options for a chat request.
ChatReducer
Reduces a list of chat messages (e.g. for context window management).
ChatResponse
Represents the response to a chat request.
ChatResponseFormat
Represents the desired format of a chat response.
ChatResponseFormatJson
Requests structured JSON output without a specific schema.
ChatResponseFormatJsonSchema
Requests structured JSON output conforming to a specific schema.
ChatResponseFormatText
Requests unstructured text output.
ChatResponseUpdate
Represents a single streaming update to a chat response.
ChatRole
Represents the role of a chat message author.
ChatToolMode
Represents the mode in which tools are used by the chat client.
CitationAnnotation
An annotation citing a source.
CodeInterpreterToolCallContent
Represents a code interpreter tool call.
CodeInterpreterToolResultContent
Represents the result of a code interpreter tool call.
ConfigureOptionsChatClient
A delegating chat client that applies configuration to ChatOptions before each request.
ConfigureOptionsEmbeddingGenerator
A delegating embedding generator that applies configuration to EmbeddingGenerationOptions before each request.
ConfigureOptionsImageGenerator
A delegating image generator that applies configuration to ImageGenerationOptions before each request.
ConfigureOptionsSpeechToTextClient
A delegating speech-to-text client that applies configuration to SpeechToTextOptions before each request.
DataContent
Represents binary data content, such as an image or audio.
DelegatingAIFunction
An AIFunction that delegates all calls to an inner function.
DelegatingChatClient
A ChatClient that delegates all calls to an inner client.
DelegatingEmbeddingGenerator
An EmbeddingGenerator that delegates all calls to an inner generator.
DelegatingImageGenerator
An ImageGenerator that delegates all calls to an inner generator.
DelegatingSpeechToTextClient
A SpeechToTextClient that delegates all calls to an inner client.
Embedding
Represents a generated embedding vector.
EmbeddingGenerationOptions
Options for embedding generation requests.
EmbeddingGenerator
Represents an embedding generator.
EmbeddingGeneratorBuilder
Builds a pipeline of embedding generator middleware.
EmbeddingGeneratorMetadata
Provides metadata about an embedding generator.
ErrorContent
Represents error content in a chat response.
FunctionApprovalRequestContent
A request for user approval of a function call.
FunctionApprovalResponseContent
A user's response to a function approval request.
FunctionCallContent
Represents a request from the model to invoke a function.
FunctionInvocationContext
Provides context for a function invocation within a chat client pipeline.
FunctionInvocationResult
The result of a function invocation.
FunctionInvokingChatClient
A delegating chat client that automatically invokes functions requested by the model.
FunctionResultContent
Represents the result of a function call.
GeneratedEmbeddings
Represents a collection of generated embeddings.
HostedCodeInterpreterTool
A tool representing a hosted code interpreter capability.
HostedFileContent
Represents a reference to a file hosted by the AI service.
HostedFileSearchTool
A tool representing a hosted file search capability.
HostedImageGenerationTool
A tool representing a hosted image generation capability.
HostedMcpServerTool
A tool representing a hosted MCP server.
HostedMcpServerToolAlwaysRequireApprovalMode
Always require approval for MCP server tool calls.
HostedMcpServerToolApprovalMode
Approval mode for hosted MCP server tools.
HostedMcpServerToolNeverRequireApprovalMode
Never require approval for MCP server tool calls.
HostedMcpServerToolRequireSpecificApprovalMode
Require approval for specific MCP server tool calls.
HostedVectorStoreContent
Represents a reference to a vector store hosted by the AI service.
HostedWebSearchTool
A tool representing a hosted web search capability.
ImageGeneratingChatClient
A DelegatingChatClient that handles image generation tool calls by delegating to an ImageGenerator.
ImageGenerationOptions
Options for image generation requests.
ImageGenerationRequest
Represents an image generation request.
ImageGenerationResponse
Represents an image generation response.
ImageGenerationToolCallContent
Represents an image generation tool call by a hosted service.
ImageGenerationToolResultContent
Represents the result of an image generation tool call.
ImageGenerator
Represents an image generator.
ImageGeneratorBuilder
Builds a pipeline of image generator middleware.
ImageGeneratorMetadata
Provides metadata about an image generator.
LoggingChatClient
A delegating chat client that logs chat operations to an Logger.
LoggingEmbeddingGenerator
A delegating embedding generator that logs operations to a Logger.
LoggingImageGenerator
A delegating image generator that logs operations to a Logger.
LoggingSpeechToTextClient
A delegating speech-to-text client that logs operations to a Logger.
McpServerToolApprovalRequestContent
A request for user approval of an MCP server tool call.
McpServerToolApprovalResponseContent
A user's response to an MCP server tool approval request.
McpServerToolCallContent
Represents an MCP server tool call.
McpServerToolResultContent
Represents the result of an MCP server tool call.
MessageCountingChatReducer
A chat reducer that keeps the most recent messages up to a target count.
NoneChatToolMode
No tools should be used by the model.
ReducingChatClient
A DelegatingChatClient that reduces chat messages before forwarding requests to the inner client.
RequiredChatToolMode
The model must call at least one tool.
ResponseContinuationToken
Represents a token that can be used to resume an interrupted response.
SpeechToTextClient
Represents a speech-to-text client.
SpeechToTextClientBuilder
Builds a pipeline of speech-to-text client middleware.
SpeechToTextClientMetadata
Provides metadata about a speech-to-text client.
SpeechToTextOptions
Options for speech-to-text requests.
SpeechToTextResponse
Represents a speech-to-text response.
SpeechToTextResponseUpdate
Represents a streaming update from a speech-to-text operation.
SpeechToTextResponseUpdateKind
The kind of a speech-to-text response update.
SummarizingChatReducer
A ChatReducer that summarizes older messages using a ChatClient.
TextContent
Represents text content in a chat message.
TextReasoningContent
Represents reasoning or "thinking" content from an AI model.
TextSpanAnnotatedRegion
An annotated region defined by character span indices.
ToolReductionStrategy
Represents a strategy capable of selecting a reduced set of tools for a chat request.
UriContent
Represents content referenced by a URI.
UsageContent
Content representing usage information.
UsageDetails
Provides usage details about a request/response.
UserInputRequestContent
Abstract base for content requesting user input.
UserInputResponseContent
Abstract base for content responding to a user input request.

Enums

FunctionInvocationStatus
The status of a function invocation.

Extensions

ChatClientBuilderServiceCollectionExtensions on ServiceCollection
Provides extension methods for registering a ChatClient with a ServiceCollection.
ChatClientExtensions on ChatClient
Convenience extension methods on ChatClient.

Typedefs

AdditionalPropertiesDictionary = Map<String, Object?>
A dictionary of additional properties.
ChatClientResponseHandler = Future<ChatResponse> Function(Iterable<ChatMessage> messages, ChatOptions? options, ChatClient innerClient, CancellationToken? cancellationToken)
A function that handles a chat response request.
ChatClientStreamingResponseHandler = Stream<ChatResponseUpdate> Function(Iterable<ChatMessage> messages, ChatOptions? options, ChatClient innerClient, CancellationToken? cancellationToken)
A function that handles a streaming chat response request.
InnerClientFactory = ChatClient Function(ServiceProvider services)
InnerEmbeddingGeneratorFactory = EmbeddingGenerator Function(ServiceProvider services)
A factory that creates an EmbeddingGenerator from a ServiceProvider.
InnerImageGeneratorFactory = ImageGenerator Function(ServiceProvider services)
A factory that creates an ImageGenerator from a ServiceProvider.
InnerSpeechToTextClientFactory = SpeechToTextClient Function(ServiceProvider services)
A factory that creates a SpeechToTextClient from a ServiceProvider.