diegosouzapw/OmniRoute · error

LiteLLM returned invalid JSON (${text.slice(0, 100)}...)

Error message

LiteLLM returned invalid JSON (${text.slice(0, 100)}...)

What it means

Error "LiteLLM returned invalid JSON (${text.slice(0, 100)}...)" thrown in diegosouzapw/OmniRoute.

Source

Thrown at src/lib/pricingSync.ts:162

let activeSyncIntervalMs = SYNC_INTERVAL_MS;

// ─── Core: Fetch + Transform ─────────────────────────────

/**
 * Fetch raw pricing data from LiteLLM GitHub.
 */
export async function fetchLiteLLMPricing(): Promise<Record<string, LiteLLMModelInfo>> {
  const response = await fetch(LITELLM_PRICING_URL, {
    signal: AbortSignal.timeout(30000),
  });
  if (!response.ok) {
    throw new Error(`LiteLLM fetch failed [${response.status}]: ${response.statusText}`);
  }
  const text = await response.text();
  try {
    return JSON.parse(text) as Record<string, LiteLLMModelInfo>;
  } catch {
    throw new Error(`LiteLLM returned invalid JSON (${text.slice(0, 100)}...)`);
  }
}

/**
 * Transform LiteLLM raw data → OmniRoute PricingByProvider format.
 *
 * Conversion: cost_per_token × 1_000_000 → $/1M tokens (OmniRoute format).
 * Ingests both chat (token) AND non-token modes (image / audio / rerank /
 * video / embedding). Token pricing is scaled to $/1M; non-token fields
 * (per-image, per-second, per-character, search-unit, …) are carried through
 * verbatim as absolute USD.
 */
export function transformToOmniRoute(raw: Record<string, LiteLLMModelInfo>): PricingByProvider {
  const result: PricingByProvider = {};

  for (const [modelKey, info] of Object.entries(raw)) {
    const NON_TOKEN_FIELDS = [
      "input_cost_per_second",

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at src/lib/pricingSync.ts:162 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/44fadea8d129446a. Report an issue: GitHub.