Skip to content

Stagehand Agent mode should allow providing baseURL for OpenAICUAClient #643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
majkiw opened this issue Apr 7, 2025 · 1 comment
Open

Comments

@majkiw
Copy link

majkiw commented Apr 7, 2025

Background

Hi, when configuring Stagehand itself, you can override llmClient options, or even the whole llmClient like this:

const stagehand = new Stagehand({
  browserbaseSessionID: browserSession.sessionId,
  modelClientOptions: {
    apiKey: "",
    baseURL: "",
  },
  llmClient: CustomOpenAIClient()

💯

Problem

However when running stagehand.agent you can only set the apiKey via:

const agent = stagehand.agent({
  options: {
    apiKey: process.env.OPENAI_API_KEY,
  },

Because all the other parameters, most importantly baseURL, are ignored in the OpenAICUAClient:

    // Store client options for reference
    this.clientOptions = {
      apiKey: this.apiKey,
    };

    // Initialize the OpenAI client
    this.client = new OpenAI(this.clientOptions);

Ask

Could stagehand.agent support the whole export type ClientOptions = OpenAIClientOptions | AnthropicClientOptions; options, just like Stagehand constructor does?
At the very least, the baseURL (that nota bene seems to be passed in the AnthropicCUAClient.ts)

For bonus points: allow for a full llmClient override, just like in the Stagehand constructor to support custom instrumentation.

@majkiw
Copy link
Author

majkiw commented Apr 7, 2025

I went ahead and created the minimal PR that respects baseURL in the OpenAICUAClient.ts (matching the AnthropicCUAClient.ts): #644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant