buy_ai_tokens
Purchase AI Tokens ($0.10 per token) by charging a Stripe Shared Payment Token (SPT) — for users with no Atom balance. This SPENDS REAL MONEY and requires the 'domains:register' scope.
MANDATORY three-step flow — never skip a step:
Call with confirm=false to get a QUOTE: price is entirely server-authoritative ($0.10 x token_count) — never assume or pass a price.
Call again with confirm=true, the SAME idempotency_key, and NO payment_token: returns a structured payment_required challenge (amount, currency).
Once a Shared Payment Token is obtained for that exact amount, call a third time with confirm=true, the SAME idempotency_key, and payment_token set. Payment is captured FIRST; tokens are only credited after that succeeds.
PAYMENT PRIORITY for AI Tokens: this tool is priority 1 — try it first, using whatever payment method your own platform can already supply for the payment_token. Only if you have no way to obtain a payment_token here, fall back to priority 2: get_ai_tokens_pay_link, paid via link-cli's tools (e.g. mpp_pay), if those are present in this session. There is no checkout-link fallback for AI Tokens.
Rules: never assume or pass a price. Reuse one idempotency_key across all calls for the same intent. If crediting fails AFTER payment succeeds, no refund is issued automatically — the result says so explicitly; do not tell the user a refund is coming.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| confirm | No | false returns a quote; true attempts payment + crediting. | |
| token_count | Yes | Number of AI Tokens to purchase (1-100000). | |
| payment_token | No | Shared Payment Token authorizing the exact quoted amount. Omit to receive the payment_required challenge. | |
| idempotency_key | Yes | Client-generated unique key; identical across all calls for the same intended purchase. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| price | No | ||
| stage | Yes | ||
| balance | No | AI Token balance after crediting (credited stage). | |
| success | Yes | ||
| currency | No | ||
| challenge | No | Present when stage=payment_required. | |
| token_count | Yes | ||
| idempotency_key | No | ||
| payment_intent_id | No |