{"record":{"id":"c793964772eda3df","repo":"Mintplex-Labs/anything-llm","slug":"e-message-c79396","errorCode":null,"errorMessage":"${e.message}","messagePattern":"\\$\\{e\\.message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/nvidiaNim/index.js","lineNumber":169,"sourceCode":"      },\n    ];\n  }\n\n  async getChatCompletion(messages = null, { temperature = 0.7 }) {\n    if (!this.model)\n      throw new Error(\n        `NVIDIA NIM chat: ${this.model} is not valid or defined model for chat completion!`\n      );\n\n    const result = await LLMPerformanceMonitor.measureAsyncFunction(\n      this.nvidiaNim.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.completion_tokens / result.duration,\n        duration: result.duration,\n        model: this.model,","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/nvidiaNim/index.js#L151-L187","documentation":"Propagates the raw rejection message from the NVIDIA NIM OpenAI-compatible 'chat.completions.create' call. The NIM client is built with apiKey:null, so failures surface as the underlying SDK/HTTP message (model not found, server unreachable, context overflow, malformed base path). The catch discards the original Error's status/cause and re-throws only e.message.","triggerScenarios":"Calling NvidiaNimLLM.getChatCompletion when the NIM container is down, the model id in this.model is not served by the endpoint, the prompt exceeds the model's context window, or NVIDIA_NIM_LLM_BASE_PATH resolves to a URL that returns a non-2xx (e.g. wrong port, missing /v1).","commonSituations":"NIM Docker container not started; NVIDIA_NIM_LLM_MODEL_PREF left blank or typo'd; base path pasted with a trailing slash or wrong port; model not yet pulled/loaded on the NIM server; oversized prompt after context injection.","solutions":["Read the exact e.message text: 'model not found' vs 'fetch failed' vs 'context length exceeded' points to different roots.","Confirm the NIM server is up by curling ${NVIDIA_NIM_LLM_BASE_PATH}/v1/models and checking this.model appears in the list.","Verify NVIDIA_NIM_LLM_BASE_PATH and NVIDIA_NIM_LLM_MODEL_PREF are set and that the base path origin is reachable.","If the message indicates context length, raise NVIDIA_NIM_LLM_MODEL_TOKEN_LIMIT or trim contextTexts/chatHistory."],"exampleFix":"// before\nconst result = await LLMPerformanceMonitor.measureAsyncFunction(\n  this.nvidiaNim.chat.completions.create({ model: this.model, messages, temperature })\n    .catch((e) => { throw new Error(e.message); })\n);\n\n// after - preserve status/cause for diagnosis\n.catch((e) => {\n  const err = new Error(e.message);\n  err.status = e.status;\n  err.cause = e;\n  throw err;\n})","handlingStrategy":"try-catch","validationCode":"const assertNimReady = async (basePath, model) => {\n  const res = await fetch(`${basePath.replace(/\\/$/, '')}/v1/models`);\n  if (!res.ok) throw new Error(`NIM endpoint unhealthy: HTTP ${res.status}`);\n  const { data = [] } = await res.json();\n  if (!data.some((m) => m.id === model)) throw new Error(`NIM model '${model}' not served`);\n};\nawait assertNimReady(process.env.NVIDIA_NIM_LLM_BASE_PATH, modelId);","typeGuard":"const hasNimChoices = (o) =>\n  !!o && typeof o === 'object' && Array.isArray(o.choices) && o.choices.length > 0;","tryCatchPattern":"try {\n  const out = await llm.getChatCompletion(messages, { temperature });\n} catch (e) {\n  logger.error('NIM chat failed', { message: e.message, status: e.status });\n  throw e;\n}","preventionTips":["Validate the NIM endpoint and model via /v1/models before issuing chat requests.","Keep NVIDIA_NIM_LLM_MODEL_TOKEN_LIMIT aligned with the deployed model's actual context window.","Surface e.status alongside e.message so callers can branch on rate-limit vs not-found."],"tags":["nvidia-nim","llm-provider","network","configuration"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}