Skip to content

Stagehand Agent mode should allow providing baseURL for OpenAICUAClient #643

Open
@majkiw

Description

@majkiw

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions