Buy Credits
FreePOST /api/payment/buy-creditsPOST to this endpoint with an amount_usd to receive a payment quote: the wallet address to send USDC to, a memo (optional but recommended), the credit amount you will receive, and a 30-minute expiry. Send the USDC, then call /api/payment/confirm with the tx_hash and memo.
When to use this endpoint
Step 1 of the credits-first payment flow. Use this for any agent that will make repeat premium calls; the latency cost is paid once on the credits purchase rather than per-call.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
| amount_usd* | body | number | USD value to purchase. Min 0.5, max 10000. Volume discounts at $5 (10%), $30 (25%), $200 (40%). |
* required
Example response
{
"ok": true,
"wallet": "0x549c82e6bfc54bdae9a2073744cbc2af5d1fc6d1",
"memo": "tf-eb13b1a17c6811d6",
"amount_usd": 1.0,
"credits": 50,
"currency": "USDC",
"network": "base",
"expires_at": "2026-04-27T18:30:00Z",
"ttl_seconds": 1800,
"next_step": "Send 1.0 USDC on Base to 0x549..., then POST /api/payment/confirm with tx_hash and memo."
}Code samples
Python SDK
from tensorfeed import TensorFeed
tf = TensorFeed()
quote = tf.buy_credits(amount_usd=1.0)
print(f"Send {quote['amount_usd']} USDC to {quote['wallet']}")
print(f"Memo: {quote['memo']}")TypeScript SDK
import { TensorFeed } from 'tensorfeed';
const tf = new TensorFeed();
const quote = await tf.buyCredits({ amountUsd: 1.0 });
console.log(`Send ${quote.amount_usd} USDC to ${quote.wallet}`);FAQ
How much USDC should I send?
Send exactly the amount_usd from the quote. The on-chain verification compares the received amount against the quoted amount within $0.01; if it matches, you get the quoted credits including any volume discount. If you send more or less, credits are calculated from the actual amount at the base rate.
How long is the quote valid?
30 minutes. After expiry, the quote is unusable and you must request a new one. The /api/payment/confirm call without a nonce uses the actual tx amount at base rate, so a refresh is rarely necessary.