Files
litellm/scripts/check_eur_fx.py
T
inference-bot 18aa7c7573 pricing: regenerate USD fallback at ECB 1.0975, fix stale header, harden gate
The config header still claimed "EUR->USD FX = 1.16" and listed GreenPT/Regolo
EUR numerals with $ signs; the committed USD fallback was likewise generated
at 1.16 while the gateway has been applying the ECB daily rate since the boot
sync landed (live 1.0975 on 2026-11-26). Live billing was correct, but anyone
reading the config — members included — saw pre-conversion rates presented as
USD, and a first-install fallback over-billed by ~5.7%.

- Header now names eur_prices.json as the only source, says the USD numerals
  are generated, and pins the fallback at 1.0975 (ECB 2026-11-26).
- All GreenPT/Regolo model_info regenerated at that pin; in-file price comments
  relabelled EUR where they carried EUR numerals.
- check_eur_fx.py now reads eur_prices.json instead of a hardcoded list (which
  silently omitted regolo/apertus-70b and regolo/qwen3.5-122b), takes FX from
  FX_FALLBACK_USD, and fails if the config header pin disagrees.
2026-11-27 17:57:54 +00:00

69 lines
2.5 KiB
Python
Executable File

#!/usr/bin/env python3
"""Fail if a EUR-quoted provider's model_info is not EUR * FX.
GreenPT and Regolo quote EUR; LiteLLM costs are USD. Pasting EUR numerals into
model_info under-bills members by the FX gap (found 2026-11-18).
The EUR list prices live in eur_prices.json (the only source). This gate reads
that file instead of duplicating the prices, so a model added or repriced there
is covered automatically — the old hardcoded list missed regolo/apertus-70b and
regolo/qwen3.5-122b entirely.
FX is the FALLBACK pin: the rate the committed USD numerals were generated at.
At boot fx_sync.py overwrites them with the ECB daily rate, so this gate only
checks the committed (first-install) fallback. Keep FX_FALLBACK_USD equal to the
pin named in config.yaml's header.
"""
import json
import os
import re
import sys
FX = float(os.environ.get("FX_FALLBACK_USD", "1.0975"))
eur = json.load(open("eur_prices.json", encoding="utf-8"))["models"]
text = open("config.yaml", encoding="utf-8").read()
# The header states the pin; a mismatch means the fallback was regenerated at a
# different rate than the gate expects, which is how a stale 1.16 survived.
hdr = re.search(r"FX_FALLBACK_USD \(([0-9.]+)", text)
if hdr and abs(float(hdr.group(1)) - FX) > 1e-9:
print(f"FAIL: config header pins FX {hdr.group(1)}, gate expects {FX}")
sys.exit(1)
def block_for(name: str):
m = re.search(r"- model_name: " + re.escape(name) +
r"\n(.*?)(?=\n - model_name: |\n[a-zA-Z#])", text, re.S)
return m.group(1) if m else None
bad = []
for name, prices in eur.items():
block = block_for(name)
if block is None:
bad.append(f"{name}: missing block")
continue
def val(key, block=block):
mm = re.search(key + r": (\S+)", block)
return float(mm.group(1)) if mm else None
checks = [("input_cost_per_token", prices.get("input")),
("output_cost_per_token", prices.get("output"))]
if prices.get("cache") is not None:
checks.append(("cache_read_input_token_cost", prices["cache"]))
for key, eur_val in checks:
if eur_val is None:
continue
want = eur_val * FX / 1_000_000
got = val(key)
if got is None or abs(got - want) > max(1e-12, want * 1e-6):
bad.append(f"{name}: {key} got {got}, want {want:.10g}")
print(f"checked {len(eur)} EUR models at fallback FX {FX}")
if bad:
print("\n".join(bad))
sys.exit(1)
print("OK: EUR list prices converted to USD at the fallback pin")