google.GeminiClient

The Gemini Developer API client (`generativelanguage.googleapis.com`).

Reference version

Signature

class google.GeminiClient

The Gemini Developer API client (generativelanguage.googleapis.com).

This client always talks to the Developer API. There is no environment switch that re-points it at Vertex AI — the GOOGLE_GENAI_USE_ENTERPRISE / GOOGLE_GENAI_USE_VERTEXAI flags of the google-genai SDK are deliberately NOT honored here, because a credential-bearing client that changes endpoint, auth scheme and billing account behind an ambient env var is a footgun. Use the enterprise backend by naming it: google.VertexClient.new(...), or the "vertex/<model>" client shorthand.

Source:<builtin>/google/gemini.bamlbytes 17116845

Fields

model

string

api_key

ai.Credential | null

base_url

ai.Credential | null

request_body

baml.json.json | null

headers

map<string, string> | null

query_params

map<string, string> | null

temperature

float | null

max_output_tokens

int | null

top_p

float | null

top_k

int | null

stop_sequences

string[] | null

response_modalities

string[] | null

capture_wire

bool

Static methods

function

new

(
model: string = …,
api_key: ai.Credential | null = …,
base_url: ai.Credential | null = …,
request_body: baml.json.json | null = …,
headers: map<string, string> | null = …,
query_params: map<string, string> | null = …,
temperature: float | null = …,
max_output_tokens: int | null = …,
top_p: float | null = …,
top_k: int | null = …,
stop_sequences: string[] | null = …,
response_modalities: string[] | null = …,
safety_settings: google.SafetySetting[] | null = …,
capture_wire: bool = …
) -> google.GeminiClient

Creates a client. Construction reads no environment variable, so declaring one is always safe; credentials and endpoints resolve when a request is built.

Instance methods

function

resolved_api_key

(
self
) -> string throws baml.errors.Io | baml.errors.ParseError | ai.errors.InvalidRequest

The request-time credential: an explicit value, else the provider's canonical one. A missing key is a CATCHABLE configuration error, not a panic: baml.env.get_or_panic unwinds past the catch_all + ai.errors.normalize wrapper below, so an unset variable would take the process down instead of surfacing as an ai.errors.Failure.

function

resolved_base_url

(self) -> string | null throws baml.errors.Io | baml.errors.ParseError

The request-time base URL, or null for the provider default.

Implementations

ai.Client for google.GeminiClient

Instance methods

function

id

(self) -> string
function

invoke

(
self,
input: ai.ModelTurnInput
) -> ai.ModelTurn throws baml.errors.Timeout | baml.errors.UnknownError | reflect.errors.CompilationError | ai.errors.Failure
function

render

(
self,
input: ai.ModelTurnInput
) -> baml.http.Request throws baml.errors.Timeout | baml.errors.UnknownError | reflect.errors.CompilationError | ai.errors.Failure

Source:<builtin>/google/gemini.bamlbytes 59896546

ai.stream.StreamingClient for google.GeminiClient

Instance methods

function

invoke_stream

(
self,
input: ai.ModelTurnInput
) -> ai.stream.TurnStream throws baml.errors.Timeout | baml.errors.UnknownError | reflect.errors.CompilationError | ai.errors.Failure

Source:<builtin>/google/gemini.bamlbytes 65526843