AzureOpenAIChatClientFactory
AgentPrism.Azure.dllBuilds an AzureOpenAIClient from options and produces AI.IChatClient instances from model bindings.
public sealed class AzureOpenAIChatClientFactoryInheritance
Section titled “Inheritance”object ← AzureOpenAIChatClientFactory
Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”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.
Constructors
Section titled “Constructors”AzureOpenAIChatClientFactory(AzureOpenAIProviderOptions, ILoggerFactory?)
Section titled “ AzureOpenAIChatClientFactory(AzureOpenAIProviderOptions, ILoggerFactory?)”Builds a new factory from options.
public AzureOpenAIChatClientFactory(AzureOpenAIProviderOptions options, ILoggerFactory? loggerFactory = null)Parameters
Section titled “Parameters”options AzureOpenAIProviderOptions
The provider options.
loggerFactory ILoggerFactory?
The logger factory passed to produced clients.
Exceptions
Section titled “Exceptions”options is null.
AzureOpenAIProviderOptions.Endpoint is empty, or neither an API key nor a credential factory is given.
Methods
Section titled “Methods”CreateChatClient(ModelBinding)
Section titled “ CreateChatClient(ModelBinding)”Produces a chat client for the given binding.
public IChatClient CreateChatClient(ModelBinding binding)Parameters
Section titled “Parameters”binding ModelBinding
The model binding. ModelBinding.Model is the deployment name.
Returns
Section titled “Returns”IChatClient
A chat client passed through the pipeline.
Exceptions
Section titled “Exceptions”binding is null.
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)Parameters
Section titled “Parameters”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.
Returns
Section titled “Returns”The built client.
Exceptions
Section titled “Exceptions”options is null.
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)Parameters
Section titled “Parameters”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.
Returns
Section titled “Returns”The new factory.
Remarks
Section titled “Remarks”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.
Exceptions
Section titled “Exceptions”client is null.