An AI agent that pays for its own server, hour by hour

An agent with a USDC wallet buys its own confidential VM over x402, runs on it, and renews it from the same wallet. No account, no card, no person at checkout.

What the agent needs

A wallet holding USDC on Base, Polygon or Solana, and code that can sign with it. Nothing else: no account, no card, no API key, and no ETH or SOL for gas. We settle each payment on chain, and the network fee is inside the price the agent is quoted.

The wallet is the account. It buys the machine, reads it, controls it, renews it and destroys it. It signs two kinds of message: the x402 payment (an EIP-3009 transfer authorization on Base or Polygon, a partly signed token transfer on Solana), and X-Wallet-Auth for owner calls, a personal_sign (EIP-191) over the method, the path, a nonce and a timestamp. A Solana wallet signs the same string with its ed25519 key.

Buying the first machine

POST /api/compute/deployments with {"plan", "hours", "image"}, or "compose" for a docker-compose file, and "env" for its settings. With no payment header the answer is HTTP 402: an accepts array with one entry per network and the exact USDC amount. Quoting is free and charges nothing, so the agent can read the price on every network before it commits.

The agent signs one entry's amount and sends the same request again with the signature in X-PAYMENT (or PAYMENT-SIGNATURE, x402 version 2). The payment settles on chain and the answer is 202 with a deploymentId and "status": "provisioning". The agent then reads GET /api/compute/deployments/{id}, signed with X-Wallet-Auth, until it reads "running": its app answers then, and the endpoint and the attestation are live. While it boots, the read carries "boot": the phase, the seconds since it started and, on a failure, the reason in plain words. The paid clock starts when the machine is up ("runningAt"), not at payment.

The official x402 client caps each payment by default. For more hours or a larger plan, raise its cap (spendControls.maxAmountPerPayment), or the client refuses to pay. If the answer is lost after the payment was sent, send the same request with the same X-PAYMENT: it returns the machine already bought and charges nothing.

Running the agent on its own machine

An agent that pays for its own server usually runs on it. Its code ships as the image or the compose; its wallet key goes in env. Env values are sealed to the machine's enclave key and never stored, and the machine is a confidential VM (Intel TDX), so the key stays sealed from the host while the agent uses it to pay.

If a machine's first start has to be retried, the retry runs without the env values, so keep them settable again. POST /api/compute/deployments/{id}/update with the setup and a new "env" replaces them; the machine restarts with them and keeps its hours.

An agent that sells its own API publishes a port, and its endpoint is that host port on the machine's address. Its public verify page, https://api.agentgates.ai/compute/verify/{id}, shows its customers the compose hash, the OS image hash and the hardware quote.

Renewing from the same wallet

The machine runs until expiresAt. Shortly before, the agent calls POST /api/compute/deployments/{id}/renew with {"hours": 1} and a fresh x402 payment. Renewals stack on the end of the clock, so renewing early never loses time. Paying one hour at a time keeps the agent no more than the current hour ahead of what it uses, and never behind, because a machine runs only on paid time.

To skip an on-chain settle on every renewal, the wallet tops up a prepaid balance once with POST /api/compute/credits, then renews with X-Wallet-Auth and no payment header: the renewal draws the balance. USDC settles first and the balance moves after. A balance never expires, is not refundable, and stays with the wallet that paid it.

Notices tell the wallet when its machine is about to stop, has stopped or is about to be deleted, and when a payment was refused for lack of USDC; the refusal itself says what the wallet can buy instead. They ride every compute answer, and the agent can also read them from https://api.agentgates.ai/api/notices, follow them live, or have them posted to a webhook.

Anyone can keep the agent running: any wallet may pay a machine's renewal over x402. A person or another agent can add hours to its machine without owning it.

When the money runs out

Nothing is postpaid and nothing is ever owed. If the wallet cannot pay, the machine stops at expiresAt and sits in grace: its data is kept and a renewal starts it again, for as long as it was paid for, at least an hour and at most 72 hours. Grace is a ceiling, not a reservation: an expired machine may be deleted sooner when a paying buyer needs the room.

Every answer about the machine carries lifecycle: paidUntil and stopsAt, deleteAt, the renewal call with its price, and next, the same in words. An expired machine answers restart, start, stop, resize and update with 409 expired, with the renewal that starts it again. A machine deleted because its time ran out answers its renewal with a 402 for a new machine with its setup, priced as a new machine, with a new id and address and its env values empty unless the owner sends them; renewing the old id then renews the new machine. A machine its owner deleted answers 409 deleted with when and why it went and newMachine, the create call for its plan at today's price.

Controlling its own machine

The owner wallet signs each control with X-Wallet-Auth, and none of them takes a payment. Restart; stop, which pauses the paid hours (a stopped machine is kept 72 hours, then deleted); start; resize to another plan, the time left converting at the new rate; and update, a new setup on the same machine that keeps its hours. DELETE /api/compute/deployments/{id} destroys the machine, and its hours left go with it.

FAQ

Can an AI agent buy its own server without a person?

Yes. It needs a wallet with USDC on Base, Polygon or Solana. It reads the 402 quote, signs that amount and sends the request again, and the machine belongs to that wallet.

Does the agent need ETH or SOL for gas?

No. We settle each payment on chain, and the network fee is inside the quoted price.

Where does the agent keep its wallet key on the machine?

In env. Env values are sealed to the machine's enclave key and never stored, and the machine is a confidential VM (Intel TDX).

What happens if the agent runs out of money?

The machine stops when its paid time ends, and nothing is owed. Its data is kept for as long as it was paid for, from one hour to 72 hours, and a renewal in that time starts it again.

Can someone else pay to keep the agent running?

Yes. Any wallet may pay a renewal over x402. Only the owner wallet reads, controls or destroys the machine.

What does it cost?

Read /pricing or GET /api/compute/catalog. Each 402 quotes the exact amount for that request on each network, and quoting charges nothing.