File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -1006,17 +1006,20 @@ export class Stagehand {
1006
1006
throw new StagehandNotInitializedError ( "API client" ) ;
1007
1007
}
1008
1008
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
+ } ;
1019
1014
}
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
+ }
1020
1023
1021
1024
if ( ! options . options . apiKey ) {
1022
1025
throw new StagehandError (
You can’t perform that action at this time.
0 commit comments