One API key for GPT, Claude and Gemini: how a unified AI API works
Call GPT, Claude, Gemini, DeepSeek and Kimi with one key and one OpenAI-compatible endpoint: how it works, what it costs and the code to start.
On this page 8 sections
Yes: you can call GPT, Claude, Gemini, DeepSeek, Kimi and hundreds of other models with one API key. thelastapi runs an OpenAI-compatible gateway at /v1/ai: you keep the OpenAI SDK you already use, change the base URL, and pick a model by id. One key, one bill, one place to see what each call cost, and the model you name is exactly the model that runs.
This guide explains how a unified AI API works, what to check before you trust one, and the code to get started.
Why one key instead of four accounts
Building with more than one lab usually means an account, a key, a billing page and a slightly different SDK per lab. That is fine for one experiment and painful for a product:
- Keys multiply. Every environment (your laptop, CI, production, a teammate's agent) needs each lab's key, and each one is a secret to rotate.
- Bills scatter. Spend lives in four dashboards with four currencies of "credits", so "what did this feature cost last week?" takes an afternoon.
- Switching is a refactor. Moving a feature from one model to another means a new client, new error shapes and new streaming code.
A unified API puts one interface in front of all of them. With thelastapi it is the OpenAI chat completions shape, which most SDKs, agents and frameworks already speak.
How it works
The gateway accepts the OpenAI request format and answers in it, for chat (streaming or not, with tools and JSON mode), embeddings, images, speech and transcription. You choose the model in the model field, in one of two ways:
- A thelastapi model, named for what it is for. Each one runs one named lab model, listed in the docs and in every answer:
| thelastapi model | Runs on | Good for | Price per million tokens (in / out) |
|---|---|---|---|
vibiz/fast | GPT-6 Luna (OpenAI) | chat, tool calls, JSON | $0.10 / $0.50 |
vibiz/lite | DeepSeek V4.1 Flash | the cheapest chat, 1M context | $0.14 / $0.42 |
vibiz/balanced | Gemini 3.8 Flash (Google) | quality and price balanced | $0.825 / $4.125 |
vibiz/smart | Claude Sonnet 5.5 (Anthropic) | writing, coding, agents | $2 / $10 |
vibiz/pro | Claude Opus 5.5 (Anthropic) | the strongest tier | $4 / $20 |
- Any lab's model by its own id, such as
anthropic/claude-opus-5.5ormoonshotai/kimi-k3.1-pro. Over 400 language models from OpenAI, Anthropic, Google, DeepSeek, xAI, Moonshot AI, Qwen, Mistral, Meta and more are callable this way. A typo can't reach an expensive model by accident: an id that isn't in the catalogue answers400 invalid_requestwithparam: "model".
Either way, exactly that model runs. If it is down, you get model_unavailable or provider_unavailable with a retry hint, never a quiet swap to something else. Every JSON answer names the model that ran (served_model) and what the call cost (cost_micro_usd).
The code
Create a project with AI, or add AI to an existing one:
vibiz init "Acme Support" --resources ai
vibiz dev # writes the development env, including the AI key, to .env.development.localThe app's env gets VIBIZ_AI_BASE_URL and VIBIZ_AI_API_KEY, plus the aliases OPENAI_BASE_URL and OPENAI_API_KEY, so the OpenAI SDK works without changes:
import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: process.env.VIBIZ_AI_BASE_URL,
apiKey: process.env.VIBIZ_AI_API_KEY,
});
// The same client, three labs.
for (const model of ['vibiz/fast', 'anthropic/claude-opus-5.5', 'vibiz/balanced']) {
const res = await openai.chat.completions.create({
model,
messages: [{ role: 'user', content: 'Name a bakery in three words.' }],
});
console.log(model, '→', res.choices[0]?.message.content);
}A running app that already uses @vibiz/app can skip the env names entirely: new OpenAI(vibiz.ai) gets the base URL and key from the app's one key, VIBIZ_APP_KEY.
From a terminal, the CLI streams an answer and prints what it cost:
vibiz ai "Summarise this changelog in one line" --model vibiz/smart
vibiz ai models kimi # search every model you can call, with pricesAnd with plain HTTP, from any language:
curl https://thelastapi.dev/v1/ai/chat/completions \
-H "Authorization: Bearer $VIBIZ_API_KEY" -H 'content-type: application/json' \
-d '{"model":"vibiz/fast","messages":[{"role":"user","content":"Hi"}]}'What to check before you trust a unified API
Not every gateway behaves the same way. Four questions worth asking of any of them:
Does it ever run a different model than the one you asked for? Some gateways fall back to another model when one is busy. That keeps a demo alive, but it changes your product's behaviour and cost without telling you. thelastapi fails instead, and says why.
Can you see the cost of each call? Per-call cost in the response (cost_micro_usd) beats a monthly total. It lets you log cost next to the feature that spent it. vibiz usage --by model and the console's Usage page break spend down by model, project, key or end user.
Can you cap spend where it matters? An account-wide daily ceiling ($5 a day by default, raised by the owner in Billing), a daily budget per project ($1 by default) and a budget per end user, all answering 429 with a details.reason you can show. See per-user AI budgets.
Can you leave? Because the interface is the OpenAI one, leaving means changing a base URL back. Nothing in your code is specific to the gateway unless you choose the extra fields.
Images, voice and video on the same key
The same key reaches media models: vibiz/image (Nano Banana 2) and vibiz/image-text (GPT Image) for pictures, vibiz/voice for text to speech, vibiz/transcribe for speech to text, and vibiz/video for six-second clips. Every file you generate is saved in the project's Files with a permanent link. More in one API for image, video and voice models.
Already paying Google?
Add your own Google key and Google's models (vibiz/balanced, vibiz/image, any google/… id) run on your Google account at no charge here, while other labs' models stay on thelastapi. If your key fails, the call fails: it is never retried on our account behind your back. See using your own Gemini key.
Limits worth knowing
max_tokensis 1,024 when you don't set it, at most 16,384.- An account key gets 300 requests and 400k tokens a minute; a project key 120 requests and 200k tokens a minute, which the owner can raise.
- Errors keep the OpenAI shape, so OpenAI SDKs read them:
rate_limited(429) carries the reason (daily_spend,project_budget,requests_per_minute…), and a mid-stream error arrives as a final SSE event.
Next: switch an existing Python app over in how to use Claude with the OpenAI Python SDK, or compare prices in GPT vs Claude vs Gemini API pricing. The full reference is on the AI docs page.
Frequently asked questions
Can I really call Claude and Gemini with the OpenAI SDK?
Yes. thelastapi's AI gateway is OpenAI-compatible under /v1/ai, so you keep the OpenAI SDK (Python, Node or anything that speaks the same HTTP), point its base URL at the gateway and pass a model id such as anthropic/claude-opus-5.5 or vibiz/balanced, which runs Gemini 3.8 Flash.
What happens if the model I asked for is down?
The call fails with model_unavailable or provider_unavailable and a retry hint. The gateway never swaps in a different model, so you never pay for, or ship answers from, a model you did not choose.
How is a call priced?
At the lab's list price plus the AI fee shown on each model in GET /v1/ai/models. Every JSON response carries cost_micro_usd, the exact cost of that call, and served_model, the model that actually ran.
Do I need an account with each lab?
No. One thelastapi key reaches every major lab's language models, over 400 of them. If you already pay Google, you can add your own Google key and Google's models run on it at no charge here.
How do I stop a runaway bill?
Each account has a daily spend ceiling ($5 by default) and each project a daily AI budget ($1 by default), and you can cap spend per end user. Past a limit, calls answer 429 with the reason, instead of quietly running up a bill.