@@ -28,6 +28,14 @@ function isDeepSeekTargetedRun(testFile?: string, testGrep?: string) {
2828 return testGrep ?. toLowerCase ( ) . includes ( "deepseek" ) ?? false
2929}
3030
31+ function isNovitaTargetedRun ( testFile ?: string , testGrep ?: string ) {
32+ if ( testFile ?. toLowerCase ( ) . includes ( "novita.test" ) ) {
33+ return true
34+ }
35+
36+ return testGrep ?. toLowerCase ( ) . includes ( "novita" ) ?? false
37+ }
38+
3139function isBedrockTargetedRun ( testFile ?: string , testGrep ?: string ) {
3240 if ( testFile ?. toLowerCase ( ) . includes ( "bedrock.test" ) ) {
3341 return true
@@ -41,28 +49,35 @@ async function main() {
4149 const testGrep = getCliFlagValue ( "--grep" ) || process . env . TEST_GREP
4250 const testFile = getCliFlagValue ( "--file" ) || process . env . TEST_FILE
4351 const isDeepSeekTest = isDeepSeekTargetedRun ( testFile , testGrep )
52+ const isNovitaTest = isNovitaTargetedRun ( testFile , testGrep )
4453 const isGeminiTest = testFile ?. toLowerCase ( ) . includes ( "gemini.test" ) ?? false
4554 const isBedrockTest = isBedrockTargetedRun ( testFile , testGrep )
4655
4756 if ( isRecord && isDeepSeekTest && ! process . env . DEEPSEEK_API_KEY ) {
4857 throw new Error ( "AIMOCK_RECORD=true requires DEEPSEEK_API_KEY to record DeepSeek fixtures" )
4958 }
5059
60+ if ( isRecord && isNovitaTest && ! process . env . NOVITA_API_KEY ) {
61+ throw new Error ( "AIMOCK_RECORD=true requires NOVITA_API_KEY to record Novita fixtures" )
62+ }
63+
5164 if ( isRecord && isGeminiTest && ! process . env . GEMINI_API_KEY && ! process . env . GOOGLE_API_KEY ) {
5265 throw new Error ( "AIMOCK_RECORD=true requires GEMINI_API_KEY to record Gemini fixtures" )
5366 }
5467
55- if ( isRecord && ! isDeepSeekTest && ! isGeminiTest && ! process . env . OPENROUTER_API_KEY ) {
68+ if ( isRecord && ! isDeepSeekTest && ! isNovitaTest && ! isGeminiTest && ! process . env . OPENROUTER_API_KEY ) {
5669 throw new Error ( "AIMOCK_RECORD=true requires OPENROUTER_API_KEY to record fixtures" )
5770 }
5871
5972 // Record mode always needs aimock running (to capture traffic).
6073 // Replay mode starts aimock when no real API key is present or USE_MOCK is forced.
6174 const hasRealApiKey = isDeepSeekTest
6275 ? ! ! process . env . DEEPSEEK_API_KEY
63- : isBedrockTest
64- ? true // Bedrock test starts its own binary-event-stream mock server when no real token
65- : ! ! ( process . env . OPENROUTER_API_KEY || process . env . ANTHROPIC_API_KEY )
76+ : isNovitaTest
77+ ? ! ! process . env . NOVITA_API_KEY
78+ : isBedrockTest
79+ ? true // Bedrock test starts its own binary-event-stream mock server when no real token
80+ : ! ! ( process . env . OPENROUTER_API_KEY || process . env . ANTHROPIC_API_KEY )
6681 const useMock = isRecord || ! hasRealApiKey || process . env . USE_MOCK === "true"
6782
6883 let mock : InstanceType < typeof LLMock > | undefined
@@ -93,7 +108,11 @@ async function main() {
93108 // Use /api (not /api/v1) — aimock appends the request path (/v1/chat/completions)
94109 // so including /v1 here would produce a doubled /v1/v1 upstream URL.
95110 providers : {
96- openai : isDeepSeekTest ? "https://api.deepseek.com" : "https://openrouter.ai/api" ,
111+ openai : isDeepSeekTest
112+ ? "https://api.deepseek.com"
113+ : isNovitaTest
114+ ? "https://api.novita.ai/openai"
115+ : "https://openrouter.ai/api" ,
97116 // aimock forwards the x-api-key header from the Anthropic SDK to the real API.
98117 anthropic : "https://api.anthropic.com" ,
99118 // aimock forwards the x-goog-api-key header from the Google AI SDK.
0 commit comments