Skip to content
Docs Try Aspire

AspireConfigurableOpenAIExtensions Methods

Class Methods 2 members
Provides extension methods for registering OpenAIClient or OpenAI.AzureOpenAIClient as a singleton in the services provided by the Hosting.IHostApplicationBuilder.
AddKeyedOpenAIClientFromConfiguration(IHostApplicationBuilder, string) Section titled AddKeyedOpenAIClientFromConfiguration(IHostApplicationBuilder, string) extension AspireOpenAIClientBuilder
Registers OpenAIClient as a singleton in the services provided by the builder. The concrete implementation is selected automatically from configuration.
public static class AspireConfigurableOpenAIExtensions
{
public static AspireOpenAIClientBuilder AddKeyedOpenAIClientFromConfiguration(
this IHostApplicationBuilder builder,
string name)
{
// ...
}
}
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.
name string The 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.
AspireOpenAIClientBuilder An OpenAI.AspireOpenAIClientBuilder that can be used to register additional services.
AddOpenAIClientFromConfiguration(IHostApplicationBuilder, string) Section titled AddOpenAIClientFromConfiguration(IHostApplicationBuilder, string) extension AspireOpenAIClientBuilder
Registers OpenAIClient or OpenAI.AzureOpenAIClient as a singleton in the services provided by the builder. The concrete implementation is selected automatically from configuration.
public static class AspireConfigurableOpenAIExtensions
{
public static AspireOpenAIClientBuilder AddOpenAIClientFromConfiguration(
this IHostApplicationBuilder builder,
string connectionName)
{
// ...
}
}
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.
connectionName string A name used to retrieve the connection string from the ConnectionStrings configuration section.
AspireOpenAIClientBuilder An OpenAI.AspireOpenAIClientBuilder that can be used to register additional services.