thelastapi
Get started free

A pay-as-you-go AI API with no monthly fee

Pay for AI models per token or generation with no monthly subscription fee using thelastapi's prepaid, OpenAI-compatible gateway.

On this page 7 sections

thelastapi offers a pay-as-you-go AI gateway with no monthly subscription fees, charging only for the tokens and media you use against prepaid credits. You get access to over 400 language models across major labs plus image, speech, and video models under a single OpenAI-compatible endpoint. New accounts start with $2 in trial credits, and you only buy credits when you need them.

If you are building an application or testing an AI agent, recurring monthly minimums create unnecessary overhead. Here is how pay-as-you-go billing works, what models are supported, and how to start making calls without committing to a monthly tier.

How pay-as-you-go billing works

Instead of a monthly invoice or fixed base fee, thelastapi uses a prepaid credit balance. You add funds by card in the console under Billing ▸ Add credits in increments from $5 to $1,000, or generate a checkout link using the CLI:

Terminal
vibiz billing top-up 25

Every AI call measures the input and output tokens, calculates the exact usage cost, and deducts it from your prepaid balance the moment the request finishes.

  • No recurring base fees: You pay only for what you run. If your app sits idle for weeks, your balance remains untouched.
  • Trial credit: Every new account starts with $2 of credit to test routes and models.
  • Transparent call pricing: Every JSON chat response includes the cost_micro_usd field, giving you the exact cost of that single call in millionths of a dollar.
  • Automatic recharge (optional): To ensure production requests never fail unexpectedly, you can configure auto-recharge to add credits when your balance dips below a threshold:
Terminal
vibiz billing auto-recharge on --threshold 5 --amount 25

If your account balance ever drops to zero, paid API calls return 402 payment_required. Your projects, databases, and saved configurations remain intact.

Model catalogue and token pricing

You can call language models using stable aliases or by specifying exact provider model IDs. Stable aliases map to specific frontier models, giving you predictable endpoints:

thelastapi modelRuns onBest forPricing (Input / Output per million tokens)
vibiz/fastGPT-6 Luna (OpenAI)Chat, tool calls, JSON$0.10 / $0.50
vibiz/liteDeepSeek V4.1 Flash1M context, high-volume workloads$0.14 / $0.42
vibiz/smart-miniClaude Haiku 5.5 (Anthropic)Quick, strong writing and coding$0.10 / $0.50
vibiz/balancedGemini 3.8 Flash (Google)1M context, balanced price and quality$0.825 / $4.125
vibiz/reasoningGPT-6.1 Terra (OpenAI)Math, logic, deep planning$1 / $5
vibiz/smartClaude Sonnet 5.5 (Anthropic)Coding, agents, complex writing$2 / $10
vibiz/proClaude Opus 5.5 (Anthropic)Deep reasoning and long agent sessions$4 / $20

Beyond text, the pay-as-you-go model applies across other capabilities on the same API key:

  • Embeddings: vibiz/embed ($0.02 per 1M tokens) and vibiz/embed-large ($0.13 per 1M tokens).
  • Images: vibiz/image (about $0.067 per image) and vibiz/image-pro (about $0.034 per image).
  • Audio: vibiz/voice ($0.04 per 1,000 characters) and vibiz/transcribe ($0.22 per hour of audio).
  • Video: vibiz/video ($0.54 per 6-second clip).

You can also call more than 400 models directly using their provider paths, such as moonshotai/kimi-k3.1-pro or anthropic/claude-opus-5.5. If you need to route requests between different vendors without managing separate accounts, see our guides on how to access multiple AI models with a single API and one API key for GPT, Claude and Gemini: how a unified AI API works.

Calling models using the OpenAI SDK

Because the gateway uses an OpenAI-compatible interface, you do not need to install proprietary vendor clients. Point standard client libraries to https://thelastapi.dev/v1/ai using your API credentials.

First, initialize your project environment:

Terminal
vibiz init "My Project" --resources ai
vibiz dev

The CLI configures your .env.development.local file with VIBIZ_AI_BASE_URL and VIBIZ_AI_API_KEY (as well as OPENAI_BASE_URL and OPENAI_API_KEY).

Run calls using the standard Node.js OpenAI SDK:

TypeScript
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() {
  const completion = await openai.chat.completions.create({
    model: 'vibiz/fast',
    messages: [{ role: 'user', content: 'Draft a short confirmation email.' }],
  });

  console.log(completion.choices[0]?.message.content);
}

main();

If you are using Python, you can find a complete walkthrough in our tutorial on how to use Claude with the OpenAI Python SDK. Alternatively, you can use the @vibiz/app library, which automatically reads your project credentials:

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

const openai = new OpenAI(vibiz.ai);

You can also execute raw HTTP requests with curl:

Terminal
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":"Plan a migration."}]}'

Built-in spend limits and safety caps

A common risk with pay-as-you-go APIs is runaway spend from background jobs or runaway agent loops. thelastapi provides three default safety layers to cap exposure without manual oversight:

  1. Account Daily Safety Cap: Accounts default to a $5 per UTC day spending ceiling across AI and platform actions. The account owner can adjust this in the console or via the CLI up to $1,000:
    Terminal
    vibiz billing limit 50
  2. Project Daily Budget: Each project starts with a default daily AI limit of $1 per UTC day. You can adjust or remove this limit at any time:
    Terminal
    vibiz ai budget 10 --project prj_123
  3. Worst-Case Pre-Check: Before a model generates tokens, the platform evaluates the call's worst-case cost (max_tokens at list price). If running the call could push your credit balance more than $0.50 negative, the gateway halts execution and answers 402 payment_required.

When any daily ceiling is reached, requests fail cleanly with HTTP 429 and details.reason: "daily_spend" or "project_budget". Account owners automatically receive an email alert at 80% and 100% of their daily limits, avoiding silent outages. Full details can be reviewed on the Usage and limits docs page.

Monitoring per-call and per-user usage

You do not need third-party logging to trace where your credits go. Use the CLI to inspect your usage broken down by tool, model, or project:

Terminal
vibiz usage --period 7d --by model
vibiz usage --by end_user --project prj_123

To attribute spend directly to your own customers, pass a user identifier in the user field of the chat completion payload, or supply the X-Vibiz-User header. In @vibiz/app, use vibiz.user(id) to scope requests automatically:

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

// Tracks events and scopes AI billing to this specific user ID
await vibiz.user('usr_456').track('Generated Report');

When you define an end-user budget (end_user_daily_budget_usd), individual abuse is prevented automatically without stopping service for other active users. For complete key isolation, see our reference on Keys and environments.

Next step

To get started, explore the AI documentation for complete request schemas, or review the Billing and credits guide to configure your project's daily spend limits. Create your account at thelastapi.dev/start to get started.

Frequently asked questions

Is there an upfront commitment or monthly minimum fee?

No. There are no monthly fees, base subscription costs, or seats to pay for; you only draw down from prepaid credits based on your usage.

What happens if an API call runs out of balance mid-request?

Every call is checked against its worst-case token cost before it runs; if your account balance cannot cover it, the request is refused with a 402 payment_required status instead of failing mid-execution.

Can I use my own Google Gemini API key to save credits?

Yes. You can register your own Google credentials using `vibiz ai keys set google`, which routes all Google models directly through your personal key at zero platform charge.

What is the default maximum token limit per call?

The default `max_tokens` is 1,024 when omitted from the request body, and it can be set up to 16,384 depending on the model.