Blog· Perspectives

All posts

OpenAI API vs an OpenAI-compatible gateway: when to switch and what changes in your code (2026)

2026-08-19 · 4 min readhung-chien · AI Growth & Brand Manager

On this page · 8
  1. 01Short answer
  2. 02What OpenAI's platform already gives you
  3. 03Where direct access stops
  4. 04The code change
  5. 05What one workload costs on six models
  6. 06Migration checklist
  7. 07Related reading
  8. 08FAQs

An OpenAI-compatible API is an endpoint that accepts the same request and response format as OpenAI's API, so the official OpenAI SDK can call it after you change the base URL and the key. This article covers what OpenAI's own platform already controls, the point where a gateway starts to pay off, the exact code change, and what the same workload costs on six models.

Short answer

Stay on the OpenAI API directly if one team uses only OpenAI models and OpenAI's project limits cover your budget rules.

Add an OpenAI-compatible gateway when one of these happens:

  • A second vendor arrives, for example Claude for coding or Gemini Flash for high-volume classification, and finance wants one bill and one set of limits.
  • Several teams share one AI budget and each needs its own ceiling and model list across vendors.
  • You want to compare models on your own prompts without wiring up three SDKs.

What OpenAI's platform already gives you

OpenAI has added most of the controls that used to justify a gateway for a single vendor:

  • Projects to separate, for example, staging and production, with their own keys, rate limits and spend limits (production best practices).
  • Two kinds of spend control. Spend alerts send a notification and traffic continues. Hard spend limits make affected requests return 429 (rate limits guide).
  • A per-project "Model usage" setting that restricts which models a project can call (managing projects).
  • Usage tiers that cap monthly spend until you have paid enough, from $100 a month at Tier 1 to $200,000 at Tier 5.

If all your traffic is OpenAI, use these first.

Where direct access stops

The limits above apply to OpenAI models only. The moment a team adds Claude, Anthropic's Console has its own workspaces, spend limits and keys (Anthropic workspaces). Add Gemini and there is a third console. In practice that means:

  • Three sets of keys to issue and revoke when someone leaves.
  • Three budgets that can't see each other, so "the support bot may spend $3,000 a month across all vendors" can't be enforced anywhere.
  • Three invoices in different formats at month-end.
  • Code split across the OpenAI, Anthropic and Google SDKs.

A gateway puts one set of keys, limits and logs in front of all of them.

The code change

With ATP Token, the OpenAI SDK stays. You change three values (OpenAI SDK guide, migrate from OpenAI):

from openai import OpenAI

# Before: client = OpenAI(api_key="sk-...")
client = OpenAI(base_url="https://api.atptoken.ai/v1", api_key="atp-...")

for model in ["gpt-5.4", "claude-sonnet-4-6", "gemini-3-5-flash"]:
    r = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": "Classify this ticket: 'Refund not received after 10 days'"}],
        max_tokens=200,
    )
    print(model, r.choices[0].message.content, r.usage.total_tokens)

What stays the same: the Chat Completions request body, the response body, streaming with stream=True (OpenAI SSE) and tool definitions.

What changes:

  • Model ids come from GET /v1/models (model discovery). OpenAI models keep familiar names such as gpt-5.4; others use ids like claude-sonnet-4-6 or deepseek-v4-flash.
  • A model that isn't on the project's allowed list returns 403 before it reaches any provider.
  • When the project's credits run out, requests return 402 (errors).
  • ATP's OpenAI-format surface is /v1/chat/completions, /v1/models and /v1/files. If your code calls other OpenAI endpoints, check the API reference before moving those calls.

Teams that use the Anthropic or Google GenAI SDK don't need to switch to the OpenAI format: the same project key works with those SDKs at https://api.atptoken.ai (Anthropic SDK, Google GenAI SDK).

What one workload costs on six models

Take a classification service that handles 1 million requests a month, each with 1,000 input tokens and 300 output tokens. That is 1,000 million input tokens and 300 million output tokens. At the list rates on each model's page:

Model Input / output per 1M tokens Monthly input Monthly output Monthly total
gpt-5.5 $5 / $30 $5,000 $9,000 $14,000
claude-sonnet-4-6 $3 / $15 $3,000 $4,500 $7,500
gpt-5.4 $2.5 / $15 $2,500 $4,500 $7,000
gemini-3-5-flash $1.5 / $9 $1,500 $2,700 $4,200
claude-haiku-4-5 $1 / $5 $1,000 $1,500 $2,500
deepseek-v4-flash $0.2 / $0.4 $200 $120 $320

Price is half of the decision. Run a few hundred of your real tickets through the two or three cheapest models that pass your quality bar before you switch. The side-by-side pages for DeepSeek vs Claude and Gemini vs GPT are a starting point.

Migration checklist

  1. List every place your code creates an OpenAI client and which endpoints it calls.
  2. Create one ATP project per service and enable only the models that service needs (workspaces and projects).
  3. Allocate credits to each project; the allocation is the ceiling (budget caps).
  4. Issue one key per project and store it in your secret manager (managing keys).
  5. Change base URL, key and model id in staging. Compare outputs and token counts in Request logs (usage and logs).
  6. Move production one service at a time, then revoke the old OpenAI keys you no longer use.

Start with the quickstart

OpenAI-compatible APIOpenAI APIATP

FAQs

What is an OpenAI-compatible API?

It is an API that accepts the same request and response format as OpenAI's, usually the Chat Completions endpoint. The official OpenAI SDK works against it once you change the base URL and API key.

Can I call Claude or Gemini with the OpenAI SDK?

Yes, through an OpenAI-compatible gateway. On ATP Token you set base_url to https://api.atptoken.ai/v1, use a project key, and pass a model id such as claude-sonnet-4-6 or gemini-3-5-flash.

Does OpenAI let me limit spend per project?

Yes. OpenAI projects can have spend alerts, which notify but let traffic continue, and hard spend limits, which make affected requests return 429. Projects can also restrict which models they use.

What is the best OpenAI API alternative?

For model quality, the usual alternatives are Anthropic's Claude, Google's Gemini and open-weight models such as DeepSeek or Qwen. To use several without rewriting code, call them through an OpenAI-compatible gateway.

Do I have to rewrite my code to use an OpenAI-compatible gateway?

Usually not for Chat Completions. You change the base URL, the key and the model id. Check any other OpenAI endpoints your code uses against the gateway's API reference first.
Get started

One key, and every model call has a record

Project-scoped API keys, model allowlists, per-request logs, and pay-as-you-go credits — start with a five-dollar top-up.