Skip to content
DocsTry Aspire
DocsTry

AspireAzureOpenAIExtensions Methods

ClassMethods2 members
Provides extension methods for registering OpenAI.AzureOpenAIClient as a singleton in the services provided by the Hosting.IHostApplicationBuilder.
AddAzureOpenAIClient(IHostApplicationBuilder, string, Action<AzureOpenAISettings>, Action<IAzureClientBuilder<AzureOpenAIClient, AzureOpenAIClientOptions>>)Section titled AddAzureOpenAIClient(IHostApplicationBuilder, string, Action<AzureOpenAISettings>, Action<IAzureClientBuilder<AzureOpenAIClient, AzureOpenAIClientOptions>>)extensionAspireAzureOpenAIClientBuilder
Registers OpenAI.AzureOpenAIClient as a singleton in the services provided by the builder. Additionally, registers the OpenAI.AzureOpenAIClient as an OpenAIClient service.
public static class AspireAzureOpenAIExtensions
{
public static AspireAzureOpenAIClientBuilder AddAzureOpenAIClient(
this IHostApplicationBuilder builder,
string connectionName,
Action<AzureOpenAISettings>? configureSettings = null,
Action<IAzureClientBuilder<AzureOpenAIClient, AzureOpenAIClientOptions>>? configureClientBuilder = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
connectionNamestringA name used to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<AzureOpenAISettings>optionalAn optional method that can be used for customizing the AzureOpenAISettings. It's invoked after the settings are read from the configuration.
configureClientBuilderAction<IAzureClientBuilder<AzureOpenAIClient, AzureOpenAIClientOptions>>optionalAn optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
AspireAzureOpenAIClientBuilderAn AspireAzureOpenAIClientBuilder that can be used to register additional services.
Reads the configuration from "Aspire.Azure.AI.OpenAI" section.
AddKeyedAzureOpenAIClient(IHostApplicationBuilder, string, Action<AzureOpenAISettings>, Action<IAzureClientBuilder<AzureOpenAIClient, AzureOpenAIClientOptions>>)Section titled AddKeyedAzureOpenAIClient(IHostApplicationBuilder, string, Action<AzureOpenAISettings>, Action<IAzureClientBuilder<AzureOpenAIClient, AzureOpenAIClientOptions>>)extensionAspireAzureOpenAIClientBuilder
Registers OpenAI.AzureOpenAIClient as a singleton for given name in the services provided by the builder. Additionally, registers the OpenAI.AzureOpenAIClient as an OpenAIClient service.
public static class AspireAzureOpenAIExtensions
{
public static AspireAzureOpenAIClientBuilder AddKeyedAzureOpenAIClient(
this IHostApplicationBuilder builder,
string name,
Action<AzureOpenAISettings>? configureSettings = null,
Action<IAzureClientBuilder<AzureOpenAIClient, AzureOpenAIClientOptions>>? configureClientBuilder = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
namestringThe name of the component, which is used as the ServiceDescriptor.ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<AzureOpenAISettings>optionalAn optional method that can be used for customizing the AzureOpenAISettings. It's invoked after the settings are read from the configuration.
configureClientBuilderAction<IAzureClientBuilder<AzureOpenAIClient, AzureOpenAIClientOptions>>optionalAn optional method that can be used for customizing the Extensions.IAzureClientBuilder`2.
AspireAzureOpenAIClientBuilderAn AspireAzureOpenAIClientBuilder that can be used to register additional services.
Reads the configuration from "Aspire.Azure.AI.OpenAI:{name}" section.