{"record":{"id":"e402fec001d771f8","repo":"Mintplex-Labs/anything-llm","slug":"e-message-e402fe","errorCode":null,"errorMessage":"${e.message}","messagePattern":"\\$\\{e\\.message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/sambanova/index.js","lineNumber":125,"sourceCode":"      prompt,\n      ...chatHistory,\n      {\n        role: \"user\",\n        content: this.#generateContent({ userPrompt, attachments }),\n      },\n    ];\n  }\n\n  async getChatCompletion(messages = null, { temperature = 0.7 }) {\n    const result = await LLMPerformanceMonitor.measureAsyncFunction(\n      this.openai.chat.completions\n        .create({\n          model: this.model,\n          messages,\n          temperature,\n        })\n        .catch((e) => {\n          throw new Error(e.message);\n        })\n    );\n\n    if (\n      !result.output.hasOwnProperty(\"choices\") ||\n      result.output.choices.length === 0\n    )\n      return null;\n\n    return {\n      textResponse: result.output.choices[0].message.content,\n      metrics: {\n        prompt_tokens: result.output.usage?.prompt_tokens || 0,\n        completion_tokens: result.output.usage?.completion_tokens || 0,\n        total_tokens: result.output.usage?.total_tokens || 0,\n        outputTps: result.output.usage?.total_tokens_per_sec || 0,\n        duration: result.duration,\n        model: this.model,","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/sambanova/index.js#L107-L143","documentation":"Re-thrown from the OpenAI SDK rejection inside SambaNovaLLM.getChatCompletion via `.catch((e) => { throw new Error(e.message); })`. SambaNova does NOT pre-validate the model (isValidChatCompletionModel just returns !!modelName), so unlike Perplexity/PPIO/TogetherAI, an unknown-model error surfaces here as a runtime API failure rather than a pre-flight throw. The wrapper strips the SDK error class/status, leaving only the message.","triggerScenarios":"api.sambanova.ai returns non-2xx for the create call: 401 (bad key), 400 (model id not served by this key / not deployed), 429 (rate limit), 5xx, or a transport/abort error before a response.","commonSituations":"SAMBANOVA_LLM_MODEL_PREF references a model not enabled for the API key's tenant (SambaNova gates models per deployment); key revoked after startup; burst traffic hit the rate ceiling; cold start timeout; client aborted mid-request.","solutions":["If the message mentions the model: switch SAMBANOVA_LLM_MODEL_PREF to a model the key is authorised to call (check the SambaNova console's enabled-models list).","curl POST https://api.sambanova.ai/v1/chat/completions with the same key/model to isolate auth vs model vs quota.","On 429, throttle or add bounded exponential-backoff retry.","On 401, rotate the key and restart."],"exampleFix":"// before\nconst out = await llm.getChatCompletion(messages, { temperature: 0.7 });\n\n// after\nconst out = await (async () => {\n  for (let i = 0; i < 3; i++) {\n    try {\n      return await llm.getChatCompletion(messages, { temperature: 0.7 });\n    } catch (e) {\n      if (/401|not authorized|model/i.test(e.message)) throw e; // non-transient\n      if (i === 2) throw e;\n      await new Promise((r) => setTimeout(r, 2 ** i * 500));\n    }\n  }\n})();","handlingStrategy":"retry","validationCode":"function classifySambanovaError(message) {\n  if (/401|unauthorized|invalid api key/i.test(message)) return \"auth\";\n  if (/model|not found|not authorized|deployed/i.test(message)) return \"model\";\n  if (/429|rate limit|quota/i.test(message)) return \"rate\";\n  if (/5\\d{2}|timeout|ECONN/i.test(message)) return \"transient\";\n  return \"fatal\";\n}\n// SambaNova does no client-side model check, so model/auth errors arrive here","typeGuard":"function isTransientSambanovaError(message) {\n  return typeof message === \"string\" && /429|5\\d{2}|timeout|ECONNRESET|fetch failed/i.test(message);\n}","tryCatchPattern":"async function sambanovaCall(llm, messages, opts, retries = 3) {\n  for (let i = 0; i <= retries; i++) {\n    try {\n      return await llm.getChatCompletion(messages, opts);\n    } catch (e) {\n      const kind = classifySambanovaError(e.message);\n      if (kind === \"auth\" || kind === \"model\" || i === retries) throw e;\n      await new Promise((r) => setTimeout(r, 2 ** i * 500));\n    }\n  }\n}","preventionTips":["SambaNova performs no client-side model validation — confirm SAMBANOVA_LLM_MODEL_PREF is authorised for the key on the console before deploying.","Preserve the original error with `new Error(e.message, { cause: e })` since the wrapper drops the SDK class.","Add a pre-flight GET to api.sambanova.ai/v1/models to confirm the model id is available to the key.","Classify errors so model/auth failures are not retried blindly."],"tags":["runtime","api-error","llm-provider","sambanova","network","error-wrapping"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}