HTTP 402 Payment Required · Hard Spend Caps
Prepaid agent compute with zero runaway bills and zero account signup.
Give any autonomous agent its own isolated Linux computer under a hard USD spend cap ($10, $25, $50, or $100 USD one-time). Your agent prepares a purchase over HTTPS, a human approves Stripe Checkout once, and your agent claims a reusable tesi_ak_... bearer key.
1. Fastest path: 2-command curl HTTP 402 flow
Any agent with HTTPS access can request a $10 USD pack (`1000` cents) and claim its bearer key with zero SDK dependencies:
# 1. Request a $10 USD pack -> returns HTTP 402 with checkoutUrl and sessionId
curl -sS -X POST https://toolsenabled.ai/api/v1/agents/keys \
-H 'Content-Type: application/json' -d '{"amountCents":1000}'
# 2. After human approves payment at checkoutUrl, claim your reusable key -> HTTP 201
curl -sS -X POST https://toolsenabled.ai/api/v1/agents/keys \
-H 'Content-Type: application/json' -d '{"sessionId":"cs_live_REPLACE_ME"}'
Financial Controls for Agent Builders
2. Four spend & reliability guarantees built into the protocol
Pre-spend admission quotes (free)
Call GET /api/v1/agents/starting-credit?promptBytes=1800&includePacks=1 before holding a key. Only the integer byte count is sent—never your prompt text—and TESI returns exact pico-credit admission and eligible USD packs.
Manual top-up lock (TESI-Topup-Mode: manual)
Include TESI-Topup-Mode: manual on /chat and /work. Low balances fail cleanly with HTTP 402 manual_topup_required and zero unapproved Stripe sessions.
48-hour key & turn crash recovery
Bind purchases with a 64-hex purchaseId to recover lost key claims for 48 hours, and bind turns with requestId (mw_...) to recover verified replySha256 outputs on GET /turns/{requestId} without double-charging.
Itemized debit ledger (agc_...)
Audit every settled charge at GET /api/v1/agents/usage (or tesi_usage in MCP) with HMAC-scoped agc_... charge IDs, UTC settlement timestamps, and rolling 1–744h window sums.
Questions
HTTP 402 billing FAQ.
Can an autonomous agent accidentally run up an unbounded credit card bill on TESI?
No. Every tesi_ak_... bearer key is strictly prepaid with no saved-card auto-charge. Sending TESI-Topup-Mode: manual guarantees that when a key runs low, TESI returns HTTP 402 manual_topup_required without even creating an unapproved Stripe Checkout session.
What if my agent crashes after the human pays on Stripe before saving the API key?
When you prepare Checkout with a private 64-hex purchaseId (handled automatically by tesi-buy.py and tesi-agent-mcp.py), repeating the claim with the same sessionId and purchaseId recovers the identical bearer key for up to 48 hours until you confirm local custody.
Can we top up the same bearer key later so our agent keeps its Linux computer workspace?
Yes. Both paid keys and promotional keys can be topped up in place via POST /api/v1/agents/topup or the browser widget at /agents/#agent-topup, preserving the same tesi_ak_... token and isolated workspace.
Next steps