Use just one service from an app hosted anywhere
Use any single thelastapi service from an app hosted anywhere by creating a project with only that resource and passing one secret: VIBIZ_APP_KEY.
On this page 8 sections
- Why decouple your backend services from your hosting provider
- How to create a project with only what you need
- How to register an external domain
- How to pass the app key to your external server
- What each service requires from an external host
- How to call services using plain HTTP
- How limits, environments, and safety rules work
- FAQ
You can use any single thelastapi backend service from an app hosted anywhere without moving your site or deploying code to thelastapi hosting. Every service runs independently: you create a project containing only the capability you want, point your code to it using your environment's VIBIZ_APP_KEY, and keep your frontend, server, or script wherever it already runs.
This guide explains how external hosting works with thelastapi, how to configure external domains, and how to connect individual resources like databases, payments, email, AI models, files, and analytics using @vibiz/app or direct HTTP requests.
Why decouple your backend services from your hosting provider
Most developer platforms force an all-or-nothing architecture. If you want their database or user management, they often require you to host your entire web application on their servers.
That model creates friction when your application already has a home. You might run a mobile app backend, an existing server on your own hardware, a static marketing site, or a periodic cron task. Moving an entire deployment pipeline just to access one managed service is unnecessary work.
On thelastapi, hosting is merely one optional service among many. Every tool operates as a modular capability:
- No bundling requirements: Pick one service, multiple services, or the whole stack. None of them depends on thelastapi hosting.
- A single environment secret: Your application connects to all of its enabled services using one key:
VIBIZ_APP_KEY. - Standard interfaces: You interact with standard protocols, including direct Postgres database URLs, OpenAI SDK configurations, and standard REST requests.
If you eventually want to unify everything under one umbrella, read one key for your whole app: the one-API stack for indie builders.
How to create a project with only what you need
You provision backend resources using the vibiz CLI or your AI coding agent. The --resources flag limits the project to the exact infrastructure you intend to use.
# Provision only serverless Postgres
vibiz init customer-db --resources database
# Provision only user sign-in (which brings the database automatically)
vibiz init auth-service --resources auth
# Provision only email sending
vibiz init mail-daemon --resources email
# Provision only the AI gateway
vibiz init ai-worker --resources ai
# Provision payments, file storage, web actions, or connectors
vibiz init billing-api --resources noneSeveral features require no infrastructure provisioning at all. Payments, file storage, web scraping actions, company formation, and API connectors are available by default in an empty project initialized with --resources none.
To manage databases separately on existing servers, see using a managed Postgres database from an app hosted anywhere. For standalone native applications, check a backend for a mobile app without writing a backend.
How to register an external domain
When your chosen service interacts with end-user browsers or external webhook deliveries—such as user sign-in, session replay, cookieless analytics, or payment events—you register your external address:
vibiz domains add app.example.com --elsewhereThe --elsewhere flag informs thelastapi that the domain receives traffic on external infrastructure rather than our hosting network:
- Analytics and session replay: Page visits and client events from
app.example.comare accepted immediately. - User sign-in: Origin validation accepts authentication callbacks once you add the DNS TXT record (
_vibiz.app.example.com) and runvibiz domains verify app.example.com, or when the account owner confirms the domain in the console. - Payment webhooks: The domain becomes trusted so payment processors can dispatch event notifications to endpoints hosted there.
If your project is a background daemon, a command-line utility, or an internal API without a public web address, you do not need to register a domain.
How to pass the app key to your external server
Your external host talks to thelastapi through a single secret: VIBIZ_APP_KEY (vz_app_…).
To retrieve the production key, the account owner can open the project settings page or run the following command in the CLI:
vibiz app-keyAdd VIBIZ_APP_KEY to the environment variables on your external host. Once installed, your application runtime can unpack all relevant configuration settings during startup:
import { vibiz } from '@vibiz/app';
// Populates DATABASE_URL, VIBIZ_AUTH_*, VIBIZ_WEBHOOK_SECRET into process.env
await vibiz.loadEnv();When building non-Node services, or when configuring containerized processes in CI/CD pipelines, you can load your environment variables without the Node SDK:
# Evaluate configuration dynamically into the shell environment
eval "$(curl -fsS -H "Authorization: Bearer $VIBIZ_APP_KEY" https://thelastapi.dev/v1/app/env?format=shell)" && exec python server.pyYou can also use the CLI to run tasks directly with npx @vibiz/cli run -- <start command>, or pull values into a dotenv file with npx @vibiz/cli env pull --format dotenv -o .env.production. For details on access controls and secret management, see the guide on keys and environments.
What each service requires from an external host
Every service can be queried through the @vibiz/app client or via standard HTTP calls. Here is an overview of requirements by service:
| Service | Creation flag | Domain needed | How the external app uses it |
|---|---|---|---|
| Database | --resources database | No | Direct Postgres connection via DATABASE_URL |
| Sign-in | --resources auth | Yes | VIBIZ_AUTH_* environment variables |
| Payments | --resources none | Yes (for webhooks) | vibiz.payments.checkout(...) |
| AI models | --resources ai | No | new OpenAI(vibiz.ai) or vibiz.ai.chat(...) |
--resources email | No | vibiz.email.send(...) from project address | |
| Analytics | --resources analytics | Yes | Embed snippet from vibiz analytics snippet |
| Files | --resources none | No | vibiz.files.upload(...) |
| Web data | --resources none | No | vibiz.actions.run('web.scrape', ...) |
Accepting card payments from an external frontend
If you run an existing web store on an external server and only want managed checkouts and subscription tracking, initialize a project without extra resources:
vibiz init store --resources none
vibiz domains add store.example.com --elsewhere
vibiz payments products add Pro --amount 900 --interval month --lookup-key pro-monthly
vibiz payments webhook https://store.example.com/api/vibiz/webhookIn your application code, create checkouts and verify incoming webhook signatures using the app client:
import { vibiz } from '@vibiz/app';
// Generate a hosted checkout URL
const { url } = await vibiz.payments.checkout({
lookup_key: 'pro-monthly',
user: session.userId,
success_url: 'https://store.example.com/dashboard?session=success',
cancel_url: 'https://store.example.com/pricing',
});
// Inside your webhook handler endpoint
export async function handleWebhook(req: Request) {
try {
const event = await vibiz.webhooks.receive(req);
// Process verified payment event
return new Response('Received', { status: 200 });
} catch (error) {
return new Response('Invalid webhook signature', { status: 400 });
}
}Routing AI models through an OpenAI client
You can access multi-lab language models without swapping SDKs. The app client supplies the base URL and API key directly to the OpenAI client:
import OpenAI from 'openai';
import { vibiz } from '@vibiz/app';
// vibiz.ai returns { baseURL, apiKey } mapped to your VIBIZ_APP_KEY
const openai = new OpenAI(vibiz.ai);
const completion = await openai.chat.completions.create({
model: 'vibiz/fast',
messages: [{ role: 'user', content: 'Draft a short order confirmation email.' }],
});
console.log(completion.choices[0]?.message.content);Storing user assets in file storage
You can store user uploads or background outputs in files without provisioning separate object storage buckets. Every uploaded file receives an unguessable permanent link:
import { vibiz } from '@vibiz/app';
const uploaded = await vibiz.files.upload(imageBuffer, {
name: 'profile.png',
contentType: 'image/png',
});
// Store the permanent public URL
console.log('Public file URL:', uploaded.url);How to call services using plain HTTP
If you build with languages where installing an extra npm package is undesirable, you can call /v1/app HTTP endpoints directly using standard authorization headers:
# Upload a file directly via curl
curl https://thelastapi.dev/v1/app/files \
-H "Authorization: Bearer $VIBIZ_APP_KEY" \
-H "Content-Type: image/png" \
--data-binary @avatar.png# Scrape a web page to markdown
curl https://thelastapi.dev/v1/app/actions/web.scrape \
-H "Authorization: Bearer $VIBIZ_APP_KEY" \
-H "Content-Type: application/json" \
-d '{"input": {"url": "https://example.com"}}'Review the full reference in the documentation for @vibiz/app and use one service.
How limits, environments, and safety rules work
External applications operate under the same safety controls as apps deployed on internal hosting:
- Prepaid usage balance: Every account starts with $2 of trial credit. Ongoing service usage—such as AI inference, transactional email, and web scraping—deducts from your credit balance at documented per-unit rates.
- Safety ceilings: Every account has a default $5 daily spend cap across AI and web actions, while projects have a $1 daily AI budget. Owners can adjust these caps under Billing in the console or by running
vibiz billing limitandvibiz ai budget. - Threshold notifications: thelastapi emails account owners when a daily cap reaches 80% and 100% of its threshold.
- Local development branches: Running
vibiz devgenerates an isolated development environment with an empty Postgres branch (sharing schemas with zero production rows) and test-mode payment handling. - Portability: If you decide to migrate away, your code and data remain entirely yours. Running
vibiz exportcreates a downloadable SQL snapshot of your database and a complete project export as detailed in the export documentation.
To get started, explore what is thelastapi or create your account at thelastapi.dev/start.
Frequently asked questions
Do I need to move my frontend to thelastapi to use a single backend service?
No. thelastapi hosting is completely optional, and running `vibiz init <name> --resources <one>` allows you to consume any service independently from an app running on any external infrastructure.
How does an external server securely read its database credentials and secrets?
You add only `VIBIZ_APP_KEY` to your host's environment, then call `await vibiz.loadEnv()` at startup or evaluate the `/v1/app/env` endpoint to populate secrets like `DATABASE_URL` directly into `process.env`.
What happens if an externally hosted application runs out of credits?
Paid API requests fail with a `402 payment_required` error, while already-running services like databases, user sign-in, and analytics remain active and are never stopped or deleted for lack of balance.