Skip to content

AzureOpenAIChatClientFactory

Namespace AgentPrism · Assembly AgentPrism.Azure.dll

Builds an AzureOpenAIClient from options and produces AI.IChatClient instances from model bindings.

public sealed class AzureOpenAIChatClientFactory

objectAzureOpenAIChatClientFactory

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

The factory returns a raw client. The common pipeline (UseFunctionInvocation, UseOpenTelemetry, content guard, circuit breaker, extra resolution) is set up inside ModelProviderRegistry.CreateChatClient. When the loop was set up here, none of the wrapping layers could see the tool-call turns.

AzureOpenAIClient is built once and shared; it manages its own HTTP connection pool. Building a new client on every call fragments the pool.

What Azure calls is a deployment name, not a model name. The ModelBinding.Model field carries the deployment name for this provider and goes into the request path: POST {endpoint}/openai/deployments/{deployment}/chat/completions. The same model may be deployed under one name (e.g. prod-gpt) on one resource and another (e.g. gpt-mini-tr) on another; the person who sets up the resource chooses the name.

The provider supports no keys at all inside ModelBinding.ProviderSettings. Custom fields Azure lets you add to a chat request are written through AzureChatExtensions, and those extensions break at run time against whichever OpenAI SDK version we use. When a defined key arrives, the build stops with an explicit error.

AzureOpenAIChatClientFactory(AzureOpenAIProviderOptions, ILoggerFactory?)

Section titled “ AzureOpenAIChatClientFactory(AzureOpenAIProviderOptions, ILoggerFactory?)”

Builds a new factory from options.

public AzureOpenAIChatClientFactory(AzureOpenAIProviderOptions options, ILoggerFactory? loggerFactory = null)

options AzureOpenAIProviderOptions

The provider options.

loggerFactory ILoggerFactory?

The logger factory passed to produced clients.

ArgumentNullException

options is null.

AgentPrismException

AzureOpenAIProviderOptions.Endpoint is empty, or neither an API key nor a credential factory is given.

Produces a chat client for the given binding.

public IChatClient CreateChatClient(ModelBinding binding)

binding ModelBinding

The model binding. ModelBinding.Model is the deployment name.

IChatClient

A chat client passed through the pipeline.

ArgumentNullException

binding is null.

AgentPrismException

The deployment name cannot be resolved, or ModelBinding.ProviderSettings contains any key.

CreateClient(AzureOpenAIProviderOptions, EgressSocketGuard?)

Section titled “ CreateClient(AzureOpenAIProviderOptions, EgressSocketGuard?)”

Builds an Azure OpenAI client from options.

public static AzureOpenAIClient CreateClient(AzureOpenAIProviderOptions options, EgressSocketGuard? egressGuard = null)

options AzureOpenAIProviderOptions

The provider options.

egressGuard EgressSocketGuard?

When given, every connection this client opens passes through the outbound network guard. Supplied only for a tenant-supplied endpoint override; a setup-time endpoint is the operator’s own decision and is written in code.

AzureOpenAIClient

The built client.

ArgumentNullException

options is null.

AgentPrismException

AzureOpenAIProviderOptions.Endpoint is empty, or neither an API key nor a credential factory is given.

FromClient(AzureOpenAIClient, string?, ILoggerFactory?)

Section titled “ FromClient(AzureOpenAIClient, string?, ILoggerFactory?)”

Builds a new factory from a ready-made client.

public static AzureOpenAIChatClientFactory FromClient(AzureOpenAIClient client, string? defaultDeployment = null, ILoggerFactory? loggerFactory = null)

client AzureOpenAIClient

The Azure OpenAI client to use.

defaultDeployment string?

The name to use when no deployment name is given.

loggerFactory ILoggerFactory?

The logger factory passed to produced clients.

AzureOpenAIChatClientFactory

The new factory.

Setups that build the client themselves use this factory method: it is the only escape hatch when a custom AzureOpenAIClientOptions, a sovereign cloud, or a hand-managed HTTP pipeline is needed.

ArgumentNullException

client is null.