thelastapi
Get started free

Stop juggling API keys: one key instead of ten services

Instead of managing separate API keys across ten vendors, you can run hosting, Postgres, auth, email, payments, and AI from a single key.

On this page 9 sections

You can replace a dozen scattered provider keys with a single secret called VIBIZ_APP_KEY. When you build a modern web application, you typically spend days signing up for separate vendors, storing distinct credentials in environment files, and wiring up separate billing cards. thelastapi unifies hosting, serverless Postgres, sign-in, transactional email, AI models, file storage, card payments, analytics, and web data behind one API and one balance. You configure a single environment variable, and your application gets access to every capability it needs to operate.

This guide outlines how consolidating your infrastructure under one key works, how to use it in code, and how to keep production secrets safe when collaborating with AI coding agents.

Why do developers end up with too many API keys to manage?

Building a software product used to require writing custom software. Today, it often means stitching together third-party APIs. A standard software-as-a-service stack usually requires:

  • An account for serverless Postgres
  • An authentication service for user sign-in
  • An email provider to deliver receipts and notifications
  • An AI gateway or model provider account
  • An object storage bucket for user uploads
  • A payment processor account for checkouts and subscriptions
  • A web analytics script and dashboard
  • A scraping or search data vendor for web ingestion

Every single vendor requires its own dashboard, token generation workflow, webhook secret, rotation policy, and credit card on file. If an API key expires, an invoice fails, or a token leaks from a local file, your production app breaks. If you work with AI coding agents such as Claude Code, Codex, or Cursor, pasting ten different production secrets into chat windows creates severe security risks. Managing keys becomes a maintenance chore that distracts from shipping product features.

How does one key replace your entire backend stack?

Instead of provisioning ten standalone services, thelastapi provides those primitives under a single project umbrella. As described in What is thelastapi, every capability is metered and accessed through the same control plane.

When your app runs, it needs only one secret: VIBIZ_APP_KEY. Through the official client package, @vibiz/app, or through direct HTTP calls to https://thelastapi.dev/v1/app, this key authenticates every request your backend makes.

ServiceTraditional setupWith VIBIZ_APP_KEY
Postgres databaseSeparate database host, connection string, pooling keyProvisioned per project; loaded automatically with await vibiz.loadEnv()
AuthenticationExternal auth provider keys and client secretsEmail/password, magic links, Google, and GitHub configured via vibiz auth
Transactional emailDedicated SMTP or email API keysvibiz.email.send(...) from <mailbox>@<slug>.vibiz.app
AI modelsMultiple lab keys (OpenAI, Anthropic, Google)new OpenAI(vibiz.ai) or vibiz.ai.chat(...) routed through one gateway
Card paymentsSeparate payment processor keys and webhook secretsvibiz.payments.checkout(...); thelastapi acts as the merchant
File storageCloud storage buckets, access keys, region configsvibiz.files.upload(...) returning permanent public or signed URLs
Web dataSeparate scraping, search, and crawling subscriptionsvibiz.actions.run('web.scrape', ...) billed to project credits
Analytics & replaySeparate analytics tokens and recording snippetsvibiz.track(...) on server; snippet before </head> on web pages

To explore building entirely within this pattern, read One key for your whole app: the one-API stack for indie builders.

How do you configure and run the code?

You can adopt the entire platform or use individual pieces alongside your existing stack. As explained in Use one service, you do not need to host your site on thelastapi to use its database, email, AI gateway, or payments.

1. Initialize your project

In your terminal, initialize your project using the CLI:

Terminal
vibiz init "Acme App"

This provisions your project, creates your database, enables authentication, and generates your keys. If you only want a subset of capabilities (for example, just email and AI without a database), you specify resources directly:

Terminal
vibiz init "Acme Worker" --resources ai,email

2. Connect the client library

Install the official client package into your project:

Terminal
npm install @vibiz/app

In your application code, import vibiz from @vibiz/app. Calling await vibiz.loadEnv() at startup loads your database connection string and authentication secrets directly into process.env. From there, every service is callable through that single client:

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

// 1. Hydrate environment variables (DATABASE_URL, VIBIZ_AUTH_*, etc.)
await vibiz.loadEnv();

// 2. Call the AI gateway using standard SDKs
const openai = new OpenAI(vibiz.ai);
const completion = await openai.chat.completions.create({
  model: 'vibiz/fast',
  messages: [{ role: 'user', content: 'Draft a short onboarding note.' }],
});

// 3. Send transactional email
await vibiz.email.send({
  to: 'ana@example.com',
  subject: 'Welcome to Acme',
  text: completion.choices[0]?.message.content ?? 'Welcome!',
});

// 4. Create a payment checkout link
const checkout = await vibiz.payments.checkout({
  lookup_key: 'pro-monthly',
  user: 'usr_123',
  success_url: 'https://app.example.com/billing/success',
  cancel_url: 'https://app.example.com/billing/cancel',
});

// 5. Track server-side analytics
await vibiz.track('User Signed Up', {
  user: 'usr_123',
  properties: { plan: 'pro-monthly' },
});

Because @vibiz/app reads VIBIZ_APP_KEY from your environment automatically, your deployment configuration stays tidy. For more implementation patterns, see One env var for everything: VIBIZ_APP_KEY explained and the @vibiz/app reference.

How do you isolate development from production?

One of the largest hazards of having many API keys is accidentally running development scripts against production data or incurring live charges.

thelastapi projects come with two isolated environments: production and development.

  • Database: Development gets its own Postgres branch with your schema but zero production rows.
  • Sign-in: Development routes trust http://localhost:3000 and maintain separate test users.
  • Payments: Development uses test mode with simulated card checkouts and zero risk to real funds.
  • AI & Web data: Separate development keys bill against the project balance without touching production resources.

When you run local development, run:

Terminal
vibiz dev

This writes your isolated development variables into .env.development.local. Your production secrets remain untouched.

How do you keep keys safe with AI agents?

If you use tools like Cursor, Claude Code, or Codex, you often grant automated tools access to run commands. Passing unrestricted production API keys to an AI agent can lead to leaked credentials, unintended live charges, or database drops.

As detailed in Keys and environments, thelastapi solves this with Limited keys:

  1. Full-access keys (vz_sk_...): Held by account owners. They can deploy live code, run database migrations, issue refunds, rotate keys, and read production variables.
  2. Limited keys (access: agent): Given to agents or contractors. A Limited key can create projects, trigger preview deploys, run actions, send development emails, and use AI models. However, it is fundamentally blocked from viewing production secrets or moving live money.

If a Limited key attempts an owner-only action, the API halts with a 403 forbidden error containing a details.grant_url. The agent gives this URL to you in chat:

Text
Paste STRIPE_SECRET_KEY here: https://thelastapi.dev/projects/prj_123/secrets/new?name=STRIPE_SECRET_KEY&env=production&kind=env . It goes straight to thelastapi, never through this chat.

Your sensitive production credentials never pass through an LLM prompt. If you need to integrate existing custom third-party endpoints, read Call your own APIs through one gateway, with their keys sealed to understand how the platform proxies those requests.

How do billing and spend limits work across services?

Juggling multiple API keys usually means managing ten separate recurring bills and credit card statements. With thelastapi, account billing is unified and prepaid.

According to Billing and credits:

  • Every new account starts with $2 of trial credit.
  • Every billable operation—whether an AI completion, web scrape, email delivery, or database day—deducts directly from your credit balance.
  • To prevent accidental runaway costs caused by looping scripts or agents, every account features an account-wide daily safety cap (default $5 per day).
  • Projects have an AI daily budget cap (default $1 per day).

When your balance approaches zero, existing services such as hosted sites, databases, sign-in, and analytics remain online and never get shut down for money. Only paid outgoing calls (such as AI completions or paid actions) return 402 payment_required. You can monitor your balance or set auto-recharge from the CLI:

Terminal
vibiz billing
vibiz billing auto-recharge on --threshold 5 --amount 25

Can you leave if you decide to self-host later?

Using a unified API key does not mean getting locked into a proprietary platform. You retain full ownership of your application code and data.

As outlined in Export, you can pull down your entire application at any moment:

Terminal
vibiz export --code -o app.zip
vibiz export --db --csv

This packages your source code, your environment structure (.env.example), and a complete SQL dump of your Postgres database. You can restore that database directly into any standard Postgres instance using psql:

Terminal
gunzip -c shop-production-database.sql.gz | psql "$NEW_DATABASE_URL"

Because the AI gateway uses standard OpenAI request and response formats, shifting your AI calls to another host requires only changing the base URL back.

Next steps

Stop spending your development time creating vendor accounts and tracking down lost API keys. Run vibiz init to provision your first project, or review the Billing and credits guide to configure your project's spend ceilings. You can create your account at thelastapi.dev/start.

Frequently asked questions

Where is VIBIZ_APP_KEY used in my application?

`VIBIZ_APP_KEY` is a server-side secret used by `@vibiz/app` or HTTP headers (`Authorization: Bearer $VIBIZ_APP_KEY`) in your backend runtime. It should never be exposed in client-side browser code.

What happens if an AI coding agent tries to access production keys?

If an agent holds a Limited key, the API denies access with a `403 forbidden` error and provides a console URL where the project owner can safely paste or approve secrets outside the chat.

How do spend limits prevent runaway API costs?

Accounts include a default $5 daily safety cap on AI and action spend, alongside a $1 daily AI budget per project, throwing a `429 rate_limited` error if an agent loops or traffic spikes unexpectedly.

Can I still use thelastapi if my app is hosted on another cloud provider?

Yes, you can run your application on any host and supply only `VIBIZ_APP_KEY` in its environment, using `@vibiz/app` to call the database, AI gateway, payments, and other services remotely.