{"record":{"id":"11d41dbe46fc8914","repo":"abhigyanpatwari/GitNexus","slug":"deepseek-api-key-is-required-but-was-not-provided","errorCode":null,"errorMessage":"DeepSeek API key is required but was not provided","messagePattern":"DeepSeek API key is required but was not provided","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus-web/src/core/llm/agent.ts","lineNumber":331,"sourceCode":"\n      return new ChatOpenAI({\n        apiKey: glmConfig.apiKey,\n        modelName: glmConfig.model,\n        temperature: glmConfig.temperature ?? 0.1,\n        maxTokens: glmConfig.maxTokens,\n        configuration: {\n          apiKey: glmConfig.apiKey,\n          baseURL: glmConfig.baseUrl ?? 'https://api.z.ai/api/coding/paas/v4',\n        },\n        streaming: true,\n      });\n    }\n\n    case 'deepseek': {\n      const deepseekConfig = config as DeepSeekConfig;\n\n      if (!deepseekConfig.apiKey || deepseekConfig.apiKey.trim() === '') {\n        throw new Error('DeepSeek API key is required but was not provided');\n      }\n\n      return new DeepSeekChatOpenAI({\n        apiKey: deepseekConfig.apiKey,\n        modelName: deepseekConfig.model,\n        temperature: deepseekConfig.temperature ?? 0.1,\n        maxTokens: deepseekConfig.maxTokens,\n        configuration: {\n          apiKey: deepseekConfig.apiKey,\n          baseURL: 'https://api.deepseek.com',\n        },\n        streaming: true,\n      });\n    }\n\n    default:\n      throw new Error(`Unsupported provider: ${(config as any).provider}`);\n  }","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus-web/src/core/llm/agent.ts#L313-L349","documentation":"Thrown by createChatModel() in the 'deepseek' provider branch when deepseekConfig.apiKey is falsy or whitespace-only. DeepSeek is accessed through a DeepSeekChatOpenAI wrapper pointed at https://api.deepseek.com (hardcoded baseURL); the key is required at construction. Fails fast rather than letting the DeepSeek API return a 401 on first request.","triggerScenarios":"Calling createChatModel({ provider: 'deepseek', apiKey: undefined | '' | '   ', model: 'deepseek-chat', ... }). Note the baseURL is hardcoded to api.deepseek.com and cannot be overridden via config.","commonSituations":"The DeepSeek key wasn't set in provider settings; the env var is unset; switching to deepseek without a platform.deepseek.com account.","solutions":["Obtain a key from platform.deepseek.com and enter it in provider settings","Ensure the key is non-empty and non-whitespace","Recreate the agent after setting the key (construction-time check)","If you need a proxy/baseURL override, note DeepSeek's baseURL is hardcoded — use the openrouter or openai provider with a custom baseUrl instead"],"exampleFix":"// before\ncreateChatModel({ provider: 'deepseek', apiKey: '', model: 'deepseek-chat' }); // throws\n\n// after\ncreateChatModel({ provider: 'deepseek', apiKey: userKey, model: 'deepseek-chat' });","handlingStrategy":"validation","validationCode":"function hasDeepSeekKey(cfg: { apiKey?: string }): boolean {\n  return typeof cfg.apiKey === 'string' && cfg.apiKey.trim().length > 0;\n}\nif (cfg.provider === 'deepseek' && !hasDeepSeekKey(cfg)) {\n  throw new Error('Configure a DeepSeek API key (from platform.deepseek.com)');\n}","typeGuard":"function isDeepSeekConfigReady(cfg: unknown): cfg is { provider: 'deepseek'; apiKey: string } {\n  return typeof cfg === 'object' && cfg !== null\n    && (cfg as any).provider === 'deepseek'\n    && typeof (cfg as any).apiKey === 'string'\n    && (cfg as any).apiKey.trim().length > 0;\n}","tryCatchPattern":"try {\n  createChatModel({ provider: 'deepseek', apiKey, model });\n} catch (e) {\n  if (e instanceof Error && /DeepSeek API key is required/.test(e.message)) {\n    promptUserForKey('deepseek');\n    return;\n  }\n  throw e;\n}","preventionTips":["Obtain a key from platform.deepseek.com","DeepSeek baseURL is hardcoded to api.deepseek.com — if you need a proxy, use the 'openai' or 'openrouter' provider with a custom baseUrl","Re-create the agent after entering the key","Validate non-empty before construction to surface the error at the config layer"],"tags":["llm","deepseek","config","api-key"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}