diff --git a/src/services/api/errors.ts b/src/services/api/errors.ts index 1a7edc52..d77c92a9 100644 --- a/src/services/api/errors.ts +++ b/src/services/api/errors.ts @@ -812,7 +812,8 @@ export function getAssistantMessageFromError( if ( error instanceof Error && - error.message.toLowerCase().includes('x-api-key') + error.message.toLowerCase().includes('x-api-key') && + getAPIProvider() === 'firstParty' ) { // In CCR mode, auth is via JWTs - this is likely a transient network issue if (isCCRMode()) { diff --git a/src/utils/auth.ts b/src/utils/auth.ts index 37d1ca1f..310799fb 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -286,7 +286,7 @@ export function getAnthropicApiKeyWithSource( ) } - if (apiKeyEnv) { + if (apiKeyEnv && !isUsing3PServices()) { return { key: apiKeyEnv, source: 'ANTHROPIC_API_KEY', @@ -294,6 +294,7 @@ export function getAnthropicApiKeyWithSource( } // OAuth token is present but this function returns API keys only + // Also reached when 3P provider is active — ANTHROPIC_API_KEY is ignored return { key: null, source: 'none',