Skip to content

AzureOpenAIProviderExtensions

Namespace AgentPrism · Assembly AgentPrism.Azure.dll

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

public static class AzureOpenAIProviderExtensions

objectAzureOpenAIProviderExtensions

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

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

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

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

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

builder IAgentPrismBuilder

The AgentPrism chain.

endpoint Uri

The Azure OpenAI resource’s address.

apiKey string

The resource’s API key.

configure Action<AzureOpenAIProviderOptions>?

An extra option modifier.

IAgentPrismBuilder

The continuation of the chain.

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

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

ArgumentNullException

builder or endpoint is null.

ArgumentException

apiKey is empty.

UseAzureOpenAI(IAgentPrismBuilder, IConfiguration)

Section titled “ UseAzureOpenAI(IAgentPrismBuilder, IConfiguration)”

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

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

builder IAgentPrismBuilder

The AgentPrism chain.

configurationSection IConfiguration

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

IAgentPrismBuilder

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(IAgentPrismBuilder, Action<AzureOpenAIProviderOptions>)

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

Adds the Azure OpenAI provider by giving options in code.

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

builder IAgentPrismBuilder

The AgentPrism chain.

configure Action<AzureOpenAIProviderOptions>

The option modifier.

IAgentPrismBuilder

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.