Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shiny-eels-stand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Add support for a custom baseUrl with google cua client
10 changes: 8 additions & 2 deletions packages/core/lib/v3/agent/GoogleCUAClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
FunctionCall,
GenerateContentConfig,
Tool,
GoogleGenAIOptions,
} from "@google/genai";
import { LogLine } from "../types/public/logs";
import {
Expand Down Expand Up @@ -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,
Expand All @@ -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 (
Expand Down Expand Up @@ -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
Expand Down