{"record":{"id":"44fadea8d129446a","repo":"diegosouzapw/OmniRoute","slug":"litellm-returned-invalid-json-text-slice-0-100","errorCode":null,"errorMessage":"LiteLLM returned invalid JSON (${text.slice(0, 100)}...)","messagePattern":"LiteLLM returned invalid JSON \\((.+?)\\.\\.\\.\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/pricingSync.ts","lineNumber":162,"sourceCode":"let activeSyncIntervalMs = SYNC_INTERVAL_MS;\n\n// ─── Core: Fetch + Transform ─────────────────────────────\n\n/**\n * Fetch raw pricing data from LiteLLM GitHub.\n */\nexport async function fetchLiteLLMPricing(): Promise<Record<string, LiteLLMModelInfo>> {\n  const response = await fetch(LITELLM_PRICING_URL, {\n    signal: AbortSignal.timeout(30000),\n  });\n  if (!response.ok) {\n    throw new Error(`LiteLLM fetch failed [${response.status}]: ${response.statusText}`);\n  }\n  const text = await response.text();\n  try {\n    return JSON.parse(text) as Record<string, LiteLLMModelInfo>;\n  } catch {\n    throw new Error(`LiteLLM returned invalid JSON (${text.slice(0, 100)}...)`);\n  }\n}\n\n/**\n * Transform LiteLLM raw data → OmniRoute PricingByProvider format.\n *\n * Conversion: cost_per_token × 1_000_000 → $/1M tokens (OmniRoute format).\n * Ingests both chat (token) AND non-token modes (image / audio / rerank /\n * video / embedding). Token pricing is scaled to $/1M; non-token fields\n * (per-image, per-second, per-character, search-unit, …) are carried through\n * verbatim as absolute USD.\n */\nexport function transformToOmniRoute(raw: Record<string, LiteLLMModelInfo>): PricingByProvider {\n  const result: PricingByProvider = {};\n\n  for (const [modelKey, info] of Object.entries(raw)) {\n    const NON_TOKEN_FIELDS = [\n      \"input_cost_per_second\",","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/pricingSync.ts#L144-L180","documentation":"Error \"LiteLLM returned invalid JSON (${text.slice(0, 100)}...)\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/pricingSync.ts:162 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}