Avoid hardcoding model IDs, provider formats, or model-family checks directly in business logic; this creates duplicated knowledge that drifts out of sync and breaks when new models or providers are added. Prefer a centralized model registry or typed provider enum as the single source of truth for model IDs, response formats, and usage/pricing structures, and design shared types (e.g., usage tracking) to mirror the actual provider API shape rather than inventing a custom flattened structure.
When full abstraction isn’t yet feasible, make hardcoded checks resilient and self-documenting:
o[1-9]+(-mini)? instead of ["o1", "o3-mini"].includes(model)).NO_MAPPING still resolves to the correct format for all current integrations).Example of a more robust guard instead of an exact-match list:
// Fragile: breaks silently once o4, o5, ... are released
if (["o1", "o3-mini"].includes(model)) { ... }
// Better: generalizes across the model family
if (/^o[1-9]+(-mini)?$/.test(model)) { ... }