Skip to content
Tracon

AzureOpenAIProviderExtensions

Namespace Tracon · Assembly Tracon.Azure.dll

Extensions that add the Azure OpenAI provider to the Tracon chain.

public static class AzureOpenAIProviderExtensions
Inheritance
object ← AzureOpenAIProviderExtensions
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

UseAzureOpenAI(ITraconBuilder, Uri, string, Action<AzureOpenAIProviderOptions>?)

Section titled “ UseAzureOpenAI(ITraconBuilder, Uri, string, Action<AzureOpenAIProviderOptions>?)”

Adds the Azure OpenAI provider by giving an endpoint and API key.

public static ITraconBuilder UseAzureOpenAI(this ITraconBuilder builder, Uri endpoint, string apiKey, Action<AzureOpenAIProviderOptions>? configure = null)

builder ITraconBuilder

The Tracon chain.

endpoint Uri

The Azure OpenAI resource’s address.

apiKey string

The resource’s API key.

configure Action<AzureOpenAIProviderOptions>?

An extra option modifier.

ITraconBuilder

The continuation of the chain.

To use a managed credential, use AzureOpenAIProviderExtensions.UseAzureOpenAI instead of this overload, and give AzureOpenAIProviderOptions.CredentialFactory.

builder.AddTracon()
.UseAzureOpenAI(
new Uri(builder.Configuration["AzureOpenAI:Endpoint"]!),
builder.Configuration["AzureOpenAI:ApiKey"]!);

ArgumentNullException

builder or endpoint is null.

ArgumentException

apiKey is empty.

UseAzureOpenAI(ITraconBuilder, IConfiguration)

Section titled “ UseAzureOpenAI(ITraconBuilder, IConfiguration)”

Adds the Azure OpenAI provider by reading options from the Tracon:Providers:AzureOpenAI section.

public static ITraconBuilder UseAzureOpenAI(this ITraconBuilder builder, IConfiguration configurationSection)

builder ITraconBuilder

The Tracon chain.

configurationSection IConfiguration

The section to read options from. Typically configuration.GetSection(AzureOpenAIProviderOptions.SectionName).

ITraconBuilder

The continuation of the chain.

AzureOpenAIProviderOptions.CredentialFactory cannot be read from configuration; call the AzureOpenAIProviderExtensions.UseAzureOpenAI overload afterward to set it in code.

ArgumentNullException

builder or configurationSection is null.

UseAzureOpenAI(ITraconBuilder, Action<AzureOpenAIProviderOptions>)

Section titled “ UseAzureOpenAI(ITraconBuilder, Action<AzureOpenAIProviderOptions>)”

Adds the Azure OpenAI provider by giving options in code.

public static ITraconBuilder UseAzureOpenAI(this ITraconBuilder builder, Action<AzureOpenAIProviderOptions> configure)

builder ITraconBuilder

The Tracon chain.

configure Action<AzureOpenAIProviderOptions>

The option modifier.

ITraconBuilder

The continuation of the chain.

This call registers exactly one provider: AzureOpenAIProviderNames.AzureOpenAI.

Registration happens through AddModelProvider(...); no existing service is replaced. When called more than once, the options are merged; the provider is registered only once.

ArgumentNullException

One of the parameters is null.