{"record":{"id":"6ac061fa0c88b382","repo":"nextai-translator/nextai-translator","slug":"invalid-api-key-6ac061","errorCode":null,"errorMessage":"Invalid API Key","messagePattern":"Invalid API Key","errorType":"http","errorClass":"Error","httpStatus":403,"severity":"error","filePath":"src/common/engines/deepseek.ts","lineNumber":32,"sourceCode":"            return []\n        }\n        const url = urlJoin(apiURL, '/v1/models')\n        const response = await fetch(url, {\n            method: 'GET',\n            headers: {\n                'Content-Type': 'application/json',\n                'Authorization': `Bearer ${apiKey}`,\n            },\n        })\n        if (response.status !== 200) {\n            if (response.status === 401) {\n                throw new Error('Invalid API key')\n            }\n            if (response.status === 404) {\n                throw new Error('Invalid API URL')\n            }\n            if (response.status === 403) {\n                throw new Error('Invalid API Key')\n            }\n            throw new Error(`Failed to list models: ${response.statusText}`)\n        }\n        const json = await response.json()\n        // eslint-disable-next-line @typescript-eslint/no-explicit-any\n        return json.data.map((model: any) => {\n            return {\n                id: model.id,\n                name: model.id,\n            }\n        })\n    }\n\n    async getAPIModel(): Promise<string> {\n        const settings = await getSettings()\n        return settings.deepSeekAPIModel\n    }\n    async getAPIKey(): Promise<string> {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/nextai-translator/nextai-translator/blob/f57537ee4ad8ec654cb726b9907bab7a1f82601d/src/common/engines/deepseek.ts#L14-L50","documentation":"DeepSeek's listModels() maps HTTP 403 from the GET /models request to 'Invalid API Key' (capital K variant). 403 means the server recognized the request but refuses authorization — the credential is valid-shaped but lacks permission, is banned, or the account/region is restricted. Distinct from 401 ('Invalid API key').","triggerScenarios":"Calling DeepSeek.listModels(apiKey) when the API returns HTTP 403: the key is disabled/banned, the account has no balance or is region-blocked, or a WAF/CDN rule rejects the request origin.","commonSituations":"Account suspended for policy violation; negative balance after free credits ran out; calling from a blocked region/VPN egress IP; provider WAF flagging the extension's User-Agent; using a key from a closed beta that has been revoked.","solutions":["Check your DeepSeek account status and remaining balance on platform.deepseek.com","Generate a brand-new API key (old one may be revoked) and update settings","Disable VPN/proxy or switch egress region that may be blocked","Retry from curl with the same key to see the 403 body for the exact reason"],"exampleFix":"// before\nawait deepseek.listModels(oldRevokedKey)\n// after\nconst key = await promptUserForNewDeepSeekKey() // rotate after 403\nawait deepseek.listModels(key)","handlingStrategy":"try-catch","validationCode":"// No pre-call check can fully prevent a 403; verify account standing first.\nconst balance = await fetch('https://api.deepseek.com/user/balance', { headers: { Authorization: `Bearer ${apiKey}` } })\nif (!balance.ok) throw new Error('Key or account not in good standing (would 403 on /models)')","typeGuard":null,"tryCatchPattern":"try {\n  const models = await deepseek.listModels(apiKey)\n} catch (e) {\n  if (e instanceof Error && e.message === 'Invalid API Key') {\n    // 403: key revoked/banned or region blocked — surface account-level guidance\n    showAccountIssueHelp()\n  } else { throw e }\n}","preventionTips":["Keep the DeepSeek account in good standing (positive balance, no policy flags)","Rotate to a new key if the old one may have been revoked","Avoid egress IPs (VPN/proxy) that the provider's WAF blocks","Reproduce the 403 with curl to read the deny reason before debugging client-side"],"tags":["authentication","http-403","api-key","deepseek"],"backgroundTag":"invalid-api-key","analyzedSha":"f57537ee4ad8ec654cb726b9907bab7a1f82601d","analyzedAt":"2026-08-31T11:24:08.384Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}