Skip to content

Commit daa8c1c

Browse files
feat(api): manual updates
1 parent 5d55cd0 commit daa8c1c

12 files changed

Lines changed: 168 additions & 107 deletions

File tree

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 7
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-3607b588cab78536eb7de9f6acffe8ddda1d34aebe5910c2147421aa6c16bf22.yml
33
openapi_spec_hash: fb507e8d38b4978a5717fbb144197868
4-
config_hash: 2f1ec44e7e07906e07bdc6e075763da9
4+
config_hash: fc6606301b5142487a69d296f154b265

README.md

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
5151
import com.browserbase.api.models.sessions.SessionActParams;
5252
import com.browserbase.api.models.sessions.SessionActResponse;
5353

54-
// Configures using the `stagehand.apiKey` and `stagehand.baseUrl` system properties
55-
// Or configures using the `STAGEHAND_API_KEY` and `STAGEHAND_BASE_URL` environment variables
54+
// Configures using the `stagehand.browserbaseApiKey`, `stagehand.browserbaseProjectId`, `stagehand.modelApiKey` and `stagehand.baseUrl` system properties
55+
// Or configures using the `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID`, `MODEL_API_KEY` and `STAGEHAND_BASE_URL` environment variables
5656
StagehandClient client = StagehandOkHttpClient.fromEnv();
5757

5858
SessionActParams params = SessionActParams.builder()
@@ -70,8 +70,8 @@ Configure the client using system properties or environment variables:
7070
import com.browserbase.api.client.StagehandClient;
7171
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
7272

73-
// Configures using the `stagehand.apiKey` and `stagehand.baseUrl` system properties
74-
// Or configures using the `STAGEHAND_API_KEY` and `STAGEHAND_BASE_URL` environment variables
73+
// Configures using the `stagehand.browserbaseApiKey`, `stagehand.browserbaseProjectId`, `stagehand.modelApiKey` and `stagehand.baseUrl` system properties
74+
// Or configures using the `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID`, `MODEL_API_KEY` and `STAGEHAND_BASE_URL` environment variables
7575
StagehandClient client = StagehandOkHttpClient.fromEnv();
7676
```
7777

@@ -82,7 +82,9 @@ import com.browserbase.api.client.StagehandClient;
8282
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
8383

8484
StagehandClient client = StagehandOkHttpClient.builder()
85-
.apiKey("My API Key")
85+
.browserbaseApiKey("My Browserbase API Key")
86+
.browserbaseProjectId("My Browserbase Project ID")
87+
.modelApiKey("My Model API Key")
8688
.build();
8789
```
8890

@@ -93,19 +95,21 @@ import com.browserbase.api.client.StagehandClient;
9395
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
9496

9597
StagehandClient client = StagehandOkHttpClient.builder()
96-
// Configures using the `stagehand.apiKey` and `stagehand.baseUrl` system properties
97-
// Or configures using the `STAGEHAND_API_KEY` and `STAGEHAND_BASE_URL` environment variables
98+
// Configures using the `stagehand.browserbaseApiKey`, `stagehand.browserbaseProjectId`, `stagehand.modelApiKey` and `stagehand.baseUrl` system properties
99+
// Or configures using the `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID`, `MODEL_API_KEY` and `STAGEHAND_BASE_URL` environment variables
98100
.fromEnv()
99-
.apiKey("My API Key")
101+
.browserbaseApiKey("My Browserbase API Key")
100102
.build();
101103
```
102104

103105
See this table for the available options:
104106

105-
| Setter | System property | Environment variable | Required | Default value |
106-
| --------- | ------------------- | -------------------- | -------- | -------------------------------------------- |
107-
| `apiKey` | `stagehand.apiKey` | `STAGEHAND_API_KEY` | true | - |
108-
| `baseUrl` | `stagehand.baseUrl` | `STAGEHAND_BASE_URL` | true | `"https://api.stagehand.browserbase.com/v1"` |
107+
| Setter | System property | Environment variable | Required | Default value |
108+
| ---------------------- | -------------------------------- | ------------------------ | -------- | -------------------------------------------- |
109+
| `browserbaseApiKey` | `stagehand.browserbaseApiKey` | `BROWSERBASE_API_KEY` | true | - |
110+
| `browserbaseProjectId` | `stagehand.browserbaseProjectId` | `BROWSERBASE_PROJECT_ID` | true | - |
111+
| `modelApiKey` | `stagehand.modelApiKey` | `MODEL_API_KEY` | false | - |
112+
| `baseUrl` | `stagehand.baseUrl` | `STAGEHAND_BASE_URL` | true | `"https://api.stagehand.browserbase.com/v1"` |
109113

110114
System properties take precedence over environment variables.
111115

@@ -153,8 +157,8 @@ import com.browserbase.api.models.sessions.SessionActParams;
153157
import com.browserbase.api.models.sessions.SessionActResponse;
154158
import java.util.concurrent.CompletableFuture;
155159

156-
// Configures using the `stagehand.apiKey` and `stagehand.baseUrl` system properties
157-
// Or configures using the `STAGEHAND_API_KEY` and `STAGEHAND_BASE_URL` environment variables
160+
// Configures using the `stagehand.browserbaseApiKey`, `stagehand.browserbaseProjectId`, `stagehand.modelApiKey` and `stagehand.baseUrl` system properties
161+
// Or configures using the `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID`, `MODEL_API_KEY` and `STAGEHAND_BASE_URL` environment variables
158162
StagehandClient client = StagehandOkHttpClient.fromEnv();
159163

160164
SessionActParams params = SessionActParams.builder()
@@ -173,8 +177,8 @@ import com.browserbase.api.models.sessions.SessionActParams;
173177
import com.browserbase.api.models.sessions.SessionActResponse;
174178
import java.util.concurrent.CompletableFuture;
175179

176-
// Configures using the `stagehand.apiKey` and `stagehand.baseUrl` system properties
177-
// Or configures using the `STAGEHAND_API_KEY` and `STAGEHAND_BASE_URL` environment variables
180+
// Configures using the `stagehand.browserbaseApiKey`, `stagehand.browserbaseProjectId`, `stagehand.modelApiKey` and `stagehand.baseUrl` system properties
181+
// Or configures using the `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID`, `MODEL_API_KEY` and `STAGEHAND_BASE_URL` environment variables
178182
StagehandClientAsync client = StagehandOkHttpClientAsync.fromEnv();
179183

180184
SessionActParams params = SessionActParams.builder()
@@ -370,21 +374,6 @@ StagehandClient client = StagehandOkHttpClient.builder()
370374
.build();
371375
```
372376

373-
### Environments
374-
375-
The SDK sends requests to the production by default. To send requests to a different environment, configure the client like so:
376-
377-
```java
378-
import com.browserbase.api.client.StagehandClient;
379-
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
380-
381-
StagehandClient client = StagehandOkHttpClient.builder()
382-
.fromEnv()
383-
// Other options include `local`
384-
.dev()
385-
.build();
386-
```
387-
388377
### Custom HTTP client
389378

390379
The SDK consists of three artifacts:

stagehand-java-client-okhttp/src/main/kotlin/com/browserbase/api/client/okhttp/OkHttpClient.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien
9191
}
9292
if (logLevel != null) {
9393
clientBuilder.addNetworkInterceptor(
94-
HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") }
94+
HttpLoggingInterceptor().setLevel(logLevel).apply {
95+
redactHeader("x-bb-api-key")
96+
redactHeader("x-bb-project-id")
97+
redactHeader("x-model-api-key")
98+
}
9599
)
96100
}
97101

stagehand-java-client-okhttp/src/main/kotlin/com/browserbase/api/client/okhttp/StagehandOkHttpClient.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,12 @@ class StagehandOkHttpClient private constructor() {
145145
* The base URL to use for every request.
146146
*
147147
* Defaults to the production environment: `https://api.stagehand.browserbase.com/v1`.
148-
*
149-
* The following other environments, with dedicated builder methods, are available:
150-
* - dev: `https://api.stagehand.dev.browserbase.com/v1`
151-
* - local: `http://localhost:5000/v1`
152148
*/
153149
fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) }
154150

155151
/** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */
156152
fun baseUrl(baseUrl: Optional<String>) = baseUrl(baseUrl.getOrNull())
157153

158-
/** Sets [baseUrl] to `https://api.stagehand.dev.browserbase.com/v1`. */
159-
fun dev() = apply { clientOptions.dev() }
160-
161-
/** Sets [baseUrl] to `http://localhost:5000/v1`. */
162-
fun local() = apply { clientOptions.local() }
163-
164154
/**
165155
* Whether to call `validate` on every response before returning it.
166156
*
@@ -205,7 +195,18 @@ class StagehandOkHttpClient private constructor() {
205195
*/
206196
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }
207197

208-
fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
198+
fun browserbaseApiKey(browserbaseApiKey: String) = apply {
199+
clientOptions.browserbaseApiKey(browserbaseApiKey)
200+
}
201+
202+
fun browserbaseProjectId(browserbaseProjectId: String) = apply {
203+
clientOptions.browserbaseProjectId(browserbaseProjectId)
204+
}
205+
206+
fun modelApiKey(modelApiKey: String?) = apply { clientOptions.modelApiKey(modelApiKey) }
207+
208+
/** Alias for calling [Builder.modelApiKey] with `modelApiKey.orElse(null)`. */
209+
fun modelApiKey(modelApiKey: Optional<String>) = modelApiKey(modelApiKey.getOrNull())
209210

210211
fun headers(headers: Headers) = apply { clientOptions.headers(headers) }
211212

stagehand-java-client-okhttp/src/main/kotlin/com/browserbase/api/client/okhttp/StagehandOkHttpClientAsync.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,12 @@ class StagehandOkHttpClientAsync private constructor() {
145145
* The base URL to use for every request.
146146
*
147147
* Defaults to the production environment: `https://api.stagehand.browserbase.com/v1`.
148-
*
149-
* The following other environments, with dedicated builder methods, are available:
150-
* - dev: `https://api.stagehand.dev.browserbase.com/v1`
151-
* - local: `http://localhost:5000/v1`
152148
*/
153149
fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) }
154150

155151
/** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */
156152
fun baseUrl(baseUrl: Optional<String>) = baseUrl(baseUrl.getOrNull())
157153

158-
/** Sets [baseUrl] to `https://api.stagehand.dev.browserbase.com/v1`. */
159-
fun dev() = apply { clientOptions.dev() }
160-
161-
/** Sets [baseUrl] to `http://localhost:5000/v1`. */
162-
fun local() = apply { clientOptions.local() }
163-
164154
/**
165155
* Whether to call `validate` on every response before returning it.
166156
*
@@ -205,7 +195,18 @@ class StagehandOkHttpClientAsync private constructor() {
205195
*/
206196
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }
207197

208-
fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
198+
fun browserbaseApiKey(browserbaseApiKey: String) = apply {
199+
clientOptions.browserbaseApiKey(browserbaseApiKey)
200+
}
201+
202+
fun browserbaseProjectId(browserbaseProjectId: String) = apply {
203+
clientOptions.browserbaseProjectId(browserbaseProjectId)
204+
}
205+
206+
fun modelApiKey(modelApiKey: String?) = apply { clientOptions.modelApiKey(modelApiKey) }
207+
208+
/** Alias for calling [Builder.modelApiKey] with `modelApiKey.orElse(null)`. */
209+
fun modelApiKey(modelApiKey: Optional<String>) = modelApiKey(modelApiKey.getOrNull())
209210

210211
fun headers(headers: Headers) = apply { clientOptions.headers(headers) }
211212

0 commit comments

Comments
 (0)