{"record":{"id":"41475beb69bf7862","repo":"Mintplex-Labs/anything-llm","slug":"cerebras-getmodelcapabilities-res-statustext","errorCode":null,"errorMessage":"Cerebras:getModelCapabilities - ${res.statusText}","messagePattern":"Cerebras:getModelCapabilities - (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"server/utils/AiProviders/cerebras/index.js","lineNumber":272,"sourceCode":"    return handleDefaultStreamResponseV2(response, stream, responseProps);\n  }\n\n  /**\n   * Returns the capabilities of the model.\n   * This uses the new /public/v1/models endpoint, which returns the model capabilities.\n   * @returns {Promise<{tools: 'unknown' | boolean, reasoning: 'unknown' | boolean, imageGeneration: 'unknown' | boolean, vision: 'unknown' | boolean}>}\n   */\n  async getModelCapabilities() {\n    try {\n      const capabilities =\n        (await fetch(`https://api.cerebras.ai/public/v1/models/${this.model}`, {\n          headers: {\n            \"Content-Type\": \"application/json\",\n          },\n        })\n          .then((res) => {\n            if (!res.ok)\n              throw new Error(\n                `Cerebras:getModelCapabilities - ${res.statusText}`\n              );\n            return res.json();\n          })\n          .then(({ capabilities }) => capabilities)) || {};\n\n      return {\n        tools: capabilities?.tools,\n        reasoning: capabilities?.reasoning,\n        imageGeneration: false,\n        vision: capabilities?.vision,\n      };\n    } catch (error) {\n      console.error(\"Error getting model capabilities:\", error);\n      return {\n        tools: \"unknown\",\n        reasoning: \"unknown\",\n        imageGeneration: \"unknown\",","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/cerebras/index.js#L254-L290","documentation":"Thrown inside CerebrasLLM.getModelCapabilities when the per-model endpoint `https://api.cerebras.ai/public/v1/models/<this.model>` returns non-2xx; the .then checks res.ok and throws with statusText. The surrounding try returns a defaulted capabilities object on any failure, so the throw is internally swallowed — callers get `{tools|reasoning|vision: undefined}` rather than a propagated error.","triggerScenarios":"Calling getModelCapabilities for a model id the public endpoint does not recognize (404), during a Cerebras outage (5xx), or when a proxy returns a non-2xx. The catch in getModelCapabilities returns a mostly-empty capabilities object, so feature detection silently degrades.","commonSituations":"this.model is a custom/new id not yet listed publicly; model id typo; transient outage; proxy block; the public capabilities path changed.","solutions":["Confirm the model id is correct and currently listed at https://api.cerebras.ai/public/v1/models.","Treat as transient for outages — capabilities default to 'unknown'/undefined and the app continues; re-check later.","Verify reachability: `curl -i https://api.cerebras.ai/public/v1/models/<model>`.","If the path changed upstream, update the provider to the current Cerebras capabilities endpoint."],"exampleFix":"// before\nif (!res.ok)\n  throw new Error(`Cerebras:getModelCapabilities - ${res.statusText}`);\n\n// after - distinguish 404 (unknown model) from transient errors\nif (!res.ok) {\n  if (res.status === 404)\n    throw new Error(`Cerebras:getModelCapabilities - unknown model ${this.model}`);\n  throw new Error(`Cerebras:getModelCapabilities - ${res.status} ${res.statusText}`);\n}","handlingStrategy":"try-catch","validationCode":"// Optional pre-check that the model is publicly listed\nasync function cerebrasModelKnown(model) {\n  const res = await fetch(`https://api.cerebras.ai/public/v1/models/${model}`, {\n    signal: AbortSignal.timeout(5000),\n  });\n  return res.ok;\n}","typeGuard":"/** @param {unknown} e @returns {boolean} */\nfunction isCerebrasCapabilitiesError(e) {\n  return e instanceof Error &&\n    /Cerebras:getModelCapabilities/.test(e.message);\n}","tryCatchPattern":"// getModelCapabilities swallows this internally and returns defaults.\nconst caps = await llm.getModelCapabilities();\nif (caps.tools == null || caps.reasoning == null) {\n  // Capability detection degraded; fall back to conservative behavior.\n  disableToolCalling();\n}","preventionTips":["Treat capability detection as advisory; always have a safe default when it returns unknown.","Validate the model id against the public models list at config-save time.","Don't block the chat path on capabilities — degradation, not failure.","Re-fetch capabilities lazily and cache with a TTL."],"tags":["network","api","cerebras","feature-detection","degraded"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}