Skip to content

Commit 338d466

Browse files
committed
fix: also read ANTHROPIC_BASE_URL from env and normalize it
1 parent 4f160f5 commit 338d466

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/node/services/aiService.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,14 @@ export class AIService extends EventEmitter {
330330
configWithApiKey = { ...providerConfig, apiKey: process.env.ANTHROPIC_AUTH_TOKEN };
331331
}
332332

333-
// Normalize base URL to ensure /v1 suffix (SDK expects it)
334-
const normalizedConfig = configWithApiKey.baseURL
335-
? { ...configWithApiKey, baseURL: normalizeAnthropicBaseURL(configWithApiKey.baseURL) }
333+
// Normalize base URL to ensure /v1 suffix (SDK expects it).
334+
// Check config first, then fall back to ANTHROPIC_BASE_URL env var.
335+
// We must explicitly pass baseURL to ensure /v1 normalization happens
336+
// (SDK reads env var but doesn't normalize it).
337+
const baseURLFromEnv = process.env.ANTHROPIC_BASE_URL?.trim();
338+
const effectiveBaseURL = configWithApiKey.baseURL ?? baseURLFromEnv;
339+
const normalizedConfig = effectiveBaseURL
340+
? { ...configWithApiKey, baseURL: normalizeAnthropicBaseURL(effectiveBaseURL) }
336341
: configWithApiKey;
337342

338343
// Add 1M context beta header if requested

0 commit comments

Comments
 (0)