One API for multiple models: how routing works in practice
"One API for every model" sounds like a marketing line until you have written the alternative: five SDKs, five auth schemes, five error formats, five bills, and a retry policy that has to know which provider is which.
A multi-model API collapses that into one endpoint and one schema. The interesting part is not the endpoint — it is the decision made per request behind it.
What the caller sees
from openai import OpenAI
client = OpenAI(base_url="https://api.cisoma.com/v1", api_key="sk-...")
# same client, different models
client.chat.completions.create(model="claude-opus-5",
messages=[{"role": "user", "content": "review this diff"}])
client.chat.completions.create(model="deepseek-flash",
messages=[{"role": "user", "content": "label this ticket"}])
Two models, two vendors, one client, one key, one bill. Streaming, tool calls and usage reporting stay in the same shape.
What happens behind it
request → auth & quota → model resolution → candidate deployments
→ routing policy → provider call → usage metering → response
Model resolution maps the requested name to concrete deployments. claude-opus-5 might resolve to two independent suppliers; gemini-3.1-flash to one.
Routing policy picks among them. The three policies that survive production:
| Policy | Picks | Good for |
|---|---|---|
| Cheapest healthy | lowest live price | batch, background, evals |
| Cheapest above latency floor | lowest price among fast enough | interactive products |
| Capability match | provider that supports the feature | tools, long context, caching |
Metering records model, provider, tokens each direction, effective unit price, latency. That record is what makes routing auditable.
Rule 1: keep model names in config
If claude-opus-5 appears in nine source files, you cannot move traffic to another tier without a release. Put model choice in config or a routing table keyed by task class — classify, extract, generate, reason — and let the table point at model strings.
Rule 2: never let routing change your output contract
A router that silently substitutes a cheaper model with different behaviour will show up as a quality regression you cannot explain. Two protections:
- Pin capability-critical traffic to a model, not a price band.
- Log which deployment served each request, so a change is a query, not a rumour.
Rule 3: define the retry boundary once
Multi-provider retry is where naive implementations leak money. The rule that holds:
- Retry before first token → safe, no duplicate output.
- Retry after first token → two billable completions and a corrupted stream.
- Never retry 4xx → it is your prompt or schema, not the provider.
Put that in one place — the client — rather than in every call site.
Rule 4: measure cost per task class
A single blended cost figure hides everything useful. Track spend per task class per day:
- classification at $0.0004/request and 30,000 requests
- generation at $0.003/request and 4,000 requests
- reasoning at $0.02/request and 300 requests
That breakdown tells you where to push next. Without it, "the bill went up" is a shrug.
Multi-model patterns that pay
Cheap-first with escalation. Run the flash tier, escalate to a frontier model when a confidence check or schema validation fails. Typical split: 80–90% stays cheap.
Second opinion on expensive decisions. For high-stakes outputs, run two cheap models and compare; escalate only on disagreement. Cheaper than always using the frontier model, more reliable than one cheap model.
Model-per-language or per-domain. Chinese-language extraction, for example, often does better on a GLM-class model than a Western flash tier at the same price.
Scheduled diversity. Route 5% of traffic to an alternate provider continuously, so your failover path is exercised before you need it.
What breaks in production
- Error shapes. Provider-specific 400 bodies crash clients written against the OpenAI schema. Normalise or test.
- Tool-call formats. Parallel tool calls, argument streaming and finish reasons differ subtly across vendors.
- Context window drift. A model name can map to a deployment with a smaller window than the marketing page states.
- Pricing that moves under you. Rates change weekly; effective price should come from your own metering, not from a cached table.
Where these numbers come from
Provider counts and rates referenced here come from the live pricing table; each model page — for example claude-opus-5 or deepseek-flash — shows how many independent suppliers back it. The request schema is defined in OpenAI's chat completions reference, which is what every OpenAI-compatible endpoint mirrors.
For the policy side, what an AI gateway does covers routing decisions in depth, and the routing documentation shows the request shape a multi-model call takes.
FAQ
What is a multi-model API?
A single endpoint that routes requests to several model providers using one request schema. The caller uses one key and one SDK; the gateway handles provider selection, failures and billing.
Is it slower than calling a provider directly?
By roughly one network hop, typically single-digit milliseconds. The routing policy has a larger effect than the hop: sending interactive traffic to a slow cheap deployment costs more latency than the gateway itself.
Can I mix providers per request?
Not within one completion — a request is served by one deployment. You can, however, route different task classes to different providers on one key, and fail over between providers on failure.
Do I still need provider accounts?
With a marketplace, no: it holds the supplier relationships and you hold one API key. With a self-hosted gateway you bring your own keys and own the rotation. Choose by compliance posture, not by feature list.
Every number on this page comes from the marketplace's own live offers. Point the OpenAI SDK at Cisoma and keep your code.
Get 100M free tokens