Skip to content

GoogleChatClientFactory

Namespace AgentPrism · Assembly AgentPrism.Google.dll

Builds a Google GenAI GenAI.Client from settings and produces AI.IChatClient instances from model bindings.

public sealed class GoogleChatClientFactory : IDisposable

objectGoogleChatClientFactory

IDisposable

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

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.

GoogleChatClientFactory(GoogleProviderOptions, ILoggerFactory?)

Section titled “ GoogleChatClientFactory(GoogleProviderOptions, ILoggerFactory?)”

Builds a new factory from settings.

public GoogleChatClientFactory(GoogleProviderOptions options, ILoggerFactory? loggerFactory = null)

options GoogleProviderOptions

Provider settings.

loggerFactory ILoggerFactory?

Logger factory passed to produced clients.

ArgumentNullException

options is null.

AgentPrismException

GoogleProviderOptions.ApiKey is empty.

Produces a chat client for the given binding.

public IChatClient CreateChatClient(ModelBinding binding)

binding ModelBinding

Model binding.

IChatClient

A chat client that has gone through the pipeline.

ArgumentNullException

binding is null.

AgentPrismException

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)

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.

Client

The built client.

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.

ArgumentNullException

options is null.

AgentPrismException

GoogleProviderOptions.ApiKey is empty.

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)

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.

GoogleChatClientFactory

The new factory.

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.

ArgumentNullException

client is null.