[Claimed #1923] feat: Make model api key optional on API

Merged
GI
8mo ago
+168-10

Mirrored from external contributor PR #1923 after approval by @miguelg719.

Original author: @chromiebot
Original PR: https://github.com/browserbase/stagehand/pull/1923
Approved source head SHA: 49c1be2be843d441e3234f6ab591e2ce5bd84087

@chromiebot, please continue any follow-up discussion on this mirrored PR. When the external PR gets new commits, this same internal PR will be marked stale until the latest external commit is approved and refreshed here.

Original description

why

Introducing Model Gateway on Browserbase

what changed

modelApiKey is now optional on API

test plan


Summary by cubic

Make the model API key optional in StagehandAPIClient.init() so sessions can start without a key, supporting Model Gateway. When provided, behavior is unchanged and the x-model-api-key header is sent.

  • Bug Fixes
    • Remove throw in init(); make modelApiKey optional across types.
    • Conditionally send x-model-api-key; omit model apiKey in prepareModelConfig when undefined.
    • Add unit tests for header behavior and a server integration test for starting without the header; add a patch changeset for @browserbasehq/stagehand.