Moving an existing OpenAI integration to one endpoint

The good news about migrating off the OpenAI API is that the OpenAI wire format won. Most of the ecosystem speaks it, so a gateway that accepts it means your client code largely does not change You change where it points and what it is allowed to ask for.

Three fields, in practice: the base URL, the key, and the model IDs.

You need a key before the code below runs. Create an account, generate a key, and copy the base URL (https://aicomp.ai/v1). Create one free →
Check current rates → Free to sign up · $1 minimum top-up · No prepayment

Before: what an OpenAI call looks like

Don't have an account yet? You need an API key from the gateway before the steps below will work — how the discount works and what you take on. Create one free → (no prepay, $1 minimum top-up)
from openai import OpenAI

client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

r = client.chat.completions.create(
    model="gpt-5",
    messages=[{"role": "user", "content": "Summarise this"}],
)

After: the same call through one endpoint

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["GATEWAY_KEY"],          # one credential
    base_url="https://aicomp.ai/v1",            # one destination
)

r = client.chat.completions.create(
    model="gpt-5",                              # same model ID
    messages=[{"role": "user", "content": "Summarise this"}],
)

That is the whole diff for the common case. The SDK, the method names, the message shape, and the response object are unchanged, because the endpoint speaks the same protocol.

// Same change in Node
import OpenAI from "openai";
const client = new OpenAI({
  apiKey: process.env.GATEWAY_KEY,
  baseURL: "https://aicomp.ai/v1",
});

What actually changes

Model IDs. Your endpoint serves what it serves, which is not the same list as one vendor's. Pull it rather than assume it:

curl -s https://aicomp.ai/v1/models -H "Authorization: Bearer $GATEWAY_KEY" \
  | jq -r '.data[].id'

Anything you request that is not on that list returns model_not_found, and vendor APIs do not fuzzy-match, so a near miss is a failure rather than a substitution.

What is available under one key. This is the part that changes what you can build. Instead of one vendor's catalogue, the same credential reaches models from several vendors, so a fallback or a per-task model choice becomes a string change rather than a second integration.

Where the bill comes from. Spend that was spread across vendor dashboards becomes one line, attributable per model.

What does not change

Worth being explicit, because migrations are often oversold:

Prove traffic actually moved

This is the step people skip, and it is the only one that catches the dangerous failure. If the base_url override does not take effect. An environment variable the process never saw, a config that reads at startup, a default that wins (requests still succeed). They just go to the vendor. Tasks complete, nothing errors, and the migration silently did not happen.

# Send one deliberate request, then confirm it arrived
curl -s https://aicomp.ai/v1/chat/completions \
  -H "Authorization: Bearer $GATEWAY_KEY" -H "Content-Type: application/json" \
  -d '{"model":"gpt-5","messages":[{"role":"user","content":"ping"}],"max_tokens":8}'

Then check the endpoint's request log for that call. A 200 response proves the key works; the log entry proves the traffic is going where you think. Those are different claims and only the second one is the migration.

Rollback

Keep the old configuration in place rather than deleting it. Because the change is two fields, rollback is restoring them, no code path to unwind, no data to migrate back. That is a property of this specific migration and worth using: run both for a day, compare, then remove the old one.

What it costs once you are there

A day of ordinary application traffic — a few hundred thousand input tokens and a smaller volume of output: A day of work on this page's workload is 200k input and 50k output tokens — 4M input and 1M output across a 20-day month.

Per 1M input / output tokens
ModelGateway rate
in / out per 1M tokens
One day20 days
gpt-5$0.625 / $5.00$0.38$7.50
claude-sonnet-5$1.00 / $5.00$0.45$9.00
deepseek-v4-flash$0.15 / $0.60$0.06$1.20
gemini-3.7-flash$0.375 / $1.875$0.17$3.38
glm-5.3$0.70 / $2.2$0.25$5.00

One day = 200k input + 50k output on this page's workload. 20 days = 4M input and 1M output. Rates checked 2026-10-27 (gateway rates move with upstream promotions), so verify the current number in your dashboard before committing to a budget.

The interesting column is not the cheapest row, it is that the same credential can reach all of them, so per-task model choice stops being an integration project.

Get API access

FAQ

FAQ

Do I have to rewrite my application?

Almost never. The gateway speaks the OpenAI wire format, so the SDK, method names, and message shapes stay as they are. You change the base URL, the key, and whichever model IDs you request.

Will my prompts still work?

Prompt behaviour is a property of the model, not the endpoint. Same model ID means the same behaviour. Switching models is a separate decision from switching endpoints, and worth doing deliberately with your own evals.

Can I keep using the OpenAI SDK?

Yes. Both examples above use it — only base_url and api_key change. That is the point of targeting an OpenAI-compatible endpoint rather than a new protocol.

How do I know the migration worked?

Send a request and confirm it appears in the endpoint's request log. A successful response only proves your credential is valid; the log entry proves the traffic went through the gateway rather than falling back to the vendor.

Is it safe to run both during the switch?

That is the recommended pattern. Because the change is two fields, running both costs nothing and lets you compare before removing the old configuration. Delete the old path only after the log confirms traffic is arriving where you intend.

Related

Get API access

Rate cards: GPT and Claude