thelastapi
Get started free

How to access multiple AI models with a single API

Access GPT, Claude, Gemini, DeepSeek, and 400+ AI models using a single OpenAI-compatible API key and base URL with thelastapi.

On this page 7 sections

You can call GPT, Claude, Gemini, DeepSeek, Kimi, and over 400 other language models using a single OpenAI-compatible endpoint and one API key. Through thelastapi's gateway at https://thelastapi.dev/v1/ai, you keep your existing OpenAI client library, change the base URL, and pass whichever model identifier you want. You get one unified bill, clear per-call costs, and exact model execution without silent fallbacks.

If you are already running an integration, check one API key for GPT, Claude and Gemini: how a unified AI API works to see how routing operates under the hood.

Why use a unified gateway instead of separate accounts?

Integrating models directly from multiple AI labs introduces maintenance friction:

  • Key sprawl: Managing separate secret keys for OpenAI, Anthropic, Google, and others across local machines, continuous integration, and production servers increases administrative burden.
  • Fragmented billing: Tracking token usage across different lab dashboards makes cost attribution tedious.
  • Incompatible SDKs: Each provider maintains its own client library, custom error payloads, and streaming conventions. Switching models across labs often requires refactoring code.

A unified API standardizes these interactions into the OpenAI format. Whether you use the official OpenAI SDK, @ai-sdk/openai, or raw HTTP requests, the integration pattern remains identical.

Selecting a model: shorthand tiers vs. direct lab IDs

When sending a request, the model field accepts two naming schemes.

1. thelastapi shorthand tiers

These are stable tier names mapped to specific models. Each tier runs one lab model, which is named in the documentation and in the served_model field of every response:

thelastapi tierUnderlying modelPrimary usePrice per million tokens (in / out)
vibiz/fastGPT-6 Luna (OpenAI)Chat, tool calls, JSON mode$0.10 / $0.50
vibiz/liteDeepSeek V4.1 Flash (DeepSeek)Low-cost chat, 1M context$0.14 / $0.42
vibiz/smart-miniClaude Haiku 5.5 (Anthropic)Fast coding and writing$0.10 / $0.50
vibiz/balancedGemini 3.8 Flash (Google)Balanced quality, 1M context$0.825 / $4.125
vibiz/reasoningGPT-6.1 Terra (OpenAI)Math, logic, planning$1 / $5
vibiz/smartClaude Sonnet 5.5 (Anthropic)Writing, coding, agent tasks$2 / $10
vibiz/proClaude Opus 5.5 (Anthropic)Complex reasoning, long agent runs$4 / $20

2. Direct lab model identifiers

You can call any supported model directly by its lab ID. Over 400 language models are available from OpenAI, Anthropic, Google, DeepSeek, xAI, Moonshot AI, Qwen, Mistral, Meta, and others. For example, you can target moonshotai/kimi-k3.1-pro (read more in Kimi API access: call Moonshot AI models with an OpenAI client) or anthropic/claude-opus-5.5.

If a model is unavailable, the API returns a 503 status code (model_unavailable or provider_unavailable). The gateway never quietly swaps in a different model.

Setting up your project and environment

You can initialize a project using the vibiz CLI:

Terminal
vibiz init "Multi-Model App" --resources ai
vibiz dev

The vibiz dev command writes your development keys into .env.development.local. This file sets VIBIZ_AI_BASE_URL and VIBIZ_AI_API_KEY, along with their aliases OPENAI_BASE_URL and OPENAI_API_KEY. Learn more about these configurations in the Keys and environments guide.

If you have an existing application, add AI resources directly:

Terminal
vibiz add ai

Calling multiple models with code

Because the gateway uses the OpenAI chat completions schema, switching models only requires updating the model string.

Using the OpenAI TypeScript SDK

TypeScript
import OpenAI from 'openai';

const openai = new OpenAI({
  baseURL: process.env.VIBIZ_AI_BASE_URL,
  apiKey: process.env.VIBIZ_AI_API_KEY,
});

const modelsToTest = [
  'vibiz/fast',
  'anthropic/claude-opus-5.5',
  'vibiz/balanced',
  'moonshotai/kimi-k3.1-pro',
];

for (const model of modelsToTest) {
  const completion = await openai.chat.completions.create({
    model,
    messages: [{ role: 'user', content: 'Explain latency in one sentence.' }],
  });

  console.log(`[${model}]`);
  console.log(completion.choices[0]?.message.content);
}

If your project uses @vibiz/app, you can pass vibiz.ai directly to the constructor without configuring custom environment variable strings:

TypeScript
import OpenAI from 'openai';
import { vibiz } from '@vibiz/app';

const openai = new OpenAI(vibiz.ai);

Using HTTP requests

You can also send standard JSON payloads to the gateway via HTTP:

Terminal
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": "Hello!"}]
  }'

For real-time responses, set "stream": true. See streaming chat completions with server-sent events through one API for implementation details.

Inspecting models from the terminal

You can query the catalog and stream completions directly from the command line:

Terminal
# Search available models and view token prices
vibiz ai models kimi

# Stream a completion directly to stdout
vibiz ai "Summarize the latest release notes" --model vibiz/smart

Budget controls, spending limits, and tracking

To prevent runaway billing from automated loops or high traffic, the platform enforces daily spend protections. Details can be found in Usage and limits and Billing and credits.

  • Daily safety cap: Accounts default to a $5 per UTC day safety limit across AI and actions. Owners can adjust this in the console or by sending a request:
    Terminal
    vibiz billing limit 50
  • Project budget: Projects default to a $1 daily AI budget. When this cap is met, the gateway returns a 429 status code with details.reason: "project_budget".
  • Per-call costs: Every JSON response includes cost_micro_usd, which reports the exact cost of that call in micro-USD, along with the served_model.
  • Usage tracking: You can pass an internal end-user identifier using the user body parameter (or X-Vibiz-User header) to monitor consumption per user:
    Terminal
    vibiz usage --by model
    vibiz usage --by end_user --project prj_123

Using your own provider keys

If you maintain existing credits with Google Cloud, you can route Google-hosted models directly through your personal credentials at zero platform cost.

Run the following command to store your Gemini key:

Terminal
GEMINI_API_KEY=your_key_here vibiz ai keys set google

When configured:

  • Calls to google/* models and Google-backed tiers (vibiz/balanced, vibiz/image, vibiz/image-pro) run directly on your key.
  • thelastapi charges $0 for those calls, and the response marks "paid_by": "your_key".
  • If your Google key is invalid or rejected by Google, the request fails with customer_key_rejected or provider_unavailable. It never silently falls back to thelastapi's accounts.
  • Other models (such as OpenAI or Anthropic tiers) continue running on thelastapi's unified billing.

If you are evaluating automated coding assistants, see can you use Claude Code with other models? What a gateway can and cannot do.

To get started, explore the full route catalog on the AI docs page or create your account at thelastapi.dev/start.

Frequently asked questions

What happens if an AI model provider experiences downtime?

The gateway returns a 503 error code with `model_unavailable` or `provider_unavailable` and a retry suggestion. It will never silently substitute a different model than the one requested.

Can I use image, audio, and video models with the same setup?

Yes. The same endpoint and credentials support image generation (`vibiz/image`, `vibiz/image-text`), speech generation (`vibiz/voice`), transcription (`vibiz/transcribe`), and video (`vibiz/video`).

How do spending limits work if an agent sends too many requests?

Accounts include a default safety cap of $5 per UTC day, and projects default to a $1 daily AI budget. Once reached, calls return a 429 status code with the specific limit named in `details.reason`.

What are the request and token rate limits for AI calls?

An account key allows 300 requests and 400,000 tokens per minute (50 concurrent calls), while a project key defaults to 120 requests and 200,000 tokens per minute (25 concurrent calls).

Do responses show how much each specific completion cost?

Yes. Every JSON chat response includes `cost_micro_usd` indicating the exact charge for that invocation, along with the `served_model` string.