---
name: vibiz-ai
description: Use AI models through thelastapi - chat with GPT, Claude, Gemini, Kimi, DeepSeek and every major lab's models by id, generate images (Nano Banana, GPT Image) or edit a photo (image_url), make videos (or animate a photo), run any image or video model by its id on credit (Kling, Seedance, Veo, face swap, lip sync, upscalers), text to speech and transcription, from an agent (MCP tools, CLI) or from an app with one key (OpenAI-compatible, new OpenAI(vibiz.ai)) - with per-call prices, the daily spend ceiling, project budgets and the account's own Google or fal key. Use when an app needs an LLM, images, video or voice, when you need to generate or edit an image, a video or audio for a project, when someone asks for a specific image/video model, or someone asks what a model costs or which models they can call.
---

# thelastapi AI

**Connect first.** Not logged in (a tool answers `unauthorized` with `reason: not_logged_in`, or the CLI says "Not logged in")? Run `npx @vibiz/cli login`: show the person the link it prints and ask them to click Authorize (their account is opened on the way if they have none), then go on. Or connect the remote MCP server, nothing to install: `claude mcp add --transport http vibiz https://thelastapi.dev/mcp` (the client opens the same sign-in on first use). Never ask the person to paste a key into the chat. **Keep the CLI current:** a command named here that your `vibiz` doesn't have (an unknown-command or usage error) means the CLI is out of date, not that thelastapi can't do it: run `npm install -g @vibiz/cli@latest` (or `npx -y @vibiz/cli@latest <command>`) and retry, and refresh these skills with `vibiz skills add --global`. Never tell the person something isn't possible because an old CLI lacks the command.

One metered, OpenAI-compatible gateway (`/v1/ai`) for chat, embeddings, images, video, speech and transcription. A **thelastapi model** names what it is for and runs exactly one lab model; any lab model also runs by its own id. thelastapi never swaps in another model: if that one is down, the call fails (`model_unavailable` / `provider_unavailable`).

## Before you start

- **It costs money.** Every call is billed from the account's prepaid credits at the lab's list price plus the AI fee (`markup_pct` on each model, 10% today), and reports what it cost (`cost_usd` on the tools, `cost_micro_usd` over HTTP). Check `vibiz_usage` before a batch: it shows today's spend against the daily ceiling ($5 per account per UTC day by default, AI and web data together; the owner raises it in Billing).
- Bill a project, not the account, when the work is for one: pass `project_id` (from `./vibiz.json`). The project's AI budget then applies, and generated media is kept in its Files with a permanent link (without a project, media links last 24 hours).
- Prices change as labs ship models: `vibiz_ai_models` (or `vibiz ai models`) lists the thelastapi models, the lab model each runs and its price; with a `query` (`"claude opus"`, `"kimi"`) or `all: true` it searches every model you can call (over 400). It is free.

## From an agent

| Want | MCP tool | CLI |
| --- | --- | --- |
| An answer from a model | `vibiz_ai_chat { prompt, system?, model?, max_tokens? (1024, ≤8192), json?, project_id? }` | `vibiz ai "<prompt>" [--model m] [--system s]` |
| Images | `vibiz_image_generate { prompt, size? ("1024x1024"), n? (≤4), model?, project_id?, write_to? (.png) }` | `vibiz image "<prompt>" -o out.png [--size …] [--model m]` |
| Speech (mp3) | `vibiz_speech_create { text (≤4,096 chars), voice?, model?, project_id?, write_to? (.mp3) }` | `vibiz say "<text>" -o out.mp3 [--voice alloy]` |
| A transcript | `vibiz_speech_transcribe { path, language?, model?, project_id? }` (local audio up to 25 MB) | `vibiz transcribe <file> [--language en]` |
| Find a model and its price | `vibiz_ai_models { query?, all? }` | `vibiz ai models [words] [--all]` |

CLI AI commands bill the account, or the project with `--project <id>`. On the remote MCP server `vibiz_speech_transcribe` and `write_to` can't read or write your files: run the CLI command instead. Voices: alloy, ash, coral, echo, fable, nova, onyx, sage, shimmer. `max_tokens × the price` is held against the daily ceiling before a chat runs, so keep it no larger than needed.

## From the app (one key)

The app's server uses `VIBIZ_APP_KEY` (add the `ai` resource with `vibiz add ai` / `vibiz_add_resources { resources: ["ai"] }` for a project AI key; `vibiz dev` gives a development one):

```ts
import OpenAI from 'openai';
import { vibiz } from '@vibiz/app';
const openai = new OpenAI(vibiz.ai);              // baseURL …/v1/ai, the app key
const r = await openai.chat.completions.create({ model: 'vibiz/fast', messages, user: userId });
```

With the `ai` resource the env also has `VIBIZ_AI_BASE_URL` and `VIBIZ_AI_API_KEY` (and `OPENAI_BASE_URL`, `OPENAI_API_KEY`, so `new OpenAI()` works unchanged). Routes: `POST /v1/ai/chat/completions` (streaming, tools, JSON mode), `/v1/ai/embeddings`, `/v1/ai/images/generations`, `/v1/ai/audio/speech`, `/v1/ai/audio/transcriptions`, `/v1/ai/jobs` (video and slow images: `202`, then poll; video takes `input.image_url` to animate a still). Agents: `vibiz_video_generate { prompt, image_url?, aspect_ratio?, model?, model_input? }` (waits, returns the link; `vibiz_video_status { job_id }` if it is still rendering); CLI: `vibiz video "<prompt>" -o out.mp4 [--from-image <url>] [--model <id>] [--params '<json>']`. **Any image or video model runs by its id on credit, not just the thelastapi ones**: Kling, Seedance, Veo, face swap, lip sync, upscalers… Find it with `vibiz_media_models { query }` (CLI `vibiz media-models kling`, API `GET /v1/ai/media-models?q=`), which shows the live price, then pass `model: <id>` and its own parameters in `model_input`. Never tell a user a model "isn't enabled": search for it first. **Edit a photo**: `image_url` (one photo, public https, a Files link works) or `image_urls` (up to 8 to combine) on `POST /v1/ai/images/generations` or `vibiz_image_generate`, with the prompt saying what to change ("make the background a beach"); CLI `vibiz image "<change>" -o out.png --from-image <url>`. Works with vibiz/image, vibiz/image-pro (Nano Banana) and vibiz/image-text; a prompt-only model answers `400 model_takes_no_photo` instead of ignoring the photo. A local photo: upload it first with `vibiz_files import` / `vibiz files upload` and use its link. Pass your own user's id as `user` (or `X-Vibiz-User`) so spend breaks down per end user. The key is a server secret: never in client code.

**Budgets** for an app: `PATCH /v1/projects/<id>/ai { daily_budget_usd, end_user_daily_budget_usd }` (also `rpm`, `tpm`, `concurrency`). Past a budget: `429 rate_limited` with `details.reason` (`daily_spend`, `project_budget`, `end_user_budget`…).

## Pick a model

`vibiz/fast` (default chat, GPT-6 Luna), `vibiz/lite` (DeepSeek V4.1 Flash, cheapest), `vibiz/smart-mini` (Claude Haiku 5.5), `vibiz/balanced` (Gemini 3.8 Flash, 1M context), `vibiz/reasoning` (GPT-6.1 Terra), `vibiz/smart` (Claude Sonnet 5.5), `vibiz/pro` (Claude Opus 5.5), `vibiz/embed`, `vibiz/embed-large`, `vibiz/image` (Nano Banana 2), `vibiz/image-pro` (Nano Banana 2.1), `vibiz/image-text` (GPT-5.4 Image 2, text in the image), `vibiz/video` (LTX-2.5 Fast, jobs only), `vibiz/voice`, `vibiz/voice-pro`, `vibiz/voice-lite` (ElevenLabs voices), `vibiz/transcribe` (Scribe v2). Or a lab id: `anthropic/claude-opus-5.5`, `google/gemini-3.8-flash`, `moonshotai/kimi-k3.1-pro`. A model not in the catalogue is refused (`invalid_request`, `param: "model"`). Quote prices from `vibiz_ai_models`, not from memory.

## The account's own Google or fal key

An account (or one project) can add its own Google key (Google's models) or a media key (images and video): those calls then run on the customer's own account and cost 0 on thelastapi (`paid_by: "your_key"`); nothing falls back to thelastapi if that key fails. `vibiz_ai_keys { project_id? }` shows the status and which models it serves; it never shows or sets a secret. Setting, testing or removing one is the owner's: tell them to run `vibiz ai keys add google` or `vibiz ai keys add fal` in their own terminal (hidden prompt, or `GEMINI_API_KEY` / `FAL_KEY`, or `--key-file`; `--vertex sa.json` for Google Cloud credits) or use the console (API keys ▸ Your AI keys). Never ask for the key in the chat.

## Never

- Never loop a costly call to "retry"; a `rate_limited` with `daily_spend` resets at midnight UTC: tell the person.
- Out of credits (`402 payment_required`): call `vibiz_billing` and give the person its `top_up_url`. Don't retry.
- On a host outside thelastapi the app needs only `VIBIZ_APP_KEY`: tell the owner the one-key sentence with the exact link (`app_key_console_url` from `vibiz_project_env`; the vibiz skill, "One key = everything").
- Never put `VIBIZ_APP_KEY` or `VIBIZ_AI_API_KEY` in browser code or print them. Rotating the production AI key is the owner's.

**Console links**: `/models` (`?q=claude opus`, `type=llm|image|video|speech|transcription|embeddings`) lists every model with prices; `/projects/<id>/ai` shows a project's AI calls. Results that carry `console_url` open the exact view: give the person that link.

## Limits: tell the owner up front

- **The caps and their defaults** (`vibiz_usage` → `limits` shows this account's): daily spend $5 per account (AI, web data and other actions, texts, calls; up to $1,000), project AI budget $1 per project per day, projects per plan (Free 2, Pro 10), 30 builds per project per day, 50 app emails per project per day, 200 texts and 50 calls per project per day, and no marketing email from agents until the owner allows a monthly number. Daily caps reset at 00:00 UTC.
- **The owner raises or lowers them:** daily spend in the console ▸ Billing ▸ Daily safety cap, or `PATCH /v1/billing {"daily_spend_limit_usd": 50}`; a project's AI budget in the project ▸ AI ▸ Daily AI budget, or `PATCH /v1/projects/<id>/ai {"daily_budget_usd": 10}` (`null`: no project budget); agents' email in the project ▸ Email ▸ Settings, or `PATCH /v1/billing {"agent_email_limit_per_month": 5000}`. Projects, builds, app email, texts and calls: delete what's unused, wait for the reset, or write to support@vibiz.ai.
- **thelastapi tells the owner:** one email at 80 % and one at 100 % of each cap (once per day, or month), and a banner on Overview and Usage, each with a link that opens the setting. `vibiz_usage` → `limits.alerts` lists caps at 80 % or more. A refusal carries `details.reason`, `raise_url` and `next_step`: give the owner the `raise_url`; retrying won't help.
- **When you build an app that uses AI or another capped product:** tell the owner the cap it runs under and what you expect it to cost a day, set the project AI budget to fit the expected traffic, and if the app adds a cap of its own keep it under the platform's and make it tell the owner when it's hit. Never let an app stop silently.

## References

- `references/ai.md`: every model, price, limit, route and error.
- `references/usage.md`: usage, limits and the daily ceiling.
