Prepaid Agent API · Real TESI · HTTP 402
Real TESI for external software agents.
People can try TESI Free right in the browser at /try/ with no sign-up or email (with a free usage bar in an isolated browser session). External software agents and automated callers pay upfront via HTTP 402 + Stripe Checkout, claim a single-use bearer key, and run real TESI Ask and Work on an isolated agent computer.
Four-step pay-first protocol
Start a prepaid Stripe Checkout session.
Read GET /api/v1/agents for packs and rates, then send POST /api/v1/agents/keys with {"amountCents":1000} ($10, $25, $50 or $100). TESI answers HTTP 402 Payment Required with checkoutUrl and sessionId before issuing any key.
Complete payment and claim your hashed bearer token.
Complete card payment at checkoutUrl, then send POST /api/v1/agents/keys with {"sessionId":"cs_..."}. TESI verifies settled Stripe payment, provisions an isolated agent workspace, and returns {"apiKey":"tesi_ak_..."} once (stored only as SHA-256; replays return 409).
Execute on your isolated TESI agent computer.
Send POST /api/v1/agents/chat ({"message":"...","mode":"ask"}) or POST /api/v1/agents/work ({"message":"...","mode":"work","effort":"medium"}) with Authorization: Bearer tesi_ak_.... TESI wakes the key’s isolated computer, meters real TESI usage atomically against prepaid credits, and returns reply plus balance.
Deterministic HTTP 402 refill at $0.
Inspect balance at GET /api/v1/agents/balance or create a top-up session with POST /api/v1/agents/topup. When credits reach zero, requests refuse before execution with HTTP 402 and a fresh top-up checkoutUrl. Full charge refunds revoke the key automatically.
Questions
Good to know.
How do external software agents pay before using TESI?
Send POST /api/v1/agents/keys with an amountCents value ($10, $25, $50 or $100). TESI answers HTTP 402 Payment Required with a Stripe Checkout checkoutUrl and sessionId. Complete payment on Stripe, then POST the sessionId to /api/v1/agents/keys once to claim your bearer key.
Does the Agent API run real TESI Ask and Work?
Yes. Each funded bearer key owns an isolated TESI agent computer and workspace. POST /api/v1/agents/chat (mode ask) and POST /api/v1/agents/work (mode work, with effort control) execute real TESI turns on that computer, metered against your prepaid balance.
What happens when prepaid credits run out or a charge is refunded?
When balance reaches zero, POST /api/v1/agents/chat and /api/v1/agents/work refuse before execution with HTTP 402 Payment Required and a fresh Stripe Checkout top-up URL. Full refunds on the underlying charge automatically revoke the bearer key.
How is prepaid usage metered?
At published TESI rates: input $2.50, cached input $0.125 and output $12.50 per million tokens; prompts over 272,000 tokens are input $5.00, cached input $0.25 and output $18.75 per million tokens.
More about TESI