{"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":"critical","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/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/giteeai/index.js#L3-L39","documentation":"Thrown by the GiteeAILLM constructor when process.env.GITEE_AI_API_KEY is unset. Gitee AI (ai.gitee.com/v1) is an OpenAI-compatible serverless inference platform that requires the API key as the bearer token; without it the OpenAI client cannot authenticate.","triggerScenarios":"Constructing `new GiteeAILLM(embedder, modelPreference)` while GITEE_AI_API_KEY is absent. Fires at provider selection when the user picked Gitee AI but supplied no key.","commonSituations":".env missing GITEE_AI_API_KEY; key not yet generated in the Gitee AI console; key revoked; Docker deployment without env passthrough; account region/access restrictions.","solutions":["Generate a token in the Gitee AI console and set GITEE_AI_API_KEY in .env","Restart AnythingLLM so process.env reloads","Verify the token with curl https://ai.gitee.com/v1/models -H 'Authorization: Bearer <key>'","Pass the env var through in containerized deployments"],"exampleFix":"// before\n// .env: GITEE_AI_MODEL_PREF=Qwen2.5-7B-Instruct   // no key\n\n// after\n// .env:\n//   GITEE_AI_API_KEY=<token from console>\n//   GITEE_AI_MODEL_PREF=Qwen2.5-7B-Instruct","handlingStrategy":"validation","validationCode":"if (!process.env.GITEE_AI_API_KEY) {\n  throw new ConfigError('Generate a Gitee AI token and set GITEE_AI_API_KEY.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the key with GET /v1/models at startup","Keep Gitee AI credentials in a secrets manager for production","Surface missing-key in the UI before first chat"],"tags":["giteeai","configuration","authentication","environment-variables","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}