AnthropicChatClientFactory
AgentPrism.Anthropic.dllBuilds an Anthropic.AnthropicClient from settings and produces
AI.IChatClient instances from model bindings.
public sealed class AnthropicChatClientFactoryInheritance
Section titled “Inheritance”object ← AnthropicChatClientFactory
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 shared pipeline
(UseFunctionInvocation, UseOpenTelemetry, the content guard,
the circuit breaker, usage resolution) is built inside
ModelProviderRegistry.CreateChatClient.
When the loop was built here, none of the layers the registry
wrapped around it could see the tool-call turns.
Anthropic.AnthropicClient is built once and shared; it manages its own HTTP
connection pool. Building a new client per call would fragment the pool.
The Anthropic Messages API treats max_tokens as
required. When ModelBinding.MaxOutputTokens is
left empty, AnthropicProviderOptions.DefaultMaxOutputTokens is
used instead.
Constructors
Section titled “Constructors”AnthropicChatClientFactory(AnthropicProviderOptions, ILoggerFactory?)
Section titled “ AnthropicChatClientFactory(AnthropicProviderOptions, ILoggerFactory?)”Builds a new factory from settings.
public AnthropicChatClientFactory(AnthropicProviderOptions options, ILoggerFactory? loggerFactory = null)Parameters
Section titled “Parameters”options AnthropicProviderOptions
Provider settings.
loggerFactory ILoggerFactory?
Logger factory passed to produced clients.
Exceptions
Section titled “Exceptions”options is null.
AnthropicProviderOptions.ApiKey is empty.
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.
Returns
Section titled “Returns”IChatClient
A chat client that has passed through the pipeline.
Exceptions
Section titled “Exceptions”binding is null.
The model name cannot be resolved, or ModelBinding.ProviderSettings contains an unrecognized key.
CreateClient(AnthropicProviderOptions, EgressSocketGuard?)
Section titled “ CreateClient(AnthropicProviderOptions, EgressSocketGuard?)”Builds an Anthropic client from settings.
public static AnthropicClient CreateClient(AnthropicProviderOptions options, EgressSocketGuard? egressGuard = null)Parameters
Section titled “Parameters”options AnthropicProviderOptions
Provider settings.
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”AnthropicClient
The constructed client.
Exceptions
Section titled “Exceptions”options is null.
AnthropicProviderOptions.ApiKey is empty.
FromClient(IAnthropicClient, string?, int, ILoggerFactory?)
Section titled “ FromClient(IAnthropicClient, string?, int, ILoggerFactory?)”Builds a new factory from an already-constructed client.
public static AnthropicChatClientFactory FromClient(IAnthropicClient client, string? defaultModel = null, int defaultMaxOutputTokens = 4096, ILoggerFactory? loggerFactory = null)Parameters
Section titled “Parameters”client IAnthropicClient
The Anthropic client to use.
defaultModel string?
The model to use when no model name is given.
defaultMaxOutputTokens int
The upper bound used when ModelBinding.MaxOutputTokens is not given.
loggerFactory ILoggerFactory?
Logger factory passed to produced clients.
Returns
Section titled “Returns”The new factory.
Remarks
Section titled “Remarks”Setups that manage their own authentication (for example Bedrock/Vertex identity, or a provider that refreshes tokens) use this factory method.
Exceptions
Section titled “Exceptions”client is null.
defaultMaxOutputTokens is not positive.