{"record":{"id":"3c03a4548e83e23b","repo":"Mintplex-Labs/anything-llm","slug":"z-ai-api-key-must-be-provided-to-use-agents","errorCode":null,"errorMessage":"Z.AI API Key must be provided to use agents.","messagePattern":"Z\\.AI API Key must be provided to use agents\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/index.js","lineNumber":223,"sourceCode":"          throw new Error(\"DeepSeek API Key must be provided to use agents.\");\n        break;\n      case \"litellm\":\n        if (!process.env.LITE_LLM_BASE_PATH)\n          throw new Error(\n            \"LiteLLM API base path and key must be provided to use agents.\"\n          );\n        break;\n      case \"apipie\":\n        if (!process.env.APIPIE_LLM_API_KEY)\n          throw new Error(\"ApiPie API Key must be provided to use agents.\");\n        break;\n      case \"xai\":\n        if (!process.env.XAI_LLM_API_KEY)\n          throw new Error(\"xAI API Key must be provided to use agents.\");\n        break;\n      case \"zai\":\n        if (!process.env.ZAI_API_KEY)\n          throw new Error(\"Z.AI API Key must be provided to use agents.\");\n        break;\n      case \"novita\":\n        if (!process.env.NOVITA_LLM_API_KEY)\n          throw new Error(\"Novita API Key must be provided to use agents.\");\n        break;\n      case \"nvidia-nim\":\n        if (!process.env.NVIDIA_NIM_LLM_BASE_PATH)\n          throw new Error(\n            \"NVIDIA NIM base path must be provided to use agents.\"\n          );\n        break;\n      case \"ppio\":\n        if (!process.env.PPIO_API_KEY)\n          throw new Error(\"PPIO API Key must be provided to use agents.\");\n        break;\n      case \"gemini\":\n        if (!process.env.GEMINI_API_KEY)\n          throw new Error(\"Gemini API key must be provided to use agents.\");","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/index.js#L205-L241","documentation":"Thrown by AgentHandler.checkSetup() (server/utils/agents/index.js:222) when the workspace agent provider is 'zai' but ZAI_API_KEY is unset/empty. Z.AI (GLM family) exposes its API behind this key, which is the only credential the guard validates.","triggerScenarios":"An agent invocation runs with workspace.agentProvider === 'zai' while ZAI_API_KEY is absent from process.env. Path: #providerSetupAndCheck() -> checkSetup() at index.js:476.","commonSituations":"Z.AI selected in System > LLM Preference without a key; key from z.ai management console not pasted into .env; .env changed but AnythingLLM not restarted; key expired/revoked.","solutions":["Create an API key in the Z.AI console (open.bigmodel.cn / z.ai) and set ZAI_API_KEY in .env.","Restart AnythingLLM to reload process.env.","Verify the key with a curl to the Z.AI models endpoint using Authorization: Bearer $ZAI_API_KEY.","Confirm the workspace agent model is a valid Z.AI/GLM model id."],"exampleFix":"// before (.env)\n// ZAI_API_KEY=\n\n// after (.env)\nZAI_API_KEY=...your-zai-key","handlingStrategy":"validation","validationCode":"const key = process.env.ZAI_API_KEY;\nif (!key) {\n  throw new Error(\n    'Cannot start Z.AI agent: set ZAI_API_KEY (from the Z.AI console) in .env.'\n  );\n}","typeGuard":null,"tryCatchPattern":"try {\n  await agentHandler.start();\n} catch (e) {\n  if (/Z\\.AI API Key must be provided/.test(e.message)) {\n    return respondConfigError('zai', ['ZAI_API_KEY']);\n  }\n  throw e;\n}","preventionTips":["Create the key in the Z.AI console and write it to .env immediately.","Restart the Node process / Docker container after .env edits.","Add a CI/startup assertion that ZAI_API_KEY is set when provider is zai.","Keep .env out of version control."],"tags":["agents","llm-provider","zai","glm","api-key","environment-variables","config"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}