From 19095fadcd91e1d9acbc03bb815a1f5f925c3aa0 Mon Sep 17 00:00:00 2001 From: tkattkat Date: Wed, 12 Nov 2025 13:34:36 -0800 Subject: [PATCH 1/2] add support for custom baseURL with google computer use --- packages/core/lib/v3/agent/GoogleCUAClient.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/core/lib/v3/agent/GoogleCUAClient.ts b/packages/core/lib/v3/agent/GoogleCUAClient.ts index 968a542a4..9630472b4 100644 --- a/packages/core/lib/v3/agent/GoogleCUAClient.ts +++ b/packages/core/lib/v3/agent/GoogleCUAClient.ts @@ -6,6 +6,7 @@ import { FunctionCall, GenerateContentConfig, Tool, + GoogleGenAIOptions, } from "@google/genai"; import { LogLine } from "../types/public/logs"; import { @@ -42,6 +43,7 @@ export class GoogleCUAClient extends AgentClient { "ENVIRONMENT_BROWSER"; private generateContentConfig: GenerateContentConfig; private tools?: ToolSet; + private baseURL?: string; constructor( type: AgentType, modelName: string, @@ -58,11 +60,14 @@ export class GoogleCUAClient extends AgentClient { process.env.GEMINI_API_KEY || process.env.GOOGLE_GENERATIVE_AI_API_KEY || ""; + this.baseURL = clientOptions?.baseURL as string | undefined; // Initialize the Google Generative AI client - this.client = new GoogleGenAI({ + const genAIOptions: GoogleGenAIOptions = { apiKey: this.apiKey, - }); + ...(this.baseURL ? { httpOptions: { baseUrl: this.baseURL } } : {}), + }; + this.client = new GoogleGenAI(genAIOptions); // Get environment if specified if ( @@ -92,6 +97,7 @@ export class GoogleCUAClient extends AgentClient { // Store client options for reference this.clientOptions = { apiKey: this.apiKey, + ...(this.baseURL ? { baseURL: this.baseURL } : {}), }; // Initialize tools if provided From 1e7e69a6ab47ede9756cb4e004338f43ac76d133 Mon Sep 17 00:00:00 2001 From: tkattkat Date: Wed, 12 Nov 2025 13:35:18 -0800 Subject: [PATCH 2/2] changeset --- .changeset/shiny-eels-stand.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/shiny-eels-stand.md diff --git a/.changeset/shiny-eels-stand.md b/.changeset/shiny-eels-stand.md new file mode 100644 index 000000000..a07c78374 --- /dev/null +++ b/.changeset/shiny-eels-stand.md @@ -0,0 +1,5 @@ +--- +"@browserbasehq/stagehand": patch +--- + +Add support for a custom baseUrl with google cua client