@@ -11,27 +11,31 @@ import { LLMClient } from "./llm-client.js";
1111// Test the provider configuration logic directly
1212// (extracted from LLMClient to make it testable)
1313
14- function getDefaultApiKey ( provider : "openai" | "anthropic" | "openrouter" | "custom" ) : string | undefined {
14+ function getDefaultApiKey ( provider : "openai" | "anthropic" | "openrouter" | "cerebras" | " custom") : string | undefined {
1515 switch ( provider ) {
1616 case "openai" :
1717 return process . env [ "OPENAI_API_KEY" ] ;
1818 case "anthropic" :
1919 return process . env [ "ANTHROPIC_API_KEY" ] ;
2020 case "openrouter" :
2121 return process . env [ "OPENROUTER_API_KEY" ] ;
22+ case "cerebras" :
23+ return process . env [ "CEREBRAS_API_KEY" ] ;
2224 case "custom" :
2325 return undefined ;
2426 }
2527}
2628
27- function getDefaultBaseUrl ( provider : "openai" | "anthropic" | "openrouter" | "custom" ) : string | undefined {
29+ function getDefaultBaseUrl ( provider : "openai" | "anthropic" | "openrouter" | "cerebras" | " custom") : string | undefined {
2830 switch ( provider ) {
2931 case "openai" :
3032 return undefined ; // Uses default
3133 case "anthropic" :
3234 return "https://api.anthropic.com/v1" ;
3335 case "openrouter" :
3436 return "https://openrouter.ai/api/v1" ;
37+ case "cerebras" :
38+ return "https://api.cerebras.ai/v1" ;
3539 case "custom" :
3640 return undefined ;
3741 }
@@ -50,6 +54,10 @@ describe("LLMClient provider configuration", () => {
5054 it ( "returns OpenRouter base URL" , ( ) => {
5155 expect ( getDefaultBaseUrl ( "openrouter" ) ) . toBe ( "https://openrouter.ai/api/v1" ) ;
5256 } ) ;
57+
58+ it ( "returns Cerebras base URL" , ( ) => {
59+ expect ( getDefaultBaseUrl ( "cerebras" ) ) . toBe ( "https://api.cerebras.ai/v1" ) ;
60+ } ) ;
5361 } ) ;
5462
5563 describe ( "getDefaultApiKey" , ( ) => {
@@ -80,6 +88,15 @@ describe("LLMClient provider configuration", () => {
8088 process . env [ "OPENROUTER_API_KEY" ] = original ;
8189 } ) ;
8290
91+ it ( "reads CEREBRAS_API_KEY for cerebras provider" , ( ) => {
92+ const original = process . env [ "CEREBRAS_API_KEY" ] ;
93+ process . env [ "CEREBRAS_API_KEY" ] = "test-cerebras-key" ;
94+
95+ expect ( getDefaultApiKey ( "cerebras" ) ) . toBe ( "test-cerebras-key" ) ;
96+
97+ process . env [ "CEREBRAS_API_KEY" ] = original ;
98+ } ) ;
99+
83100 it ( "returns undefined for custom provider (must be provided explicitly)" , ( ) => {
84101 expect ( getDefaultApiKey ( "custom" ) ) . toBeUndefined ( ) ;
85102 } ) ;
0 commit comments