ProviderCredentialClientCache<TFactory\>
AgentPrism.Core.dllBuilds and caches a provider-specific client factory keyed by a resolved ModelProviderCredential (BYOK).
public sealed class ProviderCredentialClientCache<TFactory> where TFactory : classType Parameters
Section titled “Type Parameters”TFactory
The provider-specific chat client factory type.
Inheritance
Section titled “Inheritance”object ← ProviderCredentialClientCache<TFactory>
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”Every provider package’s SDK client is built once and shared (measured:
OpenAIClient, AnthropicClient, the Google GenAI
Client, and AzureOpenAIClient are all constructed once in
their factory and manage their own HTTP connection pool). A tenant
credential cannot reuse that shared instance — it carries a different key
— so a second client is built for it. This cache exists so that is done
once per distinct credential, not once per call: the same
pattern OpenAINamedChatClientFactoryCache already uses for named
OpenAI-compatible providers, generalized so all four provider packages can
share it (every provider package already references AgentPrism.Core).
The cache key is the credential’s own value (API key + endpoint), not a tenant id: two tenants that happen to share the same credential get the same cached client, which is correct — the credential, not the tenant, is the identity boundary here.
Entries are never evicted. The number of distinct credentials is
bounded by the number of tenant provider bindings an operator manages
(a small, admin-controlled set), not by request volume, so unbounded
growth is not a practical concern — the same trade-off
OpenAINamedChatClientFactoryCache already makes.
Constructors
Section titled “Constructors”ProviderCredentialClientCache()
Section titled “ ProviderCredentialClientCache()”public ProviderCredentialClientCache()Methods
Section titled “Methods”GetOrAdd(ModelProviderCredential, Func<ModelProviderCredential, TFactory>)
Section titled “ GetOrAdd(ModelProviderCredential, Func<ModelProviderCredential, TFactory>)”Returns the factory for the given credential, building and caching it when absent.
public TFactory GetOrAdd(ModelProviderCredential credential, Func<ModelProviderCredential, TFactory> build)Parameters
Section titled “Parameters”credential ModelProviderCredential
The resolved credential.
build Func<ModelProviderCredential, TFactory>
Builds a factory from the credential when not already cached.
Returns
Section titled “Returns”TFactory
The cached factory.
Exceptions
Section titled “Exceptions”A parameter is null.