pai
    Preparing search index...

    Buying credit and payments

    This guide covers direct-key purchases with pai buy and pai payment. For shared workspace funding, x402 and MPP agent payments, start with Run agents and choose how you pay.

    pai buy --amount 5                 # USDC on Solana
    pai buy --amount 5 --coin sol
    pai buy --amount 5 --wait # wait until the credit lands

    --coin takes usdc (the default), usdt or sol, in any case. usdcsol and usdtsol are older spellings of usdc and usdt ( parseBuyCoin).

    pai asks Phantom AI for a payment request for this key ( requestSolanaPayment). The answer names the address to pay, the exact amount, a Solana Pay link, a reference (an address Phantom AI finds the payment by on chain), an expiry and a payment_id ( SolanaPaymentRequest). You send the coins from any wallet. Nothing is charged until someone sends them.

    With --wait, pai prints the request on stderr, so stdout stays one JSON document, and then asks Phantom AI for the payment's status every 10 seconds, for up to 65 minutes ( waitForPayment):

    Status What pai does
    completed or finished, or topped_up is true stops and prints the result
    expired, failed or refunded stops with the error code payment_<status>
    anything else prints the new status on stderr and keeps waiting

    If 65 minutes pass, pai stops with payment_timeout and tells you to run pai payment <id>.

    pai buy --amount 10 --card                     # add credit to this key
    pai buy --amount 10 --card --new --save work # buy a new key and save it as work

    pai asks Phantom AI for a card payment on Stripe's checkout page ( requestCardPayment) and prints the card total and the link on stderr. The card pays the amount plus 5% plus $0.30, and the amount must be at least $5. pai opens the link in your default browser with open on macOS, xdg-open on Linux and rundll32 on Windows ( openInBrowser). If the browser doesn't open, copy the link from the output. Stripe's page asks for your email, the cardholder's name and the card, and Stripe keeps them. pai never sees the card.

    pai then waits for the payment the same way --wait does above, and always waits ( buyWithCard). When the payment lands it prints one JSON result ( CardBuyResult):

    • For a top-up, the credit goes on the key pai runs as, and the result shows the new balance.
    • With --new, or when no key is set, the payment buys a new key. pai saves it as the login key, or by name with --save <name>, and prints where it went, never the key. pai checks the save spot before you pay: with a login key already saved, --new needs --save.

    For a new key, pai also prints a recovery code. If pai stops before the key arrives, send that code as recovery_code to POST /v1/purchase/recover to get the key.

    Over MCP, buy_credit_card returns the link and a payment_id for the user to open, and check_payment shows when the credit lands.

    pai payment <payment_id>
    pai payment <payment_id> --wait

    The MCP tools are buy_credit, buy_credit_card and check_payment. topped_up turns true once the credit is on the key ( getPaymentStatus).

    When a payment request comes with a recovery_code, buy --wait sends it to Phantom AI in the x-phantom-recovery-code header when it asks for the status. pai payment sends no recovery code.