Skip to content

Commit a3b8a47

Browse files
monadoidsamfinton
authored andcommitted
STG-1808: Deprecate browserbase project ID (#75)
* Deprecate browserbase project ID * Fix CI formatting --------- Co-authored-by: samfinton <samfinton@samLaptopm5.galaxus.box>
1 parent 08ab4c6 commit a3b8a47

9 files changed

Lines changed: 15 additions & 30 deletions

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ namespace Stagehand.Examples
9696
static async Task Main(string[] args)
9797
{
9898
Env.Load();
99-
// Uses environment variables: STAGEHAND_API_URL, BROWSERBASE_API_KEY, BROWSERBASE_PROJECT_ID, MODEL_API_KEY
99+
// Uses environment variables: BROWSERBASE_API_KEY and MODEL_API_KEY
100100
StagehandClient client = new();
101101

102102
// Start a new remote Browserbase session (Playwright-backed)
@@ -325,10 +325,8 @@ namespace Stagehand.Examples
325325

326326
Set your environment variables (from `examples/.env.example`):
327327

328-
- `STAGEHAND_API_URL`
329328
- `MODEL_API_KEY`
330329
- `BROWSERBASE_API_KEY`
331-
- `BROWSERBASE_PROJECT_ID`
332330

333331
```bash
334332
cp examples/.env.example examples/.env
@@ -373,7 +371,7 @@ Configure the client using environment variables:
373371
```csharp
374372
using Stagehand;
375373

376-
// Configured using the BROWSERBASE_API_KEY, BROWSERBASE_PROJECT_ID, MODEL_API_KEY and STAGEHAND_API_URL environment variables
374+
// Configured using BROWSERBASE_API_KEY, MODEL_API_KEY, and STAGEHAND_API_URL, with STAGEHAND_BASE_URL as a fallback
377375
StagehandClient client = new();
378376
```
379377

@@ -385,7 +383,6 @@ using Stagehand;
385383
StagehandClient client = new()
386384
{
387385
BrowserbaseApiKey = "My Browserbase API Key",
388-
BrowserbaseProjectID = "My Browserbase Project ID",
389386
ModelApiKey = "My Model API Key",
390387
};
391388
```
@@ -397,9 +394,11 @@ See this table for the available options:
397394
| Property | Environment variable | Required | Default value |
398395
| ---------------------- | ------------------------ | -------- | ----------------------------------------- |
399396
| `BrowserbaseApiKey` | `BROWSERBASE_API_KEY` | true | - |
400-
| `BrowserbaseProjectID` | `BROWSERBASE_PROJECT_ID` | false | - |
397+
| `BrowserbaseProjectID` | - | false | - |
401398
| `ModelApiKey` | `MODEL_API_KEY` | true | - |
402-
| `BaseUrl` | `STAGEHAND_API_URL` | true | `"https://api.stagehand.browserbase.com"` |
399+
| `BaseUrl` | `STAGEHAND_API_URL` | false | `"https://api.stagehand.browserbase.com"` |
400+
401+
`BrowserbaseProjectID` is deprecated, accepted for backwards compatibility, and ignored. `STAGEHAND_BASE_URL` remains supported as a deprecated fallback when `STAGEHAND_API_URL` is unset.
403402

404403
### Modifying configuration
405404

examples/.env.example

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
STAGEHAND_API_URL=https://api.stagehand.browserbase.com
21
MODEL_API_KEY=sk-proj-your-llm-api-key-here
32
BROWSERBASE_API_KEY=bb_live_your_api_key_here
4-
BROWSERBASE_PROJECT_ID=your-bb-project-uuid-here

examples/Env.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ namespace Stagehand.Examples
66
{
77
internal static class Env
88
{
9-
private static readonly string[] RequiredKeys =
10-
[
11-
"STAGEHAND_API_URL",
12-
"MODEL_API_KEY",
13-
"BROWSERBASE_API_KEY",
14-
"BROWSERBASE_PROJECT_ID",
15-
];
9+
private static readonly string[] RequiredKeys = ["MODEL_API_KEY", "BROWSERBASE_API_KEY"];
1610

1711
public static void Load()
1812
{

examples/local_browser_playwright_example.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static async Task RunAsync()
1717
{
1818
Env.Load();
1919
// Uses environment variables: MODEL_API_KEY
20-
// In local mode, BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID can be any value.
20+
// In local mode, BROWSERBASE_API_KEY can be any value.
2121
StagehandClient client = new();
2222

2323
// Start a new local session

examples/local_server_multiregion_browser_example.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ internal static class LocalServerMultiregionBrowserExample
1616
public static async Task RunAsync()
1717
{
1818
Env.Load();
19-
// Uses environment variables: BROWSERBASE_API_KEY, BROWSERBASE_PROJECT_ID, MODEL_API_KEY
20-
// STAGEHAND_API_URL should point to the local Stagehand server.
19+
// Uses environment variables: BROWSERBASE_API_KEY and MODEL_API_KEY
20+
// STAGEHAND_API_URL should point to the local Stagehand server; STAGEHAND_BASE_URL is a fallback.
2121
StagehandClient client = new();
2222

2323
var startResponse = await client.Sessions.Start(

examples/remote_browser_playwright_example.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal static class RemoteBrowserPlaywrightExample
1616
public static async Task RunAsync()
1717
{
1818
Env.Load();
19-
// Uses environment variables: BROWSERBASE_API_KEY, BROWSERBASE_PROJECT_ID, MODEL_API_KEY
19+
// Uses environment variables: BROWSERBASE_API_KEY and MODEL_API_KEY
2020
StagehandClient client = new();
2121

2222
// Start a new remote Browserbase session (Playwright-backed)

src/Stagehand/Core/ClientOptions.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,11 @@ public string BrowserbaseApiKey
110110
/// Deprecated. Browserbase API keys are now project-scoped, so this value is
111111
/// no longer required.
112112
/// </summary>
113-
Lazy<string?> _browserbaseProjectID = new(() =>
114-
Environment.GetEnvironmentVariable("BROWSERBASE_PROJECT_ID")
115-
);
113+
Lazy<string?> _browserbaseProjectID = new(() => null);
116114

117115
/// <summary>
118116
/// Deprecated. Browserbase API keys are now project-scoped, so this value is
119-
/// no longer required.
117+
/// no longer required. Accepted for backwards compatibility; it is not sent to the API.
120118
/// </summary>
121119
public string? BrowserbaseProjectID
122120
{

src/Stagehand/Core/ParamsBase.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ internal static void AddDefaultHeaders(HttpRequestMessage request, ClientOptions
215215
{
216216
request.Headers.Add("x-bb-api-key", options.BrowserbaseApiKey);
217217
}
218-
if (options.BrowserbaseProjectID != null)
219-
{
220-
request.Headers.Add("x-bb-project-id", options.BrowserbaseProjectID);
221-
}
222218
if (options.ModelApiKey != null)
223219
{
224220
request.Headers.Add("x-model-api-key", options.ModelApiKey);

src/Stagehand/IStagehandClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public interface IStagehandClient : IDisposable
4343

4444
/// <summary>
4545
/// Deprecated. Browserbase API keys are now project-scoped, so this value is
46-
/// no longer required.
46+
/// no longer required. Accepted for backwards compatibility; it is not sent to the API.
4747
/// </summary>
4848
string? BrowserbaseProjectID { get; init; }
4949

@@ -95,7 +95,7 @@ public interface IStagehandClientWithRawResponse : IDisposable
9595

9696
/// <summary>
9797
/// Deprecated. Browserbase API keys are now project-scoped, so this value is
98-
/// no longer required.
98+
/// no longer required. Accepted for backwards compatibility; it is not sent to the API.
9999
/// </summary>
100100
string? BrowserbaseProjectID { get; init; }
101101

0 commit comments

Comments
 (0)