AspireAzureProjectOpenAIExtensions Methods
ClassMethods2 members
Registers Azure AI Project OpenAI clients with configuration and Microsoft.Extensions.AI telemetry.
AddAzureProjectOpenAIClient(IHostApplicationBuilder, string, Action<AzureProjectOpenAISettings>, Action<IAzureClientBuilder<ProjectOpenAIClient, ProjectOpenAIClientOptions>>) Section titled AddAzureProjectOpenAIClient(IHostApplicationBuilder, string, Action<AzureProjectOpenAISettings>, Action<IAzureClientBuilder<ProjectOpenAIClient, ProjectOpenAIClientOptions>>)extensionAspire Registers
OpenAI.ProjectOpenAIClient and its OpenAIClient alias as singletons. public static class AspireAzureProjectOpenAIExtensions{ public static AspireAzureProjectOpenAIClientBuilder AddAzureProjectOpenAIClient( this IHostApplicationBuilder builder, string connectionName, Action<AzureProjectOpenAISettings>? configureSettings = null, Action<IAzureClientBuilder<ProjectOpenAIClient, ProjectOpenAIClientOptions>>? configureClientBuilder = null) { // ... }}Parameters
builderIHostApplicationBuilder The application builder.connectionName stringThe project connection-string name.configureSettings Action<AzureProjectOpenAISettings> optionalCustomizes settings after configuration and connection-string binding.configureClientBuilder Action<IAzureClientBuilder<ProjectOpenAIClient, ProjectOpenAIClientOptions>> optionalCustomizes the Azure client registration and options.Returns
AspireAzureProjectOpenAIClientBuilder A builder for registering model clients and Microsoft.Extensions.AI services.Exceptions
ArgumentNullExceptionbuilder is null.ArgumentExceptionconnectionName is null or empty, or the connection string is invalid.Remarks
Reads configuration from
Aspire:Azure:AI:Extensions:OpenAI and its connection-specific subsection.Examples
builder.AddAzureProjectOpenAIClient("project").AddChatClient("chat");AddKeyedAzureProjectOpenAIClient(IHostApplicationBuilder, string, Action<AzureProjectOpenAISettings>, Action<IAzureClientBuilder<ProjectOpenAIClient, ProjectOpenAIClientOptions>>) Section titled AddKeyedAzureProjectOpenAIClient(IHostApplicationBuilder, string, Action<AzureProjectOpenAISettings>, Action<IAzureClientBuilder<ProjectOpenAIClient, ProjectOpenAIClientOptions>>)extensionAspire Registers
OpenAI.ProjectOpenAIClient and its OpenAIClient alias as keyed singletons. public static class AspireAzureProjectOpenAIExtensions{ public static AspireAzureProjectOpenAIClientBuilder AddKeyedAzureProjectOpenAIClient( this IHostApplicationBuilder builder, string name, Action<AzureProjectOpenAISettings>? configureSettings = null, Action<IAzureClientBuilder<ProjectOpenAIClient, ProjectOpenAIClientOptions>>? configureClientBuilder = null) { // ... }}Parameters
builderIHostApplicationBuilder The application builder.namestringThe service key and project connection-string name.configureSettings Action<AzureProjectOpenAISettings> optionalCustomizes settings after configuration and connection-string binding.configureClientBuilder Action<IAzureClientBuilder<ProjectOpenAIClient, ProjectOpenAIClientOptions>> optionalCustomizes the Azure client registration and options.Returns
AspireAzureProjectOpenAIClientBuilder A builder for registering model clients and Microsoft.Extensions.AI services.Exceptions
ArgumentNullExceptionbuilder is null.ArgumentExceptionname is null or empty, or the connection string is invalid.Remarks
Uses
name for both configuration lookup and keyed service resolution.Examples
builder.AddKeyedAzureProjectOpenAIClient("project").AddKeyedChatClient("chat-client", "chat");