Skip to content

Conversation

@RahulThennarasu
Copy link

why

Users with GOOGLE_API_KEY set in their environment were getting modelApiKey is required error when using BROWSERBASE mode with Google models. The code only checked for GEMINI_API_KEY and GOOGLE_GENERATIVE_AI_API_KEY, but GOOGLE_API_KEY is a commonly used environment variable name for Google's API services.

what changed

  • Added GOOGLE_API_KEY to the providerEnvVarMap for the google provider in lib/utils.ts
  • The provider now checks for API keys in priority order: GEMINI_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY, GOOGLE_API_KEY
  • Added test suite in tests/google-api-key-env.test.ts with 4 test cases covering all three environment variable options and priority ordering

test plan

  • All existing unit tests pass (10/10)
  • All existing integration tests pass (173/173)
  • New test suite validates all three environment variables work correctly
  • Manually tested with BROWSERBASE environment using a Google model (google/gemini-2.0-flash-exp)

Fixes #1274

@changeset-bot
Copy link

changeset-bot bot commented Nov 18, 2025

⚠️ No Changeset found

Latest commit: 9d1569b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 18, 2025

Greptile Summary

  • Added GOOGLE_API_KEY as third fallback option for google provider environment variables, fixing modelApiKey is required error for users with this commonly used environment variable name in BROWSERBASE mode
  • Test suite validates all three environment variables (GEMINI_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY, GOOGLE_API_KEY) and priority ordering

Confidence Score: 4/5

  • safe to merge after fixing two minor syntax issues in test file
  • simple, well-tested change adding a commonly used environment variable name to existing array, with comprehensive test coverage; only concerns are typo and missing semicolon in tests
  • packages/core/tests/google-api-key-env.test.ts needs minor syntax fixes before merge

Important Files Changed

Filename Overview
packages/core/lib/utils.ts added GOOGLE_API_KEY to google provider environment variable array, enabling users to use this common environment variable name

Sequence Diagram

sequenceDiagram
    participant User
    participant V3
    participant loadApiKeyFromEnv
    participant providerEnvVarMap
    participant Environment

    User->>V3: init() with BROWSERBASE mode
    V3->>loadApiKeyFromEnv: load API key for "google"
    loadApiKeyFromEnv->>providerEnvVarMap: get env var names for "google"
    providerEnvVarMap-->>loadApiKeyFromEnv: ["GEMINI_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY", "GOOGLE_API_KEY"]
    loadApiKeyFromEnv->>Environment: check GEMINI_API_KEY
    alt GEMINI_API_KEY exists
        Environment-->>loadApiKeyFromEnv: return key
    else check next
        loadApiKeyFromEnv->>Environment: check GOOGLE_GENERATIVE_AI_API_KEY
        alt GOOGLE_GENERATIVE_AI_API_KEY exists
            Environment-->>loadApiKeyFromEnv: return key
        else check next
            loadApiKeyFromEnv->>Environment: check GOOGLE_API_KEY
            Environment-->>loadApiKeyFromEnv: return key
        end
    end
    loadApiKeyFromEnv-->>V3: API key
    V3->>V3: set modelClientOptions.apiKey
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile
React with 👍 or 👎 to share your feedback on this new summary format

@RahulThennarasu RahulThennarasu force-pushed the fix/browserbase-modelapikey-issue branch from a58bf45 to 9d1569b Compare November 18, 2025 23:26
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

Successfully merging this pull request may close these issues.

modelApiKey is required when using BROWSERBASE environment

1 participant