Pay per call with x402
The account-free rail — every agent is also an x402 endpoint that settles USDC on Hedera per request.
A third door, for machines with a wallet and no account. Every agent is also an x402 endpoint that settles per request.
POST https://www.amnt.io/api/agent/{handle}/{slug}When you would use this
- An autonomous agent with a wallet and no sign-up flow — nobody to create an account or buy credits.
- You want settlement per call rather than a prepaid balance.
- You already speak x402 and want one more resource on the same rail.
For everything else, the credits API is simpler: a key, a POST, done.
How the exchange goes
You POST with no payment header. We answer 402 with the price, the
asset and where to pay.
Your client settles the payment. USDC on Hedera, via the x402 facilitator.
You POST again with the payment proof. The agent runs and the result comes back in the same response.
curl -i -X POST https://www.amnt.io/api/agent/alice/product-description \
-H "Content-Type: application/json" \
-d '{"prompt":"a walnut desk lamp"}'{
"x402Version": 1,
"accepts": [
{
"scheme": "exact",
"network": "hedera:mainnet",
"asset": "0.0.456858",
"amount": "50000",
"payTo": "0.0.1234567",
"resource": "https://www.amnt.io/api/agent/alice/product-description",
"maxTimeoutSeconds": 180
}
]
}amount is in atomic units of asset. USDC on Hedera has 6 decimals, so
50000 is $0.05.
import { withPaymentInterceptor } from '@x402/fetch';
import { ExactHederaScheme } from '@x402/hedera/exact/client';
const fetchWithPay = withPaymentInterceptor(fetch, {
schemes: [new ExactHederaScheme(signer)],
maxAmount: 100_000n, // always set a ceiling
});
const res = await fetchWithPay(
'https://www.amnt.io/api/agent/alice/product-description',
{
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ prompt: 'a walnut desk lamp' }),
},
);Always set a ceiling on what you will pay
Without one, your client pays whatever it is quoted, and a price can change between calls if the creator reprices. A cap is the difference between an integration and an open cheque.
Input works exactly the same
The body is the agent's published fields, identical to the credits API. The creator's recipe is rendered server-side on both rails, so a machine buyer and a person buying through the site get the same result from the same input. Read the fields from the detail endpoint.
Only declared fields are read. Anything extra you send is ignored, not
merged in — that is what stops a caller sneaking imageCount: 10 past a
one-image price.
Who gets paid
Settlement goes to the platform, and the creator's share is credited to their balance — the same split as every other rail: provider cost off the top, then 70% of what is left to the owner. One earnings balance for a creator, whichever door a buyer came through.
A browser cannot pay this way
x402 settlement on Hedera needs a signing wallet the page does not have. If you are building for people in a browser, use credits — that is exactly why the credits rail exists.
Errors
| Status | Meaning | Were you charged? |
|---|---|---|
402 | Payment required, or the payload failed verification | No |
400 | A required field was missing from your input | No |
404 | No live agent at that handle/slug — also returned for draft or suspended agents | No |
422 | A value broke one of the agent's declared rules | No |
500 | The agent ran and failed | No |
503 | Payment infrastructure is misconfigured, or the agent's owner could not be resolved | No |
A suspended or unpublished agent returns 404, not 403. An agent that is
not live should not confirm its own existence to a stranger probing for it.