DEV Community

SC0d3r
SC0d3r

Posted on

HTTP 402: The API key AI agents never needed

Every trading bot on Solana needs a quote before it can swap. Today that means an API key, a plan, a monthly bill — and a human to set it up.

x402 replaces all of that with one status code the web already has: 402 Payment Required.

Here is the flow our 78-second demo follows, with SwapMate, a Telegram bot that swaps tokens for its users:

First, SwapMate asks Swap.io’s Agent API for a SOL → USDC quote.

Second, the first response is not a quote. It is HTTP 402, with the price of that exact request: about $0.003 in USDC on Solana.

Third, SwapMate pays, retries the same request, and gets the quote back.

Fourth, a second paid call builds the unsigned transaction. The user signs it in their own wallet.

No key to create, rotate, or leak. No monthly capacity the bot never uses. The agent pays fractions of a cent per call, only when it acts — failed requests are never charged. A full swap is two paid calls, under a cent, and the bot can charge its own users per swap.

That is the part that matters for agents: x402 lets software pay its own way, at a price that scales with use instead of with seats.

Watch the video on X: https://x.com/silvereyedead/status/2120053304457658673

Agent API quickstart: https://docs.swap.io/developer-tools/agent-api-x402/quickstart

Try it: https://swap.io

Top comments (0)