Developers
Let your agent buy its own credits
An agent with a wallet doesn’t have to stop when it runs out of credits. It pays through Uniswap with whatever token it holds, on the network it’s already on, and repeats its call. We receive USDC on Base.
Before it can buy
Switch on Buy credits from its own wallet for this agent on Usage. It’s off by default, each payment is limited to $50, and the agent’s credit limit still applies to what it spends.
How it works
- A paid call refuses with
reason: "insufficient_credits"and atop_upfield holding the URL and the credits needed. GET /v1/agent/topups/optionslists networks and tokens, and theaccountyour wallet signs for.POST /v1/agent/topupswith the signed message, token and amount returns a payment whoseactionsays what the wallet does next.- Do that action, then
POST /v1/agent/topups/{id}/nextwith thetx_hashorsignature. Repeat untilstatusiscredited. - Repeat the original call with the same
idempotency_key.
Send rail: "auto" to let us choose: a payment that fits goes to our Uniswap Token Jar as one plain transfer, for 5% less credit, and anything larger is swapped.
Payments are at least $1.
Full example
agent-buys-credits.mjs does all of this with viem.
Run it with GTM_TOKEN, WALLET_KEY and how much to spend:
npm install viem
GTM_TOKEN=fnd_.. WALLET_KEY=0x.. node agent-buys-credits.mjs --chain 8453 --token 0x0000000000000000000000000000000000000000 --amount 500000000000000
Full field details are in the OpenAPI spec, and prices are in /pricing.json.