{"record":{"id":"c80174680926b7b5","repo":"Budibase/budibase","slug":"error-fetching-litellm-model-cost-map-text-r","errorCode":null,"errorMessage":"Error fetching LiteLLM model cost map: ${text || res.statusText}","messagePattern":"Error fetching LiteLLM model cost map: (.+?)","errorType":"http","errorClass":"HTTPError","httpStatus":null,"severity":"error","filePath":"packages/server/src/sdk/workspace/ai/configs/litellm.ts","lineNumber":656,"sourceCode":"      }\n      value = json.data?.find(d => d.model_info?.id === liteLLMModelId)\n        ?.model_info?.max_input_tokens\n    }\n  } catch {\n    // fall through and cache undefined\n  }\n  modelMaxInputCache.set(liteLLMModelId, {\n    value,\n    expires: Date.now() + MODEL_INFO_TTL_MS,\n  })\n  return value\n}\n\nexport async function fetchPublicModelCostMap(): Promise<LiteLLMModelCostMap> {\n  const res = await fetch(`${liteLLMUrl}/public/litellm_model_cost_map`)\n  if (!res.ok) {\n    const text = await res.text()\n    throw new HTTPError(\n      `Error fetching LiteLLM model cost map: ${text || res.statusText}`,\n      res.status\n    )\n  }\n\n  const json = await res.json()\n  return json as LiteLLMModelCostMap\n}\n\nasync function mapToLiteLLMProvider(provider: string) {\n  if (provider === BUDIBASE_AI_PROVIDER_ID) {\n    return \"custom_openai\"\n  }\n\n  const providers = await fetchPublicProviders()\n  const result = providers.find(p => p.provider === provider)?.litellm_provider\n\n  if (!result) {","sourceCodeStart":638,"sourceCodeEnd":674,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/ai/configs/litellm.ts#L638-L674","documentation":"fetchPublicModelCostMap fetches LiteLLM's /public/litellm_model_cost_map endpoint (pricing/context metadata for models). Non-OK responses raise an HTTPError containing the response body (or statusText) with the upstream status.","triggerScenarios":"GET /public/litellm_model_cost_map returning 4xx/5xx — proxy unreachable, route absent in the deployed LiteLLM version, or gateway returning 502/503.","commonSituations":"LiteLLM proxy outage; older LiteLLM builds without the public cost-map endpoint; large cost map timeouts through a proxy that truncates responses.","solutions":["curl ${liteLLMUrl}/public/litellm_model_cost_map to see the raw upstream error and compare with the message.","Check LiteLLM proxy health/URL configuration and restart the proxy if down.","Upgrade LiteLLM if the cost map endpoint returns 404 (endpoint not present in that version)."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"const res = await fetch(`${liteLLMUrl}/public/litellm_model_cost_map`)\nif (res.status === 404) throw new Error(\"Cost map endpoint missing in this LiteLLM build\")","typeGuard":null,"tryCatchPattern":"try {\n  const costMap = await fetchPublicModelCostMap()\n} catch (e) {\n  if (e.message.startsWith(\"Error fetching LiteLLM model cost map\")) {\n    return lastKnownGoodCostMap // stale-but-usable fallback\n  }\n  throw e\n}","preventionTips":["Cache the last successful cost map for fallback on proxy outages.","Confirm the deployed LiteLLM exposes the cost-map endpoint.","Alert on repeated failures — they indicate proxy or ingress problems."],"tags":["network","litellm","upstream-error","model-cost"],"backgroundTag":"upstream-api-error","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}