Agent payments integration
Make your AI agent pay TensorFeed (or your own pay-per-call API) in USDC on Base mainnet. End-to-end SDK paths, MCP integration, and the validate-and-charge contract for sister-site Workers. No accounts, no API keys, no Stripe.
Path 1: One-call purchase via the Python SDK
The shortest path for an agent that already has a private key for a Base wallet:
# pip install 'tensorfeed[web3]'
from tensorfeed import TensorFeed
tf = TensorFeed()
result = tf.purchase_credits(
amount_usd=1.0,
private_key="0x...", # never hardcode; read from env or secret manager
)
# Token is auto-stored on tf. Premium calls just work.
rec = tf.routing(task="code", top_n=3)
print(tf.balance()) # ~49 credits remainingUnder the hood this calls /api/payment/buy-credits, signs and broadcasts the USDC transfer via web3.py, then calls /api/payment/confirm. End-to-end takes 5-10 seconds the first time; subsequent premium calls are 50ms.
Path 2: Manual flow (any language)
If you do not want a web3 dependency in your agent, do the three steps yourself:
# 1. Quote
curl -X POST https://tensorfeed.ai/api/payment/buy-credits \
-H "Content-Type: application/json" \
-d '{"amount_usd": 1.0}'
# -> {"wallet": "0x549...", "memo": "tf-...", "credits": 50, ...}
# 2. Send USDC on Base to the wallet using your wallet of choice
# (Rabby, Coinbase Wallet, MetaMask on Base, AgentKit, etc.)
# 3. Confirm
curl -X POST https://tensorfeed.ai/api/payment/confirm \
-H "Content-Type: application/json" \
-d '{"tx_hash": "0x...", "nonce": "tf-..."}'
# -> {"token": "tf_live_...", "balance": 50}
# 4. Use
curl https://tensorfeed.ai/api/premium/routing?task=code \
-H "Authorization: Bearer tf_live_..."Path 3: x402 fallback (no pre-flight)
For one-shot discovery calls where you do not want to pre-commit to credits, hit any premium endpoint without auth. The 402 response includes payment instructions; retry with X-Payment-Tx: 0x... after sending the USDC. Latency is 3-5 seconds (on-chain confirmation) instead of 50ms, so this is best for discovery, not repeat use.
# Discover the endpoint
curl https://tensorfeed.ai/api/premium/routing
# -> 402 Payment Required + payment instructions
# Send USDC on Base to the wallet from the response, then:
curl https://tensorfeed.ai/api/premium/routing?task=code \
-H "X-Payment-Tx: 0x..."
# -> data + bearer token in X-Payment-Token headerPath 4: MCP integration (Claude Desktop / Code)
If your agent is an MCP-aware client, drop the TensorFeed MCP server into config. The token lives in an env var; the server reads it on each tool call:
{
"mcpServers": {
"tensorfeed": {
"command": "npx",
"args": ["-y", "@tensorfeed/mcp-server"],
"env": { "TENSORFEED_TOKEN": "tf_live_..." }
}
}
}22 tools become available to the model: 5 free (news, status, pricing, etc.) and 17 premium (routing, news search, history series, cost projection, forecasting, provider deep-dive, model comparison, webhook watches, etc.). The model decides which tools to call; you pay 1 credit per premium tool invocation.
Cross-site bundle
TensorFeed exposes /api/internal/validate-and-charge so sister-site Workers (TerminalFeed.io today, future Pizza Robot Studios products tomorrow) can validate the same bearer token and debit credits over HTTP. Server-to- server only, gated by an X-Internal-Auth shared secret, never exposed to agents directly. The result: agents buy credits once, spend them on either site. The architecture is in the build retrospective.
Wallet attestation
Before any agent sends real USDC, it should cross-check the wallet across the four published locations. We publish the address at:
- /llms.txt
- /api/payment/info (also lists the operator: Pizza Robot Studios LLC, California, USA)
- GitHub README
- @tensorfeed bio on X
If any of the four disagree, do not send. The address is currently0x549c82e6bfc54bdae9a2073744cbc2af5d1fc6d1on Base mainnet.
If you are building your own agent-payable API
The full architectural argument is in the originals: why USDC on Base over Stripe (link), how validation works end-to-end (link), and a 50-line MCP server reference (link). The TensorFeed source is on GitHub if you want to crib the payment middleware directly.
Recommended endpoints (in priority order)
/api/payment/info— wallet, pricing, supported flows, attestation/api/payment/buy-credits— quote a credit purchase/api/payment/confirm— verify USDC tx on-chain, mint bearer token/api/payment/balance— check remaining credits/.well-known/x402— x402 V2 discovery manifest with all paid endpoints