Skip to content
All systems operational0 AI providers monitored, polled every 2 minutes
Live status
All use cases

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 remaining

Under 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 header (only there, never the body)
# Store that header value as a secret and keep header dumps out of logs

Path 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_..." }
    }
  }
}

24 tools become available to the model, each with free preview tiers plus paid full results: news, status, pricing on the free side, then routing, history series, provider deep-dive, model comparison, and webhook watches once a token is set. The model decides which tools to call; you pay 1 credit per paid full-result invocation.

Credit federation

TensorFeed credits are redeemable on tensorfeed.ai. Credit federation, where a sister-site Worker validates the same bearer token and debits credits over HTTP (server-to-server only, gated by an X-Internal-Auth shared secret, never exposed to agents directly), is a documented AFTA pattern with no current members. The contract is in the whitepaper, and the original build is in the build retrospective.

Wallet attestation

Before any agent sends real USDC, it should cross-check the wallet across the three published locations. We publish the address at:

If any of the three 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)