Skip to content

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.

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.

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.

Terminal window
curl https://api.cheapestinference.com/api/agent/plans

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.

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 });
Terminal window
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"
}
}
Terminal window
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"}]}'

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.

ResponseMeaningWhat to do
signature is requiredNo signature fieldSign the claim message (step 3) and include it
Missing or invalid wallet signatureSignature isn’t from the tx sender, or is for a different txHashSign the exact message with the wallet that sent the payment
Transaction not yet final …Payment not confirmed enoughWait for a few more confirmations and retry
No matching USDC transfer found …Amount/recipient mismatchSend the exact summed USDC amount to the catalog’s payTo
Transaction already used …Hash claimed but no subscription found for this walletEnsure you sign with the wallet that actually paid

USDC pool subscriptions are one-time, 30 days, no auto-renew. When it expires, repeat this flow with a new payment.