thelastapi
Get started free

How to stop an AI agent from overspending

Stop AI agents from overspending by enforcing daily account caps, per-project AI budgets, and Limited API keys that block unapproved live spending.

On this page 7 sections

You stop an AI agent from overspending by combining hard daily budget caps with scoped Limited keys that block unauthorized charges. On thelastapi, you can set account-wide daily ceilings, project-level AI budgets, and issue agent keys that run freely in development but cannot move live money or trigger expensive operations without human approval. When a limit is hit, the API immediately halts requests with a 429 error specifying the exact budget boundary reached.

Autonomous coding tools and background workers can consume tokens, fire web actions, or purchase resources rapidly if left unchecked. Controlling them requires structural guardrails at the API gateway rather than soft prompting alone.

Set hard daily ceilings on your account and projects

The first line of defense against runaway agent spend is a hard monetary cap at the infrastructure layer. thelastapi enforces daily budget controls that stop requests immediately when exceeded:

  • Account daily limit: By default, new accounts have a $5 daily spend ceiling covering all projects, AI calls, and web actions. You can inspect or raise this limit using the CLI or Billing console.
  • Project daily AI budget: Every project starts with a default daily AI budget of $1. When an agent running inside a specific project exhausts this amount, its AI requests are cut off while other projects remain operational.

You can inspect and update these limits using the CLI with a full-access key:

Terminal
# Check the account-wide daily spend ceiling
vibiz billing limit

# Raise or lower the account-wide daily spend ceiling to $20
vibiz billing limit 20

# Check the current AI budget for a project
vibiz ai budget --project prj_123

# Set a $5 daily AI budget for a specific project
vibiz ai budget 5 --project prj_123

# Apply a $2 daily AI budget across every project with AI enabled
vibiz ai budget 2 --all

When an agent hits either threshold, the gateway answers with status code 429 and a JSON error indicating rate_limited. The response object contains details.reason set to "daily_spend" or "project_budget". Your agent receives a clear signal to pause instead of repeatedly executing failing calls.

Give your agent a Limited key instead of an owner key

Giving an autonomous agent full access to an infrastructure account invites unexpected costs. An agent with an owner key can file companies, purchase phone numbers, run unthrottled live marketing, or export paid data.

thelastapi separates access into Full access (access: owner) and Limited (access: agent). When you approve an agent during vibiz login or through remote MCP client authorization, you can select Limited access.

CapabilityLimited key (access: agent)Full-access key (access: owner)
Create projects, build, and deployAllowedAllowed
AI completions and web data runsAllowed (metered against budget)Allowed (metered against budget)
Read production environment variablesNames only (?names=1)Full values
Development database and test cardsAllowedAllowed
Live money actions (refunds, payouts)Blocked (403 owner_only)Allowed
Domain purchasesCapped at owner's per-domain limitAllowed
Large email broadcastsPauses for owner reviewAllowed
Create or revoke API keysBlocked (403 owner_only)Allowed

To create a Limited key for an autonomous process or teammate's agent:

Terminal
# Create a dedicated Limited key
vibiz keys create research-agent --limited

# Inspect the access tier of an existing key
vibiz keys access key_123

# Downgrade an existing key to Limited access
vibiz keys access key_123 limited

# Revoke a key immediately if an agent loops or misbehaves
vibiz keys revoke key_123

Using the HTTP API, you can provision a Limited key directly:

Terminal
curl https://thelastapi.dev/v1/api-keys \
  -H "Authorization: Bearer $OWNER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"worker-agent","access":"agent"}'

Because a Limited key works against an isolated development environment by default, database rows are branched without touching production tables, and payments operate in test mode where transactions are simulated. To learn how to structure credentials for your coding assistants, read about one API key for an AI agent and review the Keys and environments guide.

Monitor and break down spend by agent, model, and project

You cannot budget what you do not measure. Instead of waiting for an aggregated invoice at the end of the billing cycle, thelastapi provides real-time per-call metering and multi-dimensional cost breakdowns.

Every JSON completion response from the AI gateway returns the exact cost of the execution in micro-USD:

JSON
{
  "id": "chatcmpl-123",
  "served_model": "anthropic/claude-sonnet-5.5",
  "cost_micro_usd": 12400,
  "usage": {
    "prompt_tokens": 1200,
    "completion_tokens": 400,
    "total_tokens": 1600
  }
}

In the CLI, you can query usage across multiple dimensions to see precisely which agent or feature is consuming credits:

Terminal
# Break down usage by individual API key over the last 7 days
vibiz usage --period 7d --by api_key

# Break down spend by model across projects
vibiz usage --period 24h --by model

# Inspect spend generated by a specific project
vibiz usage --project prj_123 --by tool

# Filter spend by end-user attribution
vibiz usage --by end_user --period month

Before initiating long-running workflows, agents running over MCP can call vibiz_usage to inspect their current spend and confirm how much headroom remains before reaching daily limits. When writing apps that let visitors prompt models directly, you can also establish per-user AI budgets to ensure one user cannot consume an entire project's quota.

Protect real-world actions: email, domains, and connectors

Language model tokens are not the only vector for runaway charges. An agent given autonomous web execution can trigger transactional costs across emails, registered domains, paid APIs, and search runs.

thelastapi builds approval checkpoints into high-risk capabilities:

Email broadcasts and campaigns

Sending a bulk email blast costs $0.001 per message. If a Limited key calls vibiz email broadcast send <id>, the API intercepts the operation. Instead of dispatching messages immediately, it generates an owner review link unless you have pre-configured an explicit monthly agent allowance via vibiz email settings set --agent-limit <emails/month>.

Domains and infrastructure

A Limited key can only purchase a domain through vibiz domains buy <domain> if the price falls within the owner's pre-approved per-domain limit. A Limited key can never delete an existing domain, move registered domains between projects, or delete DNS records.

External API connectors

If you import external APIs using OpenAPI manifests via vibiz connectors, thelastapi holds the underlying credentials securely. Write operations and potentially dangerous endpoints invoked by a Limited key are held in an approval queue:

Terminal
# Check operations waiting for human authorization
vibiz connectors approvals

# Approve a pending external API call initiated by an agent
vibiz connectors approve apr_123

Social and ad campaigns

An agent can assemble Google Ads campaigns through vibiz social campaigns create. However, all campaigns are created in a PAUSED state by default. They require manual confirmation or the explicit --active flag with a full-access key to initiate real spend.

Teach agents to check budgets before running

Agents can be taught to inspect their constraints rather than failing blindly. If you use Claude Code, Codex, or Cursor, you can install specialized agent skills that provide pre-built workflows for reading limits.

Run the following command in your terminal or agent session:

Terminal
# Install the skills bundle globally across your agent environment
vibiz skills add --global

These bundles provide the agent with workflow rules found in our documentation. For example, the agent learns to invoke vibiz_usage or vibiz billing before kicking off expensive batch jobs, and learns to handle 403 owner_only or 429 rate_limited errors gracefully by presenting the human operator with details.grant_url or details.console_url.

If you prefer building directly inside conversational tools like Claude or ChatGPT, you can connect the remote MCP server at https://thelastapi.dev/mcp without installing local software. See how this operates in deploy a website from Claude or ChatGPT with nothing installed and read the setup steps in Agents.

Next step

To establish spending boundaries for your team or automated tools, run vibiz billing limit to verify your account ceiling, create a scoped credential with vibiz keys create <name> --limited, and review current resource usage with vibiz usage.

Frequently asked questions

What error does an agent receive when a daily spending budget is reached?

The API returns HTTP status code `429` with error code `rate_limited`. The response includes a `details.reason` field specifying whether the pause was triggered by `daily_spend` (account ceiling) or `project_budget` (project AI cap).

Can a Limited key increase its own spending limits or AI budget?

No. Modifying account ceilings with `vibiz billing limit`, setting project budgets with `vibiz ai budget`, or elevating key privileges requires a full-access owner key. A Limited key attempting these operations receives a `403 owner_only` error.

How does thelastapi stop an agent from spending money on bulk email?

When a Limited key initiates an email broadcast, the system halts delivery and outputs an owner review link. The emails are only dispatched once the owner approves the broadcast or sets an explicit monthly allowance using `vibiz email settings set --agent-limit`.

How can I see which specific agent key spent credits today?

Run `vibiz usage --period 24h --by api_key` in the CLI. This breaks down all metered AI calls, web data actions, and resource charges by the unique API key that made the request.