402 with an offer. Your x402 client signs a USDC payment on Base and sends the request again. This recipe adds a price cap, so the client refuses any offer above $0.01 instead of signing whatever amount it’s asked for.
Recipe prompt
Paste this into your coding agent to have it build the recipe in your project:Recipe prompt
What you build
A SELECT query costs 100,000 base units, so the cap in this recipe refuses it. Raise
MAX_AMOUNT if your agent should run SELECT queries.
When it runs
On every call. A paid call is two requests: the first returns402 with the offer, and the retry carries the payment. Keenable runs the request, settles the payment on-chain and returns the result only after settlement succeeds.
Code
The TypeScript tab pays for one search and one fetch of the top result, and prints the transaction hash of each payment. The curl tab asks without paying and prints the offer:npm install @x402/fetch @x402/evm viem, and set WALLET_PRIVATE_KEY to the key of a wallet you funded for this.
Example output
The curl tab decodes thePAYMENT-REQUIRED header of the 402 response and prints the first offer:
Example output
amount is in USDC base units, 6 decimals, so 10000 is $0.01. asset is the USDC contract on Base. The TypeScript tab prints one line per paid call, with the number of results or the page length, and the transaction hash.
Production notes
Keep the wallet balance small. If your agent calls Keenable regularly, an API key costs less: $4 per 1,000 requests from a prepaid balance rather than $10. See Pay per request.
Next steps
- Pay per request: the payment flow, every error and ZeroClick prepaid credits.
- Enrich a list with SELECT: a SELECT query you can send over x402.
- Research loop: the searches and fetches an agent pays for.
- Recipes: every recipe on one page.