DEV Community

Long AI
Long AI

Posted on

Model names drift. Your gateway should not.

#ai

Most reliability advice about aggregating LLM APIs is about uptime: retries, circuit breakers, fallbacks. In practice the failures that hurt clients first are naming failures.

A provider ships a new dated snapshot. Another quietly stops accepting a short alias. A video model moves from one family name to another. From the outside nothing is wrong: the health check is green, status is 200, the docs still show the old string. Inside, every caller who hardcoded that string now gets a 400 with model_not_found, or worse, a 200 answered by a different model than the one they asked for.

We run a gateway over 109 models from a lot of upstreams, so this is our daily bread. Three rules keep it manageable.

1. Keep three names for every model, not one

  • canonical id - what our API accepts, never changes once published.
  • upstream id - what the vendor currently wants, changes whenever they change.
  • display name - what a human sees on a price page.

Only the middle one is allowed to move. A rename upstream becomes a one-line mapping change, not a breaking change for everyone downstream.

ALIASES = {
    "gpt-4o-mini": ["gpt-4o-mini", "gpt-4o-mini-2024-07-18"],
    "kling-v2": ["kling-v2", "kling-v2-master"],
}

def resolve(model: str) -> str:
    for canon, names in ALIASES.items():
        if model in names:
            return canon
    raise ValueError(f"unknown model: {model}")
Enter fullscreen mode Exit fullscreen mode

2. Serve the catalog before you serve the chat

GET /v1/models is the cheapest request an integrator makes and the cheapest place to be honest. If the list endpoint returns models that chat does not accept, or omits models that chat does accept, every client will eventually discover that the hard way.

We treat the list as the source of truth and test it against the chat route: for each declared model, a minimal call must at least reach the upstream and come back with a provider-shaped error, not model_not_found from us.

3. Document the mapping, publicly

The mapping table is the thing integrators search for at 2am. Ours lives on the per-model reference pages: canonical id, upstream id, context window, whether streaming and tool calls are supported, and the price per million tokens as actually charged rather than as advertised.

That page also settles arguments. When a customer says "your price does not match the vendor", the answer is usually that the vendor's page shows list price for a different tier, and the reference page shows which tier the model is routed to.

What this buys you

Renames become routine. When an upstream retires a snapshot we keep the canonical id alive against the successor for a deprecation window, and callers migrate on their own schedule instead of ours. The catalog stays monotonic: clients can trust that a model that worked yesterday still resolves today, even if the bytes are now served by a different upstream.

If you are building against an OpenAI-compatible endpoint, the practical test is simple: ask it to list what it can do, then call each listed model once. A catalog that passes that check is one you can automate against without a spreadsheet.


I maintain LONG AI, an OpenAI-compatible gateway that routes to 109 upstream models - this post is what the name-mapping layer behind it looks like.

Top comments (0)