Guide · 4 min read

Unified AI API: Connect Apps to Multiple Models

A unified AI API can simplify application integration. Learn about compatible endpoints, model routing, and provider tradeoffs.

In this guideWhat a unified AI API is, the problems it solves, what it can't hide, and how to design your app so that changing models is a one-line change.

The problem it solves

Each model maker has its own account, billing, keys, rate limits, SDK and request format. A product that uses one model from each of three companies has three of everything. Trying a fourth means another sign-up, another payment method and another integration.

A unified AI API puts one interface in front of all of them. You get one base URL, one API key and one bill, and you choose the model by changing a name in the request. Nothing else in your code moves.

How it works

A unified API is a service that accepts requests in a standard format, works out which provider serves the model you named, forwards the request with its own credentials, and returns the answer in the same standard format. Along the way it records the tokens used and charges your balance.

Python
from openai import OpenAI

client = OpenAI(base_url="https://cheaptokens.pw/v1", api_key="YOUR_API_KEY")

for model in ["gpt-6-luna", "claude-haiku-5-5", "deepseek-v4-pro"]:
    reply = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": "Summarise this in one line: ..."}],
    )
    print(model, "→", reply.choices[0].message.content)

The loop above talks to three different companies' models. The only thing that changes between them is the model name.

Which formats matter

"Unified" usually means "OpenAI-compatible", because that format is what most tools already speak. In practice three formats cover nearly everything:

FormatUsed byNotes
OpenAI Chat CompletionsMost SDKs, editors and agentsThe common denominator. Works with every text model.
OpenAI ResponsesCodex and newer OpenAI toolsRequired by some tools that no longer speak Chat Completions.
Claude MessagesClaude Code and Anthropic SDKsThe native format for Claude tools.

A unified API that offers all three lets each tool use the format it was built for, on the same key. CheapTokens does this; the docs list which models support which format.

What you gain

What it can't hide

One format does not make all models the same. These differences remain, and your app should expect them:

The tradeoffs

A unified API is an extra party between you and the model. That has real costs, and it is better to weigh them than to ignore them:

Designing your app for it

  1. Keep the base URL, key and model name in configuration. Never in code.
  2. Wrap model calls in one function. Everything else in your app calls that function, so a change of model or provider happens in one place.
  3. Choose models by task. Name the tasks ("classify", "draft", "review") and map each to a model in configuration.
  4. Keep a small test set. Twenty to fifty real prompts with known good answers. Run it whenever you change a model.
  5. Handle errors by type. Retry rate limits and outages with a delay; never retry an invalid request.
  6. Record cost per task. Usage comes back with every response. Log it next to the feature that caused it.

Is it right for you?

A unified API suits you if you use, or want to try, more than one model; if you want one bill and one key; or if you want a lower price than list. It suits you less if you depend on a provider's newest experimental features the day they launch, or if a contract requires your data to go to one named provider only.

To try it, create a CheapTokens account, pick models on the models page, and use the setup wizard to connect your tools.

Create a CheapTokens account ↗

Related guides