Agent subscriptions with USDC
An agent can buy a 30-day unlimited pool subscription with USDC on Base and get an API key back in a single call — no account, no card, no KYC. This guide walks the full flow, including the wallet signature the claim requires.
Why a signature is required
Section titled “Why a signature is required”You pay by sending USDC on-chain and then telling us the transaction hash. But a settled transaction hash is public on Base — anyone watching the payee address can see it. If the hash alone were enough to claim the key, an observer could replay your hash and receive your key.
So the claim must prove you control the wallet that paid: you sign a message with that wallet, and we check the signature against the transaction’s sender. Only the real payer can produce it.
The flow
Section titled “The flow”1. Get the price
Section titled “1. Get the price”Make a keyless inference request to receive a 402 with the live catalog, or call GET /api/agent/plans directly. Read blocks[].priceUsdc for the blocks you want and sum them.
curl https://api.cheapestinference.com/api/agent/plans2. Pay USDC on Base
Section titled “2. Pay USDC on Base”Send the summed amount of your chosen blocks, in USDC, to the payTo address from the catalog, on Base. Keep the transaction hash. Wait for the transaction to reach a few confirmations before claiming — a just-mined transaction is not yet final and the claim will ask you to retry.
3. Sign the claim message
Section titled “3. Sign the claim message”Sign this exact message with the same wallet you paid from:
CheapestInference: claim pool subscription for transaction <txHash>Using ethers:
import { Wallet } from 'ethers';
const wallet = new Wallet(PRIVATE_KEY);const message = `CheapestInference: claim pool subscription for transaction ${txHash}`;const signature = await wallet.signMessage(message);Using viem:
import { privateKeyToAccount } from 'viem/accounts';
const account = privateKeyToAccount(PRIVATE_KEY);const message = `CheapestInference: claim pool subscription for transaction ${txHash}`;const signature = await account.signMessage({ message });4. Claim the key
Section titled “4. Claim the key”curl -X POST https://api.cheapestinference.com/api/agent/subscribe-pool \ -H "Content-Type: application/json" \ -d '{ "txHash": "0xabc...", "poolSlug": "frontier", "blocks": ["asia"], "signature": "0x<sig>" }'Response:
{ "success": true, "data": { "apiKey": "sk-...", "pool": "frontier", "blocks": ["asia"], "amountUsdc": "52.00", "expiresAt": "2026-08-02T00:00:00.000Z", "walletAddress": "0x...", "status": "active" }}5. Use the key
Section titled “5. Use the key”curl https://api.cheapestinference.com/v1/chat/completions \ -H "Authorization: Bearer sk-..." \ -H "Content-Type: application/json" \ -d '{"model": "kimi-k2.7", "messages": [{"role": "user", "content": "Hello"}]}'Retrying safely
Section titled “Retrying safely”The claim is idempotent for the paying wallet: resending the same signed request never charges twice and never mints a second subscription. If a key couldn’t be issued on the first attempt, the retry delivers it. So the safe pattern is: pay once, then retry the signed claim until you get an apiKey.
Common errors
Section titled “Common errors”| Response | Meaning | What to do |
|---|---|---|
signature is required | No signature field | Sign the claim message (step 3) and include it |
Missing or invalid wallet signature | Signature isn’t from the tx sender, or is for a different txHash | Sign the exact message with the wallet that sent the payment |
Transaction not yet final … | Payment not confirmed enough | Wait for a few more confirmations and retry |
No matching USDC transfer found … | Amount/recipient mismatch | Send the exact summed USDC amount to the catalog’s payTo |
Transaction already used … | Hash claimed but no subscription found for this wallet | Ensure you sign with the wallet that actually paid |
Renewal
Section titled “Renewal”USDC pool subscriptions are one-time, 30 days, no auto-renew. When it expires, repeat this flow with a new payment.