Budibase/budibase · error · HTTPError

Error fetching LiteLLM model cost map: ${text || res.statusT

Error message

Error fetching LiteLLM model cost map: ${text || res.statusText}

What it means

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.

Source

Thrown at packages/server/src/sdk/workspace/ai/configs/litellm.ts:656

      }
      value = json.data?.find(d => d.model_info?.id === liteLLMModelId)
        ?.model_info?.max_input_tokens
    }
  } catch {
    // fall through and cache undefined
  }
  modelMaxInputCache.set(liteLLMModelId, {
    value,
    expires: Date.now() + MODEL_INFO_TTL_MS,
  })
  return value
}

export async function fetchPublicModelCostMap(): Promise<LiteLLMModelCostMap> {
  const res = await fetch(`${liteLLMUrl}/public/litellm_model_cost_map`)
  if (!res.ok) {
    const text = await res.text()
    throw new HTTPError(
      `Error fetching LiteLLM model cost map: ${text || res.statusText}`,
      res.status
    )
  }

  const json = await res.json()
  return json as LiteLLMModelCostMap
}

async function mapToLiteLLMProvider(provider: string) {
  if (provider === BUDIBASE_AI_PROVIDER_ID) {
    return "custom_openai"
  }

  const providers = await fetchPublicProviders()
  const result = providers.find(p => p.provider === provider)?.litellm_provider

  if (!result) {

View on GitHub (pinned to a81a902e9a)

Solutions

  1. curl ${liteLLMUrl}/public/litellm_model_cost_map to see the raw upstream error and compare with the message.
  2. Check LiteLLM proxy health/URL configuration and restart the proxy if down.
  3. Upgrade LiteLLM if the cost map endpoint returns 404 (endpoint not present in that version).

Example fix

null
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await fetch(`${liteLLMUrl}/public/litellm_model_cost_map`)
if (res.status === 404) throw new Error("Cost map endpoint missing in this LiteLLM build")

Try / catch

try {
  const costMap = await fetchPublicModelCostMap()
} catch (e) {
  if (e.message.startsWith("Error fetching LiteLLM model cost map")) {
    return lastKnownGoodCostMap // stale-but-usable fallback
  }
  throw e
}

Prevention

When it happens

Trigger: GET /public/litellm_model_cost_map returning 4xx/5xx — proxy unreachable, route absent in the deployed LiteLLM version, or gateway returning 502/503.

Common situations: LiteLLM proxy outage; older LiteLLM builds without the public cost-map endpoint; large cost map timeouts through a proxy that truncates responses.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/c80174680926b7b5. Report an issue: GitHub.