@@ -31,6 +31,15 @@ vi.mock("../providers", () => ({
3131 HumanRelayHandler : vi . fn ( ) . mockImplementation ( ( ) => ( { provider : "human-relay" } ) ) ,
3232 FakeAIHandler : vi . fn ( ) . mockImplementation ( ( options ) => ( { provider : "fake-ai" , options } ) ) ,
3333 HuggingFaceHandler : vi . fn ( ) . mockImplementation ( ( options ) => ( { provider : "huggingface" , options } ) ) ,
34+ CerebrasHandler : vi . fn ( ) . mockImplementation ( ( options ) => ( { provider : "cerebras" , options } ) ) ,
35+ SambaNovaHandler : vi . fn ( ) . mockImplementation ( ( options ) => ( { provider : "sambanova" , options } ) ) ,
36+ ZAiHandler : vi . fn ( ) . mockImplementation ( ( options ) => ( { provider : "zai" , options } ) ) ,
37+ FireworksHandler : vi . fn ( ) . mockImplementation ( ( options ) => ( { provider : "fireworks" , options } ) ) ,
38+ FeatherlessHandler : vi . fn ( ) . mockImplementation ( ( options ) => ( { provider : "featherless" , options } ) ) ,
39+ IOIntelligenceHandler : vi . fn ( ) . mockImplementation ( ( options ) => ( { provider : "io-intelligence" , options } ) ) ,
40+ VercelAiGatewayHandler : vi . fn ( ) . mockImplementation ( ( options ) => ( { provider : "vercel-ai-gateway" , options } ) ) ,
41+ DoubaoHandler : vi . fn ( ) . mockImplementation ( ( options ) => ( { provider : "doubao" , options } ) ) ,
42+ DeepInfraHandler : vi . fn ( ) . mockImplementation ( ( options ) => ( { provider : "deepinfra" , options } ) ) ,
3443} ) )
3544
3645describe ( "API Environment Variable Integration" , ( ) => {
@@ -331,6 +340,171 @@ describe("API Environment Variable Integration", () => {
331340 } )
332341 } )
333342
343+ describe ( "cerebras provider" , ( ) => {
344+ it ( "should use environment variable when cerebrasConfigUseEnvVars is true" , ( ) => {
345+ process . env . CEREBRAS_API_KEY = "env-cerebras-key"
346+
347+ const config : ProviderSettings = {
348+ apiProvider : "cerebras" ,
349+ cerebrasApiKey : "config-key" ,
350+ cerebrasConfigUseEnvVars : true ,
351+ }
352+
353+ const handler = buildApiHandler ( config ) as any
354+ expect ( handler . options . cerebrasApiKey ) . toBe ( "env-cerebras-key" )
355+ } )
356+ } )
357+
358+ describe ( "sambanova provider" , ( ) => {
359+ it ( "should use environment variable when sambaNovaConfigUseEnvVars is true" , ( ) => {
360+ process . env . SAMBANOVA_API_KEY = "env-sambanova-key"
361+
362+ const config : ProviderSettings = {
363+ apiProvider : "sambanova" ,
364+ sambaNovaApiKey : "config-key" ,
365+ sambaNovaConfigUseEnvVars : true ,
366+ }
367+
368+ const handler = buildApiHandler ( config ) as any
369+ expect ( handler . options . sambaNovaApiKey ) . toBe ( "env-sambanova-key" )
370+ } )
371+ } )
372+
373+ describe ( "zai provider" , ( ) => {
374+ it ( "should use environment variable when zaiConfigUseEnvVars is true" , ( ) => {
375+ process . env . ZAI_API_KEY = "env-zai-key"
376+
377+ const config : ProviderSettings = {
378+ apiProvider : "zai" ,
379+ zaiApiKey : "config-key" ,
380+ zaiConfigUseEnvVars : true ,
381+ }
382+
383+ const handler = buildApiHandler ( config ) as any
384+ expect ( handler . options . zaiApiKey ) . toBe ( "env-zai-key" )
385+ } )
386+ } )
387+
388+ describe ( "fireworks provider" , ( ) => {
389+ it ( "should use environment variable when fireworksConfigUseEnvVars is true" , ( ) => {
390+ process . env . FIREWORKS_API_KEY = "env-fireworks-key"
391+
392+ const config : ProviderSettings = {
393+ apiProvider : "fireworks" ,
394+ fireworksApiKey : "config-key" ,
395+ fireworksConfigUseEnvVars : true ,
396+ }
397+
398+ const handler = buildApiHandler ( config ) as any
399+ expect ( handler . options . fireworksApiKey ) . toBe ( "env-fireworks-key" )
400+ } )
401+ } )
402+
403+ describe ( "featherless provider" , ( ) => {
404+ it ( "should use environment variable when featherlessConfigUseEnvVars is true" , ( ) => {
405+ process . env . FEATHERLESS_API_KEY = "env-featherless-key"
406+
407+ const config : ProviderSettings = {
408+ apiProvider : "featherless" ,
409+ featherlessApiKey : "config-key" ,
410+ featherlessConfigUseEnvVars : true ,
411+ }
412+
413+ const handler = buildApiHandler ( config ) as any
414+ expect ( handler . options . featherlessApiKey ) . toBe ( "env-featherless-key" )
415+ } )
416+ } )
417+
418+ describe ( "io-intelligence provider" , ( ) => {
419+ it ( "should use environment variable when ioIntelligenceConfigUseEnvVars is true" , ( ) => {
420+ process . env . IOINTELLIGENCE_API_KEY = "env-iointelligence-key"
421+
422+ const config : ProviderSettings = {
423+ apiProvider : "io-intelligence" ,
424+ ioIntelligenceApiKey : "config-key" ,
425+ ioIntelligenceConfigUseEnvVars : true ,
426+ }
427+
428+ const handler = buildApiHandler ( config ) as any
429+ expect ( handler . options . ioIntelligenceApiKey ) . toBe ( "env-iointelligence-key" )
430+ } )
431+ } )
432+
433+ describe ( "vercel-ai-gateway provider" , ( ) => {
434+ it ( "should use environment variable when vercelConfigUseEnvVars is true" , ( ) => {
435+ process . env . VERCEL_API_KEY = "env-vercel-key"
436+
437+ const config : ProviderSettings = {
438+ apiProvider : "vercel-ai-gateway" ,
439+ vercelAiGatewayApiKey : "config-key" ,
440+ vercelConfigUseEnvVars : true ,
441+ }
442+
443+ const handler = buildApiHandler ( config ) as any
444+ expect ( handler . options . vercelAiGatewayApiKey ) . toBe ( "env-vercel-key" )
445+ } )
446+ } )
447+
448+ describe ( "doubao provider" , ( ) => {
449+ it ( "should use environment variable when doubaoConfigUseEnvVars is true" , ( ) => {
450+ process . env . DOUBAO_API_KEY = "env-doubao-key"
451+
452+ const config : ProviderSettings = {
453+ apiProvider : "doubao" ,
454+ doubaoApiKey : "config-key" ,
455+ doubaoConfigUseEnvVars : true ,
456+ }
457+
458+ const handler = buildApiHandler ( config ) as any
459+ expect ( handler . options . doubaoApiKey ) . toBe ( "env-doubao-key" )
460+ } )
461+ } )
462+
463+ describe ( "moonshot provider" , ( ) => {
464+ it ( "should use environment variable when moonshotConfigUseEnvVars is true" , ( ) => {
465+ process . env . MOONSHOT_API_KEY = "env-moonshot-key"
466+
467+ const config : ProviderSettings = {
468+ apiProvider : "moonshot" ,
469+ moonshotApiKey : "config-key" ,
470+ moonshotConfigUseEnvVars : true ,
471+ }
472+
473+ const handler = buildApiHandler ( config ) as any
474+ expect ( handler . options . moonshotApiKey ) . toBe ( "env-moonshot-key" )
475+ } )
476+ } )
477+
478+ describe ( "huggingface provider" , ( ) => {
479+ it ( "should use environment variable when huggingFaceConfigUseEnvVars is true" , ( ) => {
480+ process . env . HUGGINGFACE_API_KEY = "env-huggingface-key"
481+
482+ const config : ProviderSettings = {
483+ apiProvider : "huggingface" ,
484+ huggingFaceApiKey : "config-key" ,
485+ huggingFaceConfigUseEnvVars : true ,
486+ }
487+
488+ const handler = buildApiHandler ( config ) as any
489+ expect ( handler . options . huggingFaceApiKey ) . toBe ( "env-huggingface-key" )
490+ } )
491+ } )
492+
493+ describe ( "deepinfra provider" , ( ) => {
494+ it ( "should use environment variable when deepInfraConfigUseEnvVars is true" , ( ) => {
495+ process . env . DEEPINFRA_API_KEY = "env-deepinfra-key"
496+
497+ const config : ProviderSettings = {
498+ apiProvider : "deepinfra" ,
499+ deepInfraApiKey : "config-key" ,
500+ deepInfraConfigUseEnvVars : true ,
501+ }
502+
503+ const handler = buildApiHandler ( config ) as any
504+ expect ( handler . options . deepInfraApiKey ) . toBe ( "env-deepinfra-key" )
505+ } )
506+ } )
507+
334508 describe ( "providers without environment variable support" , ( ) => {
335509 it ( "should not modify options for claude-code provider" , ( ) => {
336510 const config : ProviderSettings = {
@@ -382,6 +556,17 @@ describe("API Environment Variable Integration", () => {
382556 "GROQ_API_KEY" ,
383557 "CHUTES_API_KEY" ,
384558 "LITELLM_API_KEY" ,
559+ "CEREBRAS_API_KEY" ,
560+ "SAMBANOVA_API_KEY" ,
561+ "ZAI_API_KEY" ,
562+ "FIREWORKS_API_KEY" ,
563+ "FEATHERLESS_API_KEY" ,
564+ "IOINTELLIGENCE_API_KEY" ,
565+ "VERCEL_API_KEY" ,
566+ "DOUBAO_API_KEY" ,
567+ "MOONSHOT_API_KEY" ,
568+ "HUGGINGFACE_API_KEY" ,
569+ "DEEPINFRA_API_KEY" ,
385570 ]
386571
387572 envVars . forEach ( ( envVar , index ) => {
0 commit comments