Skip to content

Commit 19a67fd

Browse files
feat(api): manual updates
1 parent 80413be commit 19a67fd

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

.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: fc6606301b5142487a69d296f154b265
4+
config_hash: 9d54b9fd851ec7ac25b85f579be64425

src/stagehand/_client.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Stagehand(SyncAPIClient):
5050
# client options
5151
browserbase_api_key: str
5252
browserbase_project_id: str
53-
model_api_key: str | None
53+
model_api_key: str
5454

5555
def __init__(
5656
self,
@@ -102,6 +102,10 @@ def __init__(
102102

103103
if model_api_key is None:
104104
model_api_key = os.environ.get("MODEL_API_KEY")
105+
if model_api_key is None:
106+
raise StagehandError(
107+
"The model_api_key client option must be set either by passing model_api_key to the client or by setting the MODEL_API_KEY environment variable"
108+
)
105109
self.model_api_key = model_api_key
106110

107111
if base_url is None:
@@ -147,8 +151,6 @@ def _bb_project_id_auth(self) -> dict[str, str]:
147151
@property
148152
def _llm_model_api_key_auth(self) -> dict[str, str]:
149153
model_api_key = self.model_api_key
150-
if model_api_key is None:
151-
return {}
152154
return {"x-model-api-key": model_api_key}
153155

154156
@property
@@ -257,7 +259,7 @@ class AsyncStagehand(AsyncAPIClient):
257259
# client options
258260
browserbase_api_key: str
259261
browserbase_project_id: str
260-
model_api_key: str | None
262+
model_api_key: str
261263

262264
def __init__(
263265
self,
@@ -309,6 +311,10 @@ def __init__(
309311

310312
if model_api_key is None:
311313
model_api_key = os.environ.get("MODEL_API_KEY")
314+
if model_api_key is None:
315+
raise StagehandError(
316+
"The model_api_key client option must be set either by passing model_api_key to the client or by setting the MODEL_API_KEY environment variable"
317+
)
312318
self.model_api_key = model_api_key
313319

314320
if base_url is None:
@@ -354,8 +360,6 @@ def _bb_project_id_auth(self) -> dict[str, str]:
354360
@property
355361
def _llm_model_api_key_auth(self) -> dict[str, str]:
356362
model_api_key = self.model_api_key
357-
if model_api_key is None:
358-
return {}
359363
return {"x-model-api-key": model_api_key}
360364

361365
@property

0 commit comments

Comments
 (0)