Skip to content

Commit 1f84e61

Browse files
committed
update
1 parent 42c3c00 commit 1f84e61

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

lib/index.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,17 +1006,20 @@ export class Stagehand {
10061006
throw new StagehandNotInitializedError("API client");
10071007
}
10081008

1009-
if (!options.options) {
1010-
options.options = {};
1011-
}
1012-
1013-
if (options.provider === "anthropic") {
1014-
options.options.apiKey = process.env.ANTHROPIC_API_KEY;
1015-
} else if (options.provider === "openai") {
1016-
options.options.apiKey = process.env.OPENAI_API_KEY;
1017-
} else if (options.provider === "google") {
1018-
options.options.apiKey = process.env.GOOGLE_API_KEY;
1009+
if (!options?.options) {
1010+
options = {
1011+
...options,
1012+
options: {},
1013+
};
10191014
}
1015+
if (options?.provider) {
1016+
if (options.provider === "anthropic") {
1017+
options.options.apiKey = process.env.ANTHROPIC_API_KEY;
1018+
} else if (options.provider === "openai") {
1019+
options.options.apiKey = process.env.OPENAI_API_KEY;
1020+
} else if (options.provider === "google") {
1021+
options.options.apiKey = process.env.GOOGLE_API_KEY;
1022+
}
10201023

10211024
if (!options.options.apiKey) {
10221025
throw new StagehandError(

0 commit comments

Comments
 (0)