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.
This commit is contained in:
inference-bot committed 2026-11-27 17:57:54 +00:00
1 parent 4610e688db
commit 18aa7c7573
2 files changed
+95 -73

No files matched your search

+46 -26
View File
@@ -3,46 +3,66 @@
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 = 1.16
EUR = {
"greenpt/deepseek-v4.1-flash": (0.36, 1.45, 0.04),
"greenpt/glm-5.3-flash": (0.11, 0.44, 0.022),
"greenpt/glm-5.3": (1.10, 4.40, 0.275),
"greenpt/green-embeddings": (0.20, 0.0, None),
"greenpt/qwen3-embedding-8b": (0.25, 0.0, None),
"regolo/mistral-small-4-119b": (0.20, 0.70, None),
"regolo/gemma4-31b": (0.40, 0.60, None),
# Route aliases carry their own model_info; members call these names, so a
# deployment-only conversion leaves billing stale (found 2026-11-18).
"deepseek-flash-green": (0.36, 1.45, 0.04),
"glm-flash-green": (0.11, 0.44, 0.022),
}
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, (i, o, c) in EUR.items():
m = re.search(r"- model_name: " + re.escape(name) + r"\n(.*?)(?=\n - model_name: |\n[a-zA-Z#])", text, re.S)
if not m:
for name, prices in eur.items():
block = block_for(name)
if block is None:
bad.append(f"{name}: missing block")
continue
block = m.group(1)
def val(key):
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", i), ("output_cost_per_token", o)]
if c is not None:
checks.append(("cache_read_input_token_cost", c))
for key, eur in checks:
want = eur * FX / 1_000_000
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("checked", len(EUR), "EUR models at FX", FX)
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")
print("OK: EUR list prices converted to USD at the fallback pin")