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>>)extensionAspireAzureProjectOpenAIClientBuilder
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)
{
// ...
}
}
builderIHostApplicationBuilderThe application builder.
connectionNamestringThe project connection-string name.
configureSettingsAction<AzureProjectOpenAISettings>optionalCustomizes settings after configuration and connection-string binding.
configureClientBuilderAction<IAzureClientBuilder<ProjectOpenAIClient, ProjectOpenAIClientOptions>>optionalCustomizes the Azure client registration and options.
AspireAzureProjectOpenAIClientBuilderA builder for registering model clients and Microsoft.Extensions.AI services.
ArgumentNullExceptionbuilder is null.
ArgumentExceptionconnectionName is null or empty, or the connection string is invalid.
Reads configuration from Aspire:Azure:AI:Extensions:OpenAI and its connection-specific subsection.
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>>)extensionAspireAzureProjectOpenAIClientBuilder
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)
{
// ...
}
}
builderIHostApplicationBuilderThe application builder.
namestringThe service key and project connection-string name.
configureSettingsAction<AzureProjectOpenAISettings>optionalCustomizes settings after configuration and connection-string binding.
configureClientBuilderAction<IAzureClientBuilder<ProjectOpenAIClient, ProjectOpenAIClientOptions>>optionalCustomizes the Azure client registration and options.
AspireAzureProjectOpenAIClientBuilderA builder for registering model clients and Microsoft.Extensions.AI services.
ArgumentNullExceptionbuilder is null.
ArgumentExceptionname is null or empty, or the connection string is invalid.
Uses name for both configuration lookup and keyed service resolution.
builder.AddKeyedAzureProjectOpenAIClient("project").AddKeyedChatClient("chat-client", "chat");