Skip to content

Commit 4e816f6

Browse files
monadoidsamfinton
andauthored
Deprecate browserbase project ID (#58)
Co-authored-by: samfinton <samfinton@samLaptopm5.galaxus.box>
1 parent 81f1991 commit 4e816f6

5 files changed

Lines changed: 25 additions & 18 deletions

File tree

AGENTS.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ composer require browserbase/stagehand
3232

3333
# Set environment variables
3434
export BROWSERBASE_API_KEY="your-bb-api-key"
35-
export BROWSERBASE_PROJECT_ID="your-bb-project-uuid"
3635
export MODEL_API_KEY="sk-proj-your-llm-api-key"
3736

3837
# Run the example
@@ -45,7 +44,6 @@ use Stagehand\Client;
4544

4645
$client = new Client(
4746
browserbaseAPIKey: getenv('BROWSERBASE_API_KEY'),
48-
browserbaseProjectID: getenv('BROWSERBASE_PROJECT_ID'),
4947
modelAPIKey: getenv('MODEL_API_KEY'),
5048
);
5149
$startResponse = $client->sessions->start(model: 'openai/gpt-5-nano');

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,12 @@ if (file_exists(__DIR__ . '/../.env')) {
113113
// Initialize the Stagehand client with API keys from environment variables
114114
$client = new Client(
115115
browserbaseAPIKey: getenv('BROWSERBASE_API_KEY') ?: throw new Exception('BROWSERBASE_API_KEY environment variable is required'),
116-
browserbaseProjectID: getenv('BROWSERBASE_PROJECT_ID') ?: throw new Exception('BROWSERBASE_PROJECT_ID environment variable is required'),
117116
modelAPIKey: getenv('MODEL_API_KEY') ?: throw new Exception('MODEL_API_KEY environment variable is required'),
118117
);
119118

120119
// Start a new session
121120
$startResponse = $client->sessions->start(
122121
browserbaseAPIKey: getenv('BROWSERBASE_API_KEY'),
123-
browserbaseProjectID: getenv('BROWSERBASE_PROJECT_ID'),
124122
model: 'openai/gpt-4o',
125123
);
126124
echo "Session started: {$startResponse->data->sessionID}\n";
@@ -217,12 +215,11 @@ echo "Session ended\n";
217215

218216
### Running the Example
219217

220-
Set the required environment variables and run the example script:
218+
Set the environment variables and run the example script:
221219

222220
```bash
223221
# Set your credentials
224222
export BROWSERBASE_API_KEY="your-browserbase-api-key"
225-
export BROWSERBASE_PROJECT_ID="your-browserbase-project-id"
226223
export MODEL_API_KEY="your-openai-api-key"
227224

228225
# Install dependencies and run
@@ -248,9 +245,6 @@ use Stagehand\Client;
248245

249246
$client = new Client(
250247
browserbaseAPIKey: getenv('BROWSERBASE_API_KEY') ?: 'My Browserbase API Key',
251-
browserbaseProjectID: getenv(
252-
'BROWSERBASE_PROJECT_ID'
253-
) ?: 'My Browserbase Project ID',
254248
modelAPIKey: getenv('MODEL_API_KEY') ?: 'My Model API Key',
255249
);
256250

examples/basic.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818
// Initialize the Stagehand client with API keys from environment variables
1919
$client = new Client(
2020
browserbaseAPIKey: getenv('BROWSERBASE_API_KEY') ?: throw new Exception('BROWSERBASE_API_KEY environment variable is required'),
21-
browserbaseProjectID: getenv('BROWSERBASE_PROJECT_ID') ?: throw new Exception('BROWSERBASE_PROJECT_ID environment variable is required'),
2221
modelAPIKey: getenv('MODEL_API_KEY') ?: throw new Exception('MODEL_API_KEY environment variable is required'),
2322
);
2423

2524
// Start a new session
2625
$startResponse = $client->sessions->start(
2726
browserbaseAPIKey: getenv('BROWSERBASE_API_KEY'),
28-
browserbaseProjectID: getenv('BROWSERBASE_PROJECT_ID'),
2927
model: 'openai/gpt-4o',
3028
);
3129
echo "Session started: {$startResponse->data->sessionID}\n";

src/Client.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ class Client extends BaseClient
1818
{
1919
public string $browserbaseAPIKey;
2020

21+
/**
22+
* Deprecated. Browserbase API keys are now project-scoped, so this value is no longer required.
23+
* Accepted for backwards compatibility; it is ignored.
24+
*/
2125
public string $browserbaseProjectID;
2226

2327
public string $modelAPIKey;
@@ -40,9 +44,7 @@ public function __construct(
4044
$this->browserbaseAPIKey = (string) ($browserbaseAPIKey ?? Util::getenv(
4145
'BROWSERBASE_API_KEY'
4246
));
43-
$this->browserbaseProjectID = (string) ($browserbaseProjectID ?? Util::getenv(
44-
'BROWSERBASE_PROJECT_ID'
45-
));
47+
$this->browserbaseProjectID = (string) $browserbaseProjectID;
4648
$this->modelAPIKey = (string) ($modelAPIKey ?? Util::getenv(
4749
'MODEL_API_KEY'
4850
));
@@ -85,7 +87,6 @@ protected function authHeaders(): array
8587
{
8688
return [
8789
...$this->bbAPIKeyAuth(),
88-
...$this->bbProjectIDAuth(),
8990
...$this->llmModelAPIKeyAuth(),
9091
];
9192
}
@@ -101,9 +102,7 @@ protected function bbAPIKeyAuth(): array
101102
/** @return array<string,string> */
102103
protected function bbProjectIDAuth(): array
103104
{
104-
return $this->browserbaseProjectID ? [
105-
'x-bb-project-id' => $this->browserbaseProjectID,
106-
] : [];
105+
return [];
107106
}
108107

109108
/** @return array<string,string> */

tests/ClientTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,24 @@ public function testDefaultHeaders(): void
9292
}
9393
}
9494

95+
public function testProjectIDHeaderIsOmitted(): void
96+
{
97+
$transporter = $this->mockTransport();
98+
99+
$client = new \Stagehand\Client(
100+
baseUrl: 'http://localhost',
101+
browserbaseAPIKey: 'My Browserbase API Key',
102+
browserbaseProjectID: 'My Browserbase Project ID',
103+
modelAPIKey: 'My Model API Key',
104+
requestOptions: ['transporter' => $transporter],
105+
);
106+
107+
$client->sessions->start(modelName: 'openai/gpt-5.4-mini');
108+
109+
$this->assertNotFalse($requested = $transporter->getRequests()[0] ?? false);
110+
$this->assertSame('', $requested->getHeaderLine('x-bb-project-id'));
111+
}
112+
95113
private function mockTransport(): Client
96114
{
97115
$transporter = new Client;

0 commit comments

Comments
 (0)