The problem no one talks about until it hurts
You build an AI agent. It works great. Then one night it runs a loop, calls Anthropic 8,000 times, and you wake up to a $4,000 bill on your personal credit card.
Or: you give a client access to your agent. They ask it to "research everything about our competitors." The agent calls your internal APIs 500 times. Each call costs $0.01. That's $5 you didn't plan for, every time someone asks a broad question.
AI agents are autonomous. Autonomy without spending controls is a liability.
The fix takes 10 minutes. Create a wallet for your agent with a hard budget limit. Every purchase call checks the remaining budget first. No human approval needed — just enforcement at the infrastructure level.
What you'll use
Trove's API gives every agent a programmable wallet. The wallet has:
Budget limit: A hard ceiling on total spend. Your agent can never exceed it.
Transaction ledger: Every purchase is recorded with amount, vendor, and description.
Balance check: Ask the wallet "how much is left?" before making expensive calls.
402 rejection: When the budget is exhausted, the API returns 402 with the remaining balance.
Step 1: Create the wallet
Create a wallet for your agent
Give your agent a wallet with a $50/month budget limit. You can always increase it later.
The response gives you a wallet.id. Save that — it's how you reference the wallet in all future calls.
Step 2: Check the budget before making calls
Guard before you spend
Before your agent calls an expensive API, check the remaining budget. If it's too low, skip the call or alert you.
Step 3: Execute purchases through the wallet
Route every dollar through the wallet
When your agent makes a purchase, call the wallet API instead of billing directly. The wallet deducts and records the transaction atomically.
The wallet check is atomic. If two agents call the purchase endpoint simultaneously, the row lock ensures both are evaluated against the same balance at commit time. No double-spending, no race conditions.
Step 4: Read the transaction log
Know where every dollar went
Pull the transaction ledger to see exactly what your agent spent money on — vendor, amount, description, timestamp.
Try it in the playground
No setup required. Get a sandbox API key and wallet instantly.
Open the PlaygroundWhat happens when the budget runs out
Your agent calls POST /api/wallets/:id/purchase with amount_usd: 0.50. The wallet has $0.31 remaining.
The transaction is never recorded. Your agent handles the 402 — skips the call, alerts you, or queues the request until the budget is increased. No credit card surprise.
Common mistakes to avoid
Setting budget = balance. Your budget limit is the ceiling, not the current balance. If you want $100/month, set budget_limit_usd: 100. The agent can spend up to $100 total, and balance_usd tracks how much it's spent so far. Setting budget to 0 means the agent can't spend anything.
No pre-flight check. Checking the balance before calling expensive APIs isn't required — the purchase endpoint will reject over-budget calls — but it lets your agent be smart about what to attempt. A "budget exhausted" error means the agent wasted time on a call it knew might fail.
Using the same wallet for multiple agents. One wallet, one agent. If two agents share a wallet and spend concurrently, they can race to the same budget ceiling. Give each agent its own wallet and set per-agent budgets independently.
Scale up as your agents grow
The same pattern works for any scale. A $50/month research bot uses the same API as a $10,000/month enterprise agent fleet. The difference is wallet count and budget limits — the enforcement mechanism is identical.
Start with one wallet per agent. Monitor transaction history. Increase budget limits as you learn what your agents actually spend. After a month, you'll have accurate per-agent cost data that lets you price client work profitably instead of guessing.
Get started. Open the playground — get a sandbox API key and wallet in 30 seconds. No credit card required. Read the full API docs for transaction webhooks and budget update endpoints.