Mintplex-Labs/anything-llm · error · Error
${e.message}
Error message
${e.message} What it means
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.
Source
Thrown at server/utils/AiProviders/sambanova/index.js:125
prompt,
...chatHistory,
{
role: "user",
content: this.#generateContent({ userPrompt, attachments }),
},
];
}
async getChatCompletion(messages = null, { temperature = 0.7 }) {
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.openai.chat.completions
.create({
model: this.model,
messages,
temperature,
})
.catch((e) => {
throw new Error(e.message);
})
);
if (
!result.output.hasOwnProperty("choices") ||
result.output.choices.length === 0
)
return null;
return {
textResponse: result.output.choices[0].message.content,
metrics: {
prompt_tokens: result.output.usage?.prompt_tokens || 0,
completion_tokens: result.output.usage?.completion_tokens || 0,
total_tokens: result.output.usage?.total_tokens || 0,
outputTps: result.output.usage?.total_tokens_per_sec || 0,
duration: result.duration,
model: this.model,View on GitHub (pinned to 526360e320)
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.
Example fix
// before
const out = await llm.getChatCompletion(messages, { temperature: 0.7 });
// after
const out = await (async () => {
for (let i = 0; i < 3; i++) {
try {
return await llm.getChatCompletion(messages, { temperature: 0.7 });
} catch (e) {
if (/401|not authorized|model/i.test(e.message)) throw e; // non-transient
if (i === 2) throw e;
await new Promise((r) => setTimeout(r, 2 ** i * 500));
}
}
})(); Defensive patterns
Strategy: retry
Validate before calling
function classifySambanovaError(message) {
if (/401|unauthorized|invalid api key/i.test(message)) return "auth";
if (/model|not found|not authorized|deployed/i.test(message)) return "model";
if (/429|rate limit|quota/i.test(message)) return "rate";
if (/5\d{2}|timeout|ECONN/i.test(message)) return "transient";
return "fatal";
}
// SambaNova does no client-side model check, so model/auth errors arrive here Type guard
function isTransientSambanovaError(message) {
return typeof message === "string" && /429|5\d{2}|timeout|ECONNRESET|fetch failed/i.test(message);
} Try / catch
async function sambanovaCall(llm, messages, opts, retries = 3) {
for (let i = 0; i <= retries; i++) {
try {
return await llm.getChatCompletion(messages, opts);
} catch (e) {
const kind = classifySambanovaError(e.message);
if (kind === "auth" || kind === "model" || i === retries) throw e;
await new Promise((r) => setTimeout(r, 2 ** i * 500));
}
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/e402fec001d771f8.
Report an issue: GitHub.