{"record":{"id":"f326b48cbd372edb","repo":"Mintplex-Labs/anything-llm","slug":"no-sambanova-api-key-was-set","errorCode":null,"errorMessage":"No SambaNova API key was set.","messagePattern":"No SambaNova API key was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/sambanova/index.js","lineNumber":16,"sourceCode":"const { NativeEmbedder } = require(\"../../EmbeddingEngines/native\");\nconst { isAbortError } = require(\"../../helpers/abortSignals\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst { v4: uuidv4 } = require(\"uuid\");\nconst {\n  writeResponseChunk,\n  clientAbortedHandler,\n} = require(\"../../helpers/chat/responses\");\nconst { MODEL_MAP } = require(\"../modelMap\");\n\nclass SambaNovaLLM {\n  constructor(embedder = null, modelPreference = null) {\n    if (!process.env.SAMBANOVA_LLM_API_KEY)\n      throw new Error(\"No SambaNova API key was set.\");\n    this.className = \"SambaNovaLLM\";\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n\n    this.openai = new OpenAIApi({\n      baseURL: \"https://api.sambanova.ai/v1\",\n      apiKey: process.env.SAMBANOVA_LLM_API_KEY,\n    });\n    this.model = modelPreference || process.env.SAMBANOVA_LLM_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    this.log(\n      `Initialized ${this.model} with context window ${this.promptWindowLimit()}`","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/sambanova/index.js#L1-L34","documentation":"Thrown by the SambaNovaLLM constructor when process.env.SAMBANOVA_LLM_API_KEY is falsy. SambaNova exposes an OpenAI-compatible endpoint at https://api.sambanova.ai/v1 and the constructor builds the client inline, so it fails fast without a key.","triggerScenarios":"Calling `new SambaNovaLLM(...)` while SAMBANOVA_LLM_API_KEY is unset or empty. Selecting SambaNova in the UI before provisioning a key at sambanova.ai, or running the server with the variable missing.","commonSituations":"New SambaNova integration where the API key was not yet created in the SambaNova console; variable named SAMBANOVA_API_KEY instead of SAMBANOVA_LLM_API_KEY; .env updated but server not restarted; container env not refreshed.","solutions":["Generate a key in the SambaNova dashboard and set SAMBANOVA_LLM_API_KEY in server/.env, then restart.","Verify with `node -e \"console.log(Boolean(process.env.SAMBANOVA_LLM_API_KEY))\"` under the same env.","Pass the variable through in Docker (env_file / environment) and recreate the container.","Remove any surrounding quotes/whitespace."],"exampleFix":"// before\n// SAMBANOVA_LLM_API_KEY unset -> throws\nconst llm = new SambaNovaLLM(embedder, \"Meta-Llama-3.1-70B-Instruct\");\n\n// after\n// server/.env\n// SAMBANOVA_LLM_API_KEY=<key from sambanova.ai>\nconst llm = new SambaNovaLLM(embedder, \"Meta-Llama-3.1-70B-Instruct\");","handlingStrategy":"validation","validationCode":"function assertSambanovaKey() {\n  if (!process.env.SAMBANOVA_LLM_API_KEY || !process.env.SAMBANOVA_LLM_API_KEY.trim()) {\n    throw new Error(\"SAMBANOVA_LLM_API_KEY is missing — create one in the SambaNova console\");\n  }\n}\nassertSambanovaKey();\nconst llm = new SambaNovaLLM(embedder, modelPref);","typeGuard":"function hasSambanovaKey(env = process.env) {\n  return typeof env.SAMBANOVA_LLM_API_KEY === \"string\" && env.SAMBANOVA_LLM_API_KEY.trim().length > 0;\n}","tryCatchPattern":"let llm;\ntry {\n  llm = new SambaNovaLLM(embedder, modelPref);\n} catch (e) {\n  if (/No SambaNova API key/i.test(e.message)) {\n    return { ok: false, reason: \"missing-sambanova-key\" };\n  }\n  throw e;\n}","preventionTips":["Validate all provider keys at boot and report missing ones in one message.","Use the exact name SAMBANOVA_LLM_API_KEY (note the _LLM segment) — a common typo is SAMBANOVA_API_KEY.","Restart the process after adding the variable.","Confirm the key is authorised for the model on the SambaNova console, since SambaNova gates models per tenant."],"tags":["configuration","api-key","env","llm-provider","sambanova","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}