Share via


AspireAzureAIInferenceExtensions.AddAzureChatCompletionsClient Method

Definition

Adds a ChatCompletionsClient to the application and configures it with the specified settings.

public static Microsoft.Extensions.Hosting.AspireChatCompletionsClientBuilder AddAzureChatCompletionsClient(this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string connectionName, Action<Microsoft.Extensions.Hosting.ChatCompletionsClientSettings>? configureSettings = default, Action<Azure.Core.Extensions.IAzureClientBuilder<Azure.AI.Inference.ChatCompletionsClient,Azure.AI.Inference.AzureAIInferenceClientOptions>>? configureClientBuilder = default);
static member AddAzureChatCompletionsClient : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Microsoft.Extensions.Hosting.ChatCompletionsClientSettings> * Action<Azure.Core.Extensions.IAzureClientBuilder<Azure.AI.Inference.ChatCompletionsClient, Azure.AI.Inference.AzureAIInferenceClientOptions>> -> Microsoft.Extensions.Hosting.AspireChatCompletionsClientBuilder
<Extension()>
Public Function AddAzureChatCompletionsClient (builder As IHostApplicationBuilder, connectionName As String, Optional configureSettings As Action(Of ChatCompletionsClientSettings) = Nothing, Optional configureClientBuilder As Action(Of IAzureClientBuilder(Of ChatCompletionsClient, AzureAIInferenceClientOptions)) = Nothing) As AspireChatCompletionsClientBuilder

Parameters

builder
IHostApplicationBuilder

The IHostApplicationBuilder to add the client to.

connectionName
String

The name of the client. This is used to retrieve the connection string from configuration.

configureSettings
Action<ChatCompletionsClientSettings>

An optional callback to configure the ChatCompletionsClientSettings.

configureClientBuilder
Action<IAzureClientBuilder<ChatCompletionsClient,AzureAIInferenceClientOptions>>

An optional callback to configure the IAzureClientBuilder<TClient,TOptions> for the client.

Returns

An AspireChatCompletionsClientBuilder that can be used to further configure the client.

Exceptions

Thrown when endpoint is missing from settings.

Remarks

The client is registered as a singleton with a keyed service.

Configuration is loaded from the "Aspire:Azure:AI:Inference" section, and can be supplemented with a connection string named after the connectionName parameter.

Applies to