Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ export class StagehandAPI {
browserbaseSessionCreateParams,
browserbaseSessionID,
}: StartSessionParams): Promise<StartSessionResult> {
if (!modelApiKey) {
// Only require modelApiKey for built-in providers, inferred from modelName
const builtInProviders = ["openai", "anthropic", "google", "aisdk"];
const provider = modelName?.split("/")[0]?.toLowerCase();
if (!modelApiKey && builtInProviders.includes(provider)) {
throw new StagehandAPIError("modelApiKey is required");
}
this.modelApiKey = modelApiKey;
this.modelApiKey = modelApiKey ?? "";

const region = browserbaseSessionCreateParams?.region;
if (region && region !== "us-west-2") {
Expand Down