{"record":{"id":"e27ccb6843576b3f","repo":"Mintplex-Labs/anything-llm","slug":"no-cerebras-api-key-was-set","errorCode":null,"errorMessage":"No Cerebras API key was set.","messagePattern":"No Cerebras API key was set\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/cerebras/index.js","lineNumber":17,"sourceCode":"const { NativeEmbedder } = require(\"../../EmbeddingEngines/native\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst {\n  handleDefaultStreamResponseV2,\n  formatChatHistory,\n} = require(\"../../helpers/chat/responses\");\nconst { MODEL_MAP } = require(\"../modelMap\");\n\nclass CerebrasLLM {\n  static modelContextWindows = {};\n\n  constructor(embedder = null, modelPreference = null) {\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    if (!process.env.CEREBRAS_API_KEY)\n      throw new Error(\"No Cerebras API key was set.\");\n\n    this.className = \"CerebrasLLM\";\n    this.openai = new OpenAIApi({\n      baseURL: \"https://api.cerebras.ai/v1\",\n      apiKey: process.env.CEREBRAS_API_KEY,\n    });\n    this.model =\n      modelPreference || process.env.CEREBRAS_MODEL_PREF || \"gpt-oss-120b\";\n    // Lazy load the limits to avoid blocking the main thread on cacheContextWindows\n    this.limits = null;\n\n    this.embedder = embedder ?? new NativeEmbedder();\n    this.defaultTemp = 0;\n\n    CerebrasLLM.cacheContextWindows(true);\n    this.#log(`Initialized with model: ${this.model}`);\n  }\n","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/a145d4d87d086bdb31d50f9bf9cd9c46d311780c/server/utils/AiProviders/cerebras/index.js#L1-L35","documentation":"Constructor guard in CerebrasLLM: the CEREBRAS_API_KEY environment variable is unset, so the OpenAI-compatible client cannot authenticate to Cerebras and provider instantiation stops before any request is attempted.","triggerScenarios":"Thrown at provider construction when no Cerebras API key is configured.","commonSituations":"Cerebras selected as LLM provider without an API key.","solutions":["Set the Cerebras API key in provider settings or env."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a145d4d87d086bdb31d50f9bf9cd9c46d311780c","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}