google.VertexClient

Gemini on Vertex AI: the same models as `google.GeminiClient`, reached through a Google Cloud project with Google Cloud credentials.

Reference version

Signature

class google.VertexClient

Gemini on Vertex AI: the same models as google.GeminiClient, reached through a Google Cloud project with Google Cloud credentials.

Three ways to authenticate, in the order the client tries them:

  • credentials_json — an inline credential document (service account, authorized user, workload identity federation, impersonated service account);
  • credentials_file — a path to one, plus the GOOGLE_APPLICATION_CREDENTIALS_CONTENT env var holding a document inline;
  • nothing — Application Default Credentials (GOOGLE_APPLICATION_CREDENTIALS, the well-known ADC file, the gcloud config file, the GCE metadata server).

api_key selects Vertex AI express mode instead: the key rides the URL as ?key=…, no credentials are read, and the request goes to the project-less global endpoint unless a project is configured.

Source:<builtin>/google/vertex.bamlbytes 9366394

Fields

model

string

project_id

ai.Credential | null

location

string | null

credentials_json

string | null

credentials_file

string | null

api_key

ai.Credential | null

base_url

ai.Credential | null

request_timeout_ms

int | null

time_to_first_token_timeout_ms

int | 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 = …,
project_id: ai.Credential | null = …,
location: string | null = …,
credentials_json: string | null = …,
credentials_file: string | null = …,
api_key: ai.Credential | null = …,
base_url: ai.Credential | null = …,
request_timeout_ms: int | null = …,
time_to_first_token_timeout_ms: int | 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.VertexClient

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 | null throws baml.errors.Io | baml.errors.ParseError

The express-mode key, or null for OAuth2. Unlike the other providers this may legitimately be absent: credentials are the normal path.

function

resolved_base_url

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

The request-time base URL, or null to build one from project + location.

Implementations

ai.Client for google.VertexClient

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/vertex.bamlbytes 55316095

ai.stream.StreamingClient for google.VertexClient

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/vertex.bamlbytes 61016392