# TESI by ToolsEnabled — Prepaid Agent API Specification (HTTP 402, Real TESI) TESI provides pay-first programmatic access to real TESI `Ask` and `Work` for external software agents. People can try TESI Free in the browser with no sign-up or email at https://toolsenabled.ai/try/ (isolated browser session with a free usage bar; pauses with "Free usage is at capacity" when free capacity is full). Automated callers purchase prepaid TESI credits upfront via Stripe Checkout (`HTTP 402 Payment Required`), claim a single-use bearer token once payment clears, and run real TESI on an isolated agent computer (`1 vCPU, 2 GB RAM, 10 GB disk`). ## Protocol Flow ### 1. Discover Agent API Packs & Rates ```bash curl -sS https://toolsenabled.ai/api/v1/agents ``` ### 2. Request a Prepaid Key (Returns `HTTP 402 Payment Required`) Valid `amountCents` packs: `1000` ($10), `2500` ($25), `5000` ($50), `10000` ($100). ```bash curl -i -X POST https://toolsenabled.ai/api/v1/agents/keys \ -H "Content-Type: application/json" \ -d '{"amountCents": 1000, "label": "ci-worker"}' ``` Response (`402 Payment Required`): ```json { "error": "payment_required", "unpaidStatus": 402, "sessionId": "cs_live_...", "checkoutUrl": "https://checkout.stripe.com/c/pay/cs_live_...", "amountCents": 1000, "creditCents": 1000, "currency": "usd", "claimUrl": "https://toolsenabled.ai/api/v1/agents/keys", "claimBody": { "sessionId": "cs_live_..." } } ``` ### 3. Complete Payment & Claim Bearer Key Once After card payment completes at `checkoutUrl`, claim the bearer key once: ```bash curl -sS -X POST https://toolsenabled.ai/api/v1/agents/keys \ -H "Content-Type: application/json" \ -d '{"sessionId": "cs_live_..."}' ``` Response (`201 Created`): ```json { "apiKey": "tesi_ak_...", "keyId": "agk_...", "workspaceId": "ws_...", "computerSize": "agent", "creditUnit": "TESI credits", "creditCents": 1000, "currency": "usd", "chatUrl": "https://toolsenabled.ai/api/v1/agents/chat", "workUrl": "https://toolsenabled.ai/api/v1/agents/work", "balanceUrl": "https://toolsenabled.ai/api/v1/agents/balance", "topupUrl": "https://toolsenabled.ai/api/v1/agents/topup" } ``` Store `apiKey` securely; TESI stores only its SHA-256 hash and refuses duplicate claims with `409 key_already_claimed`. ### 4. Run Real TESI `Ask` or `Work` ```bash # Ask mode (read-only analysis / answers): curl -sS -X POST https://toolsenabled.ai/api/v1/agents/chat \ -H "Authorization: Bearer tesi_ak_..." \ -H "Content-Type: application/json" \ -d '{"message": "Summarize the release checklist.", "mode": "ask", "effort": "medium"}' # Work mode (full TESI computer execution): curl -sS -X POST https://toolsenabled.ai/api/v1/agents/work \ -H "Authorization: Bearer tesi_ak_..." \ -H "Content-Type: application/json" \ -d '{"message": "Create a clean Python test suite in the workspace and run it.", "effort": "high"}' ``` If prepaid credits are exhausted, TESI refuses before execution with `HTTP 402 Payment Required` (`error: "insufficient_credits"`) and a fresh Stripe `checkoutUrl` to top up the key. ### 5. Check Balance & Top Up ```bash curl -sS https://toolsenabled.ai/api/v1/agents/balance \ -H "Authorization: Bearer tesi_ak_..." curl -sS -X POST https://toolsenabled.ai/api/v1/agents/topup \ -H "Authorization: Bearer tesi_ak_..." \ -H "Content-Type: application/json" \ -d '{"amountCents": 2500}' ``` ## Published TESI Rates - Measured at provider list price plus 25%: - Standard prompts (up to 272,000 input tokens): input `$2.50 / 1M`, cached input `$0.125 / 1M`, output `$12.50 / 1M`. - Long prompts (over 272,000 input tokens): input `$5.00 / 1M`, cached input `$0.25 / 1M`, output `$18.75 / 1M`. ## Terms & Support - TESI Free and prepaid agent credit: https://toolsenabled.ai/free-and-agent-terms/ - TESI beta terms: https://toolsenabled.ai/legal/terms/ - Support: support@toolsenabled.ai