Skip to content
DocsTry Aspire
DocsTry

AspireConfigurableOpenAIExtensions Methods

ClassMethods2 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)extensionAspireOpenAIClientBuilder
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)
{
// ...
}
}
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.
AspireOpenAIClientBuilderAn OpenAI.AspireOpenAIClientBuilder that can be used to register additional services.
AddOpenAIClientFromConfiguration(IHostApplicationBuilder, string)Section titled AddOpenAIClientFromConfiguration(IHostApplicationBuilder, string)extensionAspireOpenAIClientBuilder
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)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
connectionNamestringA name used to retrieve the connection string from the ConnectionStrings configuration section.
AspireOpenAIClientBuilderAn OpenAI.AspireOpenAIClientBuilder that can be used to register additional services.