Mintplex-Labs/anything-llm · error · Error
No Gitee AI API key was set.
Error message
No Gitee AI API key was set.
What it means
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.
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 ''
Example fix
# before (.env) # missing # after (.env) GITEE_AI_API_KEY=<your-gitee-token>
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.GITEE_AI_API_KEY) {
return setupError("Set GITEE_AI_API_KEY to use Gitee AI.");
}
const llm = new GiteeAILLM(embedder, modelPref); Try / catch
try {
const llm = new GiteeAILLM(embedder, modelPref);
} catch (err) {
if (err.message === "No Gitee AI API key was set.") {
return respond("Add GITEE_AI_API_KEY to your environment and restart.");
}
throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- No FireworksAI API key was set.
- No Gemini API key was set.
- GenericOpenAI must have a valid base path to use for the…
- No Foundry Base Path was set.
- No Gemini API key was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/d3465f4b7a2a5247.
Report an issue: GitHub.
Appendix: source
Thrown at server/utils/AiProviders/giteeai/index.js:21
const { safeJsonParse, toValidNumber } = require("../../http");
const LEGACY_MODEL_MAP = require("../modelMap/legacy");
const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const {
handleDefaultStreamResponseV2,
} = require("../../helpers/chat/responses");
const cacheFolder = path.resolve(
process.env.STORAGE_DIR
? path.resolve(process.env.STORAGE_DIR, "models", "giteeai")
: path.resolve(__dirname, `../../../storage/models/giteeai`)
);
class GiteeAILLM {
constructor(embedder = null, modelPreference = null) {
if (!process.env.GITEE_AI_API_KEY)
throw new Error("No Gitee AI API key was set.");
const { OpenAI: OpenAIApi } = require("openai");
this.className = "GiteeAILLM";
this.openai = new OpenAIApi({
apiKey: process.env.GITEE_AI_API_KEY,
baseURL: "https://ai.gitee.com/v1",
});
this.model = modelPreference || process.env.GITEE_AI_MODEL_PREF || "";
this.limits = {
history: this.promptWindowLimit() * 0.15,
system: this.promptWindowLimit() * 0.15,
user: this.promptWindowLimit() * 0.7,
};
this.embedder = embedder ?? new NativeEmbedder();
this.defaultTemp = 0.7;
if (!fs.existsSync(cacheFolder))View on GitHub (pinned to 3aec848f28)