GoogleChatClientFactory
AgentPrism.Google.dllBuilds a Google GenAI GenAI.Client from settings and produces
AI.IChatClient instances from model bindings.
public sealed class GoogleChatClientFactory : IDisposableInheritance
Section titled “Inheritance”object ← GoogleChatClientFactory
Implements
Section titled “Implements”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, cost resolution) is built inside
ModelProviderRegistry.CreateChatClient.
When the loop was built here, no ring wrapped by the ledger could
see the tool call rounds.
The GenAI.Client is built once and shared; it manages its own HTTP
connection pool. The factory implements IDisposable, so the
client closes when the container shuts down.
Constructors
Section titled “Constructors”GoogleChatClientFactory(GoogleProviderOptions, ILoggerFactory?)
Section titled “ GoogleChatClientFactory(GoogleProviderOptions, ILoggerFactory?)”Builds a new factory from settings.
public GoogleChatClientFactory(GoogleProviderOptions options, ILoggerFactory? loggerFactory = null)Parameters
Section titled “Parameters”options GoogleProviderOptions
Provider settings.
loggerFactory ILoggerFactory?
Logger factory passed to produced clients.
Exceptions
Section titled “Exceptions”options is null.
GoogleProviderOptions.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
Model binding.
Returns
Section titled “Returns”IChatClient
A chat client that has gone through the pipeline.
Exceptions
Section titled “Exceptions”binding is null.
The model name cannot be resolved, or ModelBinding.ProviderSettings carries an unknown key or threshold value.
CreateClient(GoogleProviderOptions, EgressSocketGuard?)
Section titled “ CreateClient(GoogleProviderOptions, EgressSocketGuard?)”Builds a Google GenAI client from settings.
public static Client CreateClient(GoogleProviderOptions options, EgressSocketGuard? egressGuard = null)Parameters
Section titled “Parameters”options GoogleProviderOptions
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”Client
The built client.
Remarks
Section titled “Remarks”The base address is passed via Types.HttpOptions. The SDK’s static
Client.setDefaultBaseUrl method is deliberately not used: it mutates
process-wide state, which would make it impossible to use two different
Gemini endpoints in the same application.
Exceptions
Section titled “Exceptions”options is null.
GoogleProviderOptions.ApiKey is empty.
Dispose()
Section titled “ Dispose()”public void Dispose()FromClient(Client, string?, ILoggerFactory?)
Section titled “ FromClient(Client, string?, ILoggerFactory?)”Builds a new factory from a ready-made client.
public static GoogleChatClientFactory FromClient(Client client, string? defaultModel = null, ILoggerFactory? loggerFactory = null)Parameters
Section titled “Parameters”client Client
Google GenAI client to use.
defaultModel string?
Model to use when no model name is 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, a Vertex AI service account) use this factory method. The lifetime of a client passed this way belongs to the caller; the factory does not close it.
Exceptions
Section titled “Exceptions”client is null.