Pay per Request with x402
You can call the Discuse API without an account. Each request is paid in USDC at the moment you send it, with the x402 payment protocol. There is no sign-up, no API key, no plan and no monthly quota.
Use x402 for AI agents and occasional callers. For steady traffic, an API key on a plan is cheaper and has higher limits.
How does a paid request work?
- Send the request without an
X-API-Keyheader. - The API answers
402 Payment Required. Thepayment-requiredresponse header and the JSON body describe the price and the accepted payments. - Your x402 client signs a USDC payment for that amount.
- Send the same request again with the signed payment in the
PAYMENT-SIGNATUREheader. - The payment is verified and settled, and the API returns the normal response.
Any x402 version 2 client can do steps 2 to 4 for you.
What does the payment challenge look like?
{
"x402Version": 2,
"error": "PAYMENT-SIGNATURE header is required",
"resource": {
"url": "https://api.discuse.com/api/v2/scan",
"description": "File virus scan"
},
"accepts": [
{
"scheme": "exact",
"network": "eip155:8453",
"amount": "10000",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"payTo": "0x66Bd239CC81664622BD8d528aa8c14f9FE46e36c",
"maxTimeoutSeconds": 60,
"extra": { "assetTransferMethod": "permit2", "name": "USD Coin", "version": "2" }
}
]
}
amount is in USDC atomic units (6 decimals), so 10000 is $0.01. accepts lists one entry per network.
Which networks and tokens are accepted?
| Network | Chain id | Token |
|---|---|---|
| Base | eip155:8453 |
USDC |
| Polygon | eip155:137 |
USDC |
How much does each request cost?
| Endpoint | Price per request |
|---|---|
POST /api/v2/check |
$0.005 |
POST /api/v2/scan |
$0.01 |
POST /api/v2/ocr |
$0.02 |
POST /api/v2/summarize |
$0.03 |
POST /api/v2/demo/check |
$0.005 |
The price is fixed per request. It does not depend on the size of the content.
What limits apply to paid requests?
A paid request does more work than its price covers if it is not limited, so paid requests have smaller limits than API keys:
| Endpoint | Limit per paid request |
|---|---|
/api/v2/check |
Text, plus at most 2 images or GIFs, 1 document and 5 links. Videos are not available. |
/api/v2/scan |
1 file, by file_url (up to 50 MiB) or file_data (up to 10 MiB) |
/api/v2/ocr |
1 file |
/api/v2/summarize |
Text, or 1 file |
A request above a limit is refused with 400 and a message that starts with x402 pay-per-request limit. Each paying wallet can send up to 60 requests per minute. Above that, the API answers 429.
Paid requests use the default moderation settings. Project settings, such as custom thresholds, need an API key.
How do I avoid paying when I have an API key?
Send the X-API-Key header. A request with that header is never asked for payment, and it is billed to your plan instead. A key in the JSON body does not count: without the header, the request gets the payment challenge.