OpenAI-compatible API for Claude and Gemini: change one base URL
Point your OpenAI client to https://thelastapi.dev/v1/ai to run Claude and Gemini models alongside GPT using one base URL and a single API key.
On this page 7 sections
You can call Claude, Gemini, and GPT through an OpenAI-compatible endpoint simply by setting your base URL to https://thelastapi.dev/v1/ai and using a single thelastapi key. You keep your existing OpenAI SDK client, agent frameworks, or raw HTTP requests without changing message schemas or installing lab-specific packages. Every request executes against the exact model you select, returning standard OpenAI chat completion shapes alongside per-call cost tracking.
Switching between AI providers usually requires juggling separate accounts, distinct client libraries, scattered credit balances, and incompatible message structures. Using a unified gateway removes that friction. To learn more about how one key spans labs, see how a unified AI API works.
How to configure the OpenAI SDK for Claude and Gemini
To call Anthropic's Claude or Google's Gemini models with the official OpenAI SDK, update two values: the base URL and the API key.
When you set up a project using the CLI:
vibiz init "Acme Support" --resources ai
vibiz devThe CLI writes your development environment to .env.development.local. This injects VIBIZ_AI_BASE_URL (which points to https://thelastapi.dev/v1/ai) and VIBIZ_AI_API_KEY. It also injects the environment aliases OPENAI_BASE_URL and OPENAI_API_KEY. Because those aliases are set, standard OpenAI SDK initializations work without passing manual options.
If you pass configuration directly in TypeScript or Node.js:
import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: process.env.VIBIZ_AI_BASE_URL,
apiKey: process.env.VIBIZ_AI_API_KEY,
});
async function main() {
// Call Claude Sonnet 5.5
const claudeResponse = await openai.chat.completions.create({
model: 'vibiz/smart',
messages: [{ role: 'user', content: 'Draft a three-bullet project update.' }],
});
console.log('Claude:', claudeResponse.choices[0]?.message.content);
// Call Gemini 3.8 Flash
const geminiResponse = await openai.chat.completions.create({
model: 'vibiz/balanced',
messages: [{ role: 'user', content: 'Summarize the release notes in one sentence.' }],
});
console.log('Gemini:', geminiResponse.choices[0]?.message.content);
}
main();If your project already uses @vibiz/app, you do not need to configure separate environment variables. Passing vibiz.ai directly to new OpenAI() provides the required base URL and authentication automatically:
import OpenAI from 'openai';
import { vibiz } from '@vibiz/app';
const openai = new OpenAI(vibiz.ai);For more language setups and client patterns, see our guide on how to call Claude and Gemini from the OpenAI Node.js SDK and how to use @ai-sdk/openai with Claude, Gemini and more.
Which Claude and Gemini models can you call?
The gateway offers two ways to address models: functional alias names and direct provider IDs.
Functional names provide stable targets for your application code. Each tier runs a specific model from a major lab:
| Model name | Runs on | Best suited for | Price per million tokens (in / out) |
|---|---|---|---|
vibiz/fast | GPT-6 Luna (OpenAI) | Fast chat, tool calls, structured JSON | $0.10 / $0.50 |
vibiz/smart-mini | Claude Haiku 5.5 (Anthropic) | Quick, strong writing and coding | $0.10 / $0.50 |
vibiz/balanced | Gemini 3.8 Flash (Google) | Balanced quality, price, 1M context | $0.825 / $4.125 |
vibiz/smart | Claude Sonnet 5.5 (Anthropic) | Writing, coding, agent workflows | $2 / $10 |
vibiz/pro | Claude Opus 5.5 (Anthropic) | Complex chat, deep tasks, long agents | $4 / $20 |
vibiz/lite | DeepSeek V4.1 Flash | High-volume chat, 1M context | $0.14 / $0.42 |
vibiz/reasoning | GPT-6.1 Terra (OpenAI) | Step-by-step logic, math, planning | $1 / $5 |
You can also reference any model directly by its lab ID. Over 400 language models from OpenAI, Anthropic, Google, DeepSeek, Moonshot AI, xAI, Qwen, Mistral, and Meta are accessible:
const response = await openai.chat.completions.create({
model: 'anthropic/claude-opus-5.5',
messages: [{ role: 'user', content: 'Explain distributed consensus.' }],
});To search available models and current rates from your command line:
vibiz ai models claude
vibiz ai models geminiOr query the catalog via HTTP:
curl https://thelastapi.dev/v1/ai/models -H "Authorization: Bearer $VIBIZ_API_KEY"Making raw HTTP calls or terminal queries
Because the gateway supports the OpenAI spec at /v1/ai/chat/completions, any language with HTTP capabilities can execute calls to Claude and Gemini.
Here is a standard streaming call to Claude using curl:
curl https://thelastapi.dev/v1/ai/chat/completions \
-H "Authorization: Bearer $VIBIZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "vibiz/smart",
"messages": [{"role": "user", "content": "Write a greeting in Spanish."}],
"stream": true
}'Every response body or stream includes standard completion fields plus two operational fields:
served_model: The exact lab model that processed your tokens.cost_micro_usd: The exact call cost calculated down to one-millionth of a dollar.
From the terminal, test prompts quickly without writing code:
vibiz ai "Summarize our quarterly goals in three sentences" --model vibiz/balancedWhy strict routing matters
Some third-party proxies silently divert traffic to alternate models when an upstream provider experiences elevated latency or outages. That behavior breaks deterministic outputs, disrupts system prompts designed for specific prompt formats, and introduces unexpected pricing changes.
thelastapi never swaps models. If Anthropic or Google is unreachable, the API returns a structured error:
model_unavailable(503): No route can process the requested model right now. The response details includeretry_after_seconds.provider_unavailable(503): Upstream connectivity failed due to timeouts or circuit breakers.
All errors match the standard OpenAI format:
{
"error": {
"code": "model_unavailable",
"message": "Model is temporarily unreachable.",
"type": "provider_error",
"param": null,
"details": {
"retry_after_seconds": 15
}
}
}If you request a model name that does not exist in the catalog, the gateway returns 400 invalid_request with param: "model". You will never be charged for an accidental fallback model.
Connecting your own Gemini API key
If you maintain Google Cloud credits or prefer direct billing with Google, you can attach your own Google credentials. Google's models will run through your Google account at zero cost on thelastapi.
Set your Gemini key through the CLI:
GEMINI_API_KEY=your_key_here vibiz ai keys set googleOr use the HTTP endpoint:
curl -X PUT https://thelastapi.dev/v1/ai-keys/google \
-H "Authorization: Bearer $VIBIZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "gemini_api_key", "api_key": "your_key_here"}'When configured:
- Calls to Google models (
vibiz/balanced,vibiz/image, or direct IDs likegoogle/gemini-4-argon) run on your key. - The response returns
"paid_by": "your_key"and listswould_cost_micro_usdto display what the call would have cost. - Other lab models (like Claude Sonnet or GPT models) continue executing through thelastapi prepaid credits as normal.
- There is no silent fallback. If your Google key is revoked or Google's API fails, the gateway returns an error (
provider_failedwithcustomer_key_rejected). It will never charge your thelastapi balance behind your back.
Verify your attached key status at any time:
vibiz ai keys
vibiz ai keys test googleBudgets, spend caps, and token limits
Calling multiple frontier models in production requires guardrails against looping scripts and unexpected spikes.
Each thelastapi account includes safety controls built into the core router:
- Daily spend limit: Set to $5 per account per UTC day by default across all AI calls. You can view or change this via
vibiz billing limit <dollars>or in Billing settings. - Project AI budget: Defaults to $1 per project per UTC day. Adjust it using
vibiz ai budget <dollars> --project prj_123. - Per-user attribution: Pass your user's pseudonymous identifier in the
userfield of your chat completion request (or theX-Vibiz-Userheader). Spend tracks by end user, allowing you to setend_user_daily_budget_usd. - Limit alerts: Account owners receive email notifications at 80% and 100% of daily caps, complete with a direct URL to adjust limits.
- Context handling: By default,
max_tokensis 1,024 when omitted, with a maximum of 16,384 tokens depending on the model. Some models, such as Claude Haiku 5.5 past 100,000 input tokens or GPT-6 past 272,000 tokens, apply long-context rates as documented in the model catalog.
Review token usage and costs grouped by model from the CLI:
vibiz usage --period 7d --by modelTo get started, review full specifications on the AI docs page, manage your credentials on Keys and environments, or read about spend controls on Billing and credits and Usage and limits. Create your account at thelastapi.dev/start to get started.
Frequently asked questions
Can I use tool calling and JSON mode with Claude and Gemini through this gateway?
Yes. The gateway translates standard OpenAI tool definitions, tool calls, and JSON response formats across supported Claude and Gemini models.
What happens if Anthropic or Google suffers an outage?
The gateway returns a `503 model_unavailable` or `503 provider_unavailable` error with a `retry_after_seconds` hint. It will never silently substitute a different model for the one you specified.
How does authentication work when calling models from different labs?
You authenticate using a single thelastapi API key (either your project AI key or account key) passed as a standard Bearer token to `https://thelastapi.dev/v1/ai`.
Can I stream responses from Claude and Gemini?
Yes. Setting `"stream": true` returns standard Server-Sent Events (SSE) data chunks, and any mid-stream failure delivers a structured JSON error event before closing the connection.