Skip to content

AnthropicModelProvider

Namespace AgentPrism · Assembly AgentPrism.Anthropic.dll

IModelProvider implementation for Anthropic (Claude).

public sealed class AnthropicModelProvider : IModelProvider, IModelProviderHealthCheck, IModelProviderConfigurationDiagnostics

objectAnthropicModelProvider

IModelProvider, IModelProviderHealthCheck, IModelProviderConfigurationDiagnostics

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

The provider does not reject a model name that is absent from the catalog. AgentPrism does not need a new release when Anthropic ships a new model; when the catalog is non-empty, only an informational log entry is written.

Circuit-breaker and content-filter detection live outside this type, at the ModelProviderRegistry level; this package gets both for free.

AnthropicModelProvider(string, AnthropicChatClientFactory, IReadOnlyList<ModelDescriptor>, ILogger<AnthropicModelProvider>?, AnthropicProviderOptions?, EgressSocketGuard?)

Section titled “ AnthropicModelProvider(string, AnthropicChatClientFactory, IReadOnlyList<ModelDescriptor>, ILogger<AnthropicModelProvider>?, AnthropicProviderOptions?, EgressSocketGuard?)”

Creates a new provider.

public AnthropicModelProvider(string name, AnthropicChatClientFactory chatClientFactory, IReadOnlyList<ModelDescriptor> models, ILogger<AnthropicModelProvider>? logger = null, AnthropicProviderOptions? healthCheckOptions = null, EgressSocketGuard? egressGuard = null)

name string

Provider name. Matches ModelBinding.Provider in agent definitions.

chatClientFactory AnthropicChatClientFactory

Chat client factory.

models IReadOnlyList<ModelDescriptor>

The models this provider offers.

logger ILogger<AnthropicModelProvider>?

Logger.

healthCheckOptions AnthropicProviderOptions?

When given, AnthropicModelProvider.CheckHealthAsync calls GET {endpoint}/models using the address and key in these settings. When null, health status always returns ModelProviderHealthStatus.Unknown.

egressGuard EgressSocketGuard?

The outbound network guard. Attached only to a client built from a tenant-supplied endpoint override; when null, such an override is not guarded.

ArgumentNullException

One of the required dependencies is null.

ArgumentException

name is empty.

The models this provider offers.

public IReadOnlyList<ModelDescriptor> Models { get; }

IReadOnlyList<ModelDescriptor>

The provider name. ModelBinding.Provider matches this value. Comparison is case-insensitive.

public string Name { get; }

string

Checks the provider’s reachability.

public ValueTask<ModelProviderHealth> CheckHealthAsync(CancellationToken cancellationToken = default)

cancellationToken CancellationToken

The cancellation token.

ValueTask<ModelProviderHealth>

The check result.

CreateChatClient(ModelBinding, ModelProviderCredential?)

Section titled “ CreateChatClient(ModelBinding, ModelProviderCredential?)”

Produces a raw chat client for the given binding.

public IChatClient CreateChatClient(ModelBinding binding, ModelProviderCredential? credential = null)

binding ModelBinding

The model binding.

credential ModelProviderCredential?

A resolved per-tenant credential (BYOK). When null, the provider’s own setup-time credential is used and behavior is identical to a setup without per-tenant credentials. When given, the provider builds (or reuses a cached) client using ModelProviderCredential.ApiKey and, if present, ModelProviderCredential.Endpoint, instead of its setup-time credential.

IChatClient

The provider-specific client. Decorators specific to the provider (example: Anthropic’s settings decorator) may be added here.

Do not build the common pipeline here. UseFunctionInvocation, UseOpenTelemetry, the content guard, the circuit breaker, and extra resolution are added by ModelProviderRegistry.CreateChatClient. Before that shared pipeline, every provider package built the tool-call loop inside itself; the result was that no ring the registry wraps around could see the loop’s turns — a tool result entered the model uninspected.

If the loop is also built here, two nested FunctionInvokingChatClient instances form: the inner one resolves tools, the outer one never sees any call. The damage is not functional but measurable (double wrapping, a misleading span tree).

Returns the resolution status of the configuration key required by this provider.

public ConfigurationDiagnostic? GetConfigurationDiagnostic()

ConfigurationDiagnostic?

null when the provider was not configured with an options object.