Skip to content

modelApiKey is required when using BROWSERBASE environment #1274

@snakecased

Description

@snakecased

Bug Report: modelApiKey is required when using BROWSERBASE environment

Before submitting an issue, please:

Environment Information

Stagehand:

  • Language/SDK: TypeScript
  • Stagehand version: [not specified]

AI Provider:

  • Provider: Google
  • Model: [not specified]

Issue Description

When using Stagehand with the BROWSERBASE environment setting, the application throws an error stating "modelApiKey is required" even though the necessary API keys are configured in environment variables. The error does not occur when switching to the LOCAL environment.

Error executing computer use agent: StagehandAPIError: modelApiKey is required
    at StagehandAPIClient.<anonymous> (/Users/[USERNAME]/Documents/[PROJECT]/node_modules/@browserbasehq/stagehand/dist/index.js:39869:15)
    at Generator.next (<anonymous>)
    at /Users/[USERNAME]/Documents/[PROJECT]/node_modules/@browserbasehq/stagehand/dist/index.js:80:61
    at new Promise (<anonymous>)
    at __async (/Users/[USERNAME]/Documents/[PROJECT]/node_modules/@browserbasehq/stagehand/dist/index.js:64:10)
    at StagehandAPIClient.init (/Users/[USERNAME]/Documents/[PROJECT]/node_modules/@browserbasehq/stagehand/dist/index.js:39857:12)
    at _V3.<anonymous> (/Users/[USERNAME]/Documents/[PROJECT]/node_modules/@browserbasehq/stagehand/dist/index.js:40802:81)
    at Generator.next (<anonymous>)
    at /Users/[USERNAME]/Documents/[PROJECT]/node_modules/@browserbasehq/stagehand/dist/index.js:80:61
    at new Promise (<anonymous>)

Steps to Reproduce

  1. Set up environment variables for BROWSERBASE_PROJECT_ID, BROWSERBASE_API_KEY, and GOOGLE_API_KEY
  2. Configure Stagehand with env: "BROWSERBASE"
  3. Run the application
  4. Observe the error about missing modelApiKey

Minimal Reproduction Code

// Minimal reproduction code
import { Stagehand } from '@browserbase/stagehand';

const stagehand = new Stagehand({
  env: "BROWSERBASE",
  // Other configuration options
});

// Code that triggers the error
await stagehand.init();

Error Messages / Log trace

Error executing computer use agent: StagehandAPIError: modelApiKey is required
    at StagehandAPIClient.<anonymous> (/Users/[USERNAME]/Documents/[PROJECT]/node_modules/@browserbasehq/stagehand/dist/index.js:39869:15)
    at Generator.next (<anonymous>)
    at /Users/[USERNAME]/Documents/[PROJECT]/node_modules/@browserbasehq/stagehand/dist/index.js:80:61
    at new Promise (<anonymous>)
    at __async (/Users/[USERNAME]/Documents/[PROJECT]/node_modules/@browserbasehq/stagehand/dist/index.js:64:10)
    at StagehandAPIClient.init (/Users/[USERNAME]/Documents/[PROJECT]/node_modules/@browserbasehq/stagehand/dist/index.js:39857:12)
    at _V3.<anonymous> (/Users/[USERNAME]/Documents/[PROJECT]/node_modules/@browserbasehq/stagehand/dist/index.js:40802:81)
    at Generator.next (<anonymous>)
    at /Users/[USERNAME]/Documents/[PROJECT]/node_modules/@browserbasehq/stagehand/dist/index.js:80:61
    at new Promise (<anonymous>)
[2025-11-17 14:40:19.186 +0800] INFO: Using Browserbase credentials
    category: "init"
[2025-11-17 14:40:19.186 +0800] INFO: Starting browserbase session
    category: "init"
Session closed successfully

Screenshots / Videos

N/A

Related Issues

Are there any related issues or PRs?

https://github.com/browserbase/stagehand/issues?q=modelApiKey%20is%20required

Additional Context

The error doesn't occur when switching to "LOCAL" instead of "BROWSERBASE" environment.

Environment variables configured:

  • BROWSERBASE_PROJECT_ID
  • BROWSERBASE_API_KEY
  • GOOGLE_API_KEY

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