{"record":{"id":"d3465f4b7a2a5247","repo":"Mintplex-Labs/anything-llm","slug":"no-gitee-ai-api-key-was-set","errorCode":null,"errorMessage":"No Gitee AI API key was set.","messagePattern":"No Gitee AI API key was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/giteeai/index.js","lineNumber":21,"sourceCode":"const { safeJsonParse, toValidNumber } = require(\"../../http\");\nconst LEGACY_MODEL_MAP = require(\"../modelMap/legacy\");\nconst { NativeEmbedder } = require(\"../../EmbeddingEngines/native\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst {\n  handleDefaultStreamResponseV2,\n} = require(\"../../helpers/chat/responses\");\nconst cacheFolder = path.resolve(\n  process.env.STORAGE_DIR\n    ? path.resolve(process.env.STORAGE_DIR, \"models\", \"giteeai\")\n    : path.resolve(__dirname, `../../../storage/models/giteeai`)\n);\n\nclass GiteeAILLM {\n  constructor(embedder = null, modelPreference = null) {\n    if (!process.env.GITEE_AI_API_KEY)\n      throw new Error(\"No Gitee AI API key was set.\");\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n\n    this.className = \"GiteeAILLM\";\n    this.openai = new OpenAIApi({\n      apiKey: process.env.GITEE_AI_API_KEY,\n      baseURL: \"https://ai.gitee.com/v1\",\n    });\n    this.model = modelPreference || process.env.GITEE_AI_MODEL_PREF || \"\";\n    this.limits = {\n      history: this.promptWindowLimit() * 0.15,\n      system: this.promptWindowLimit() * 0.15,\n      user: this.promptWindowLimit() * 0.7,\n    };\n\n    this.embedder = embedder ?? new NativeEmbedder();\n    this.defaultTemp = 0.7;\n\n    if (!fs.existsSync(cacheFolder))","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/giteeai/index.js#L3-L39","documentation":"The GiteeAILLM constructor throws when GITEE_AI_API_KEY is absent from the environment. Gitee AI (ai.gitee.com) is accessed through its OpenAI-compatible /v1 endpoint with this key, so it is mandatory. The class is constructed per chat request, so the error appears when a workspace selects Gitee AI as its LLM provider.","triggerScenarios":"Selecting Gitee AI as provider with GITEE_AI_API_KEY unset in the server process: not in .env, added after server start, or missing from the container environment.","commonSituations":"Key obtained from gitee.com AI settings but saved under a different var name (GITEE_API_KEY); server process not restarted after .env edit; deploying with a partial env file.","solutions":["Add GITEE_AI_API_KEY=<token> to .env (from Gitee -> AI -> API tokens) and restart the server","Verify the exact name GITEE_AI_API_KEY","In containerized deploys, pass the var explicitly and recreate","Optionally set GITEE_AI_MODEL_PREF to pin a model, though it defaults to ''"],"exampleFix":"# before (.env)\n# missing\n\n# after (.env)\nGITEE_AI_API_KEY=<your-gitee-token>","handlingStrategy":"validation","validationCode":"if (!process.env.GITEE_AI_API_KEY) {\n  return setupError(\"Set GITEE_AI_API_KEY to use Gitee AI.\");\n}\nconst llm = new GiteeAILLM(embedder, modelPref);","typeGuard":null,"tryCatchPattern":"try {\n  const llm = new GiteeAILLM(embedder, modelPref);\n} catch (err) {\n  if (err.message === \"No Gitee AI API key was set.\") {\n    return respond(\"Add GITEE_AI_API_KEY to your environment and restart.\");\n  }\n  throw err;\n}","preventionTips":["Check provider env vars at boot with a consolidated report","Use the exact name GITEE_AI_API_KEY","Restart the server after any .env change — the key is read at construction time"],"tags":["gitee-ai","missing-env-var","api-key","constructor"],"backgroundTag":"missing-env-var","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}