browseraiOpen the playground

Payments: x402 and balance

Sessions cost 0.00005 USDG a second (0.18 USDG an hour), with a 10 second minimum. You pay in USDG on Robinhood Chain, two ways.

AssetUSDG 0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168, 6 decimals
Treasury0x3ad6063c0e667038fb22bC4797226807a928543A
Price50 units a second, 10 second minimum, at least 60 seconds of balance to open

Balance

Transfer USDG to the treasury from the agent's wallet (the agent pays the gas), then post the transaction hash. The gateway reads the receipt and credits every USDG transfer to the treasury in it to the sender. A hash is credited once.

await bai.deposit('2')                 // sends and credits in one call
await bai.claimDeposit('0x…txhash')     // or credit a transfer made elsewhere

curl -X POST https://browserai-gw.fly.dev/v1/deposits -H 'content-type: application/json' \
  -d '{"txHash":"0x…"}'

Sessions opened with a signature are billed from this balance every ten seconds and settled to the second on close. Credit does not expire.

x402

Without a signature, POST /v1/sessions answers 402 Payment Required with an exact requirement:

{
  "x402Version": 1,
  "accepts": [{
    "scheme": "exact",
    "network": "eip155:4663",
    "maxAmountRequired": "30000",
    "asset": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
    "payTo": "0x3ad6063c0e667038fb22bC4797226807a928543A",
    "maxTimeoutSeconds": 300,
    "extra": { "name": "Global Dollar", "version": "1", "pricePerSecond": "50" }
  }]
}

The agent signs an EIP-3009 TransferWithAuthorization for 0.03 USDG and retries with the X-PAYMENT header. The gateway checks the signature, the balance and the nonce, submits transferWithAuthorization on chain and opens the session. The 0.03 USDG buys 600 seconds; what the session does not use stays on the payer's balance for the next one. The response carries X-PAYMENT-RESPONSE with the settlement transaction.

const s = await bai.open({ pay: 'x402' })

x402 settlement needs gas on the gateway's relayer. When the relayer is not funded, the 402 answer lists no x402 option and the balance route is the way in; GET /v1/stats shows "x402": true when it is open.