#!/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")