Skip to main content

Python SDK for the TensorFeed.ai API: AI news, status, model pricing, and agent-payable premium routing (USDC on Base, optional auto-send via web3)

Project description

tensorfeed

Python SDK for the TensorFeed.ai API.

Free endpoints (news, status, models, benchmarks, history, routing preview) need no auth. The premium tier (top-N routing, plus more endpoints landing later) is paid via USDC on Base. No accounts, no API keys, no traditional payment processors.

Install

pip install tensorfeed

Stdlib-only. No external dependencies.

Free Tier

from tensorfeed import TensorFeed

tf = TensorFeed()

# News
for article in tf.news(category="research", limit=10)["articles"]:
    print(article["title"])

# Live AI service status
for svc in tf.status()["services"]:
    print(f'{svc["name"]}: {svc["status"]}')

# Is a service down?
print(tf.is_down("claude"))

# Model pricing and benchmarks
print(tf.models())
print(tf.benchmarks())

# Daily history snapshots (the moat)
print(tf.history())  # list of available dates
print(tf.history_snapshot("2026-04-27", "pricing"))

# Free routing preview (top-1 model, 5 calls/day per IP)
preview = tf.routing_preview(task="code")
print(preview["recommendation"])

Premium Tier (paid, USDC on Base)

from tensorfeed import TensorFeed, PaymentRequired

tf = TensorFeed()

# Step 1: get a 30-minute quote
quote = tf.buy_credits(amount_usd=1.00)
print(f"Send {quote['amount_usd']} USDC on Base to {quote['wallet']}")
print(f"Memo: {quote['memo']} (expires in {quote['ttl_seconds']}s)")
print(f"Will get: {quote['credits']} credits")

# Step 2: send the USDC tx with your wallet
# (auto-send via web3 is on the roadmap; for v1.1 you sign and send manually)

# Step 3: confirm with the tx hash
result = tf.confirm(tx_hash="0xYOUR_TX_HASH", nonce=quote["memo"])
print(f"Got {result['credits']} credits, token: {result['token']}")
# The token is also stored on `tf` automatically; routing() will use it.

# Step 4: call premium endpoints
rec = tf.routing(task="code", budget=5.0, top_n=5)
for r in rec["recommendations"]:
    print(f'#{r["rank"]}: {r["model"]["name"]} (score: {r["composite_score"]:.2f})')

# Custom routing weights
rec = tf.routing(
    task="general",
    weights={"quality": 0.6, "cost": 0.3, "availability": 0.1, "latency": 0.0},
)

# Check remaining credits
print(tf.balance())

Auto-Send (optional, web3 extra)

The base SDK keeps you dependency-free, but if you want to skip the manual tx step, install with the web3 extra:

pip install 'tensorfeed[web3]'

Then tf.purchase_credits() quotes, signs, broadcasts, and confirms in one call:

import os
from tensorfeed import TensorFeed

tf = TensorFeed()

result = tf.purchase_credits(
    amount_usd=1.00,
    private_key=os.environ["TENSORFEED_PRIVATE_KEY"],  # NEVER hardcode
    # rpc_url="https://base-mainnet.g.alchemy.com/v2/<key>",  # optional
)
print(result["token"])      # auto-stored on tf
print(result["tx_hash"])    # for your records
print(result["credits"])    # how many credits were minted

# Token already on tf, so:
rec = tf.routing(task="code")

Security: read the key from a secret manager or env var. Never commit it. The raw key is held in memory only for the duration of one signing call.

Reusing a Token Across Sessions

Save the token after confirm(). Reuse it next time:

# Save once
token = result["token"]

# Reuse in another process / job
tf = TensorFeed(token=token)
print(tf.balance())
rec = tf.routing(task="code")

Error Handling

from tensorfeed import TensorFeed, PaymentRequired, RateLimited, TensorFeedError

tf = TensorFeed(token="bad_token")
try:
    tf.routing(task="code")
except PaymentRequired as e:
    # 402: token invalid, expired, or out of credits
    # e.payload contains wallet, credits required, top_up_at, etc.
    print("Need to top up:", e.payload)
except RateLimited as e:
    # 429: free preview tier hit its 5/day per-IP limit
    print("Hit the rate limit:", e.payload)
except TensorFeedError as e:
    # Other API errors
    print("API error", e.status_code, e.payload)

API Reference

Free

Method Description
tf.news(category=, limit=) Latest AI news articles
tf.status() Real-time AI service status
tf.status_summary() Lightweight status summary
tf.models() Model pricing and specs
tf.benchmarks() Benchmark scores
tf.is_down(service_name) Check if a specific service is down
tf.agent_activity() Agent traffic metrics
tf.history() List of available daily snapshot dates
tf.history_snapshot(date, type) Read a specific snapshot
tf.routing_preview(task=) Top-1 routing recommendation (5/day/IP)
tf.health() API health check
tf.payment_info() Wallet, pricing, supported payment flows
tf.buy_credits(amount_usd=) Generate a 30-min payment quote
tf.confirm(tx_hash=, nonce=) Verify USDC tx, mint credit token

Token-required

Method Cost Description
tf.balance() Free Check remaining credits
tf.routing(task=, budget=, top_n=, weights=) 1 credit Top-N ranked routing with full detail

Auto-send (requires tensorfeed[web3])

Method Description
tf.purchase_credits(amount_usd=, private_key=, rpc_url=) One-call quote + sign + broadcast + confirm. Returns token, credits, tx_hash, block_number.

Wallet & Trust

The TensorFeed payment wallet is 0x549c82e6bfc54bdae9a2073744cbc2af5d1fc6d1 on Base mainnet. USDC contract: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913.

Cross-check this address before sending funds at:

If any source disagrees, do not send.

Premium Data Terms

Premium API responses are licensed for inference use only. Use of TensorFeed premium data for training, fine-tuning, evaluation, or distillation of ML models is prohibited.

Refunds

Email evan@tensorfeed.ai with the tx hash within 24 hours of the charge for a manual USDC refund.

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tensorfeed-1.2.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tensorfeed-1.2.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file tensorfeed-1.2.0.tar.gz.

File metadata

  • Download URL: tensorfeed-1.2.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for tensorfeed-1.2.0.tar.gz
Algorithm Hash digest
SHA256 8afa660599641f1fba78652a4cc248ea93aec2cdbf8b8a4664dc33df2cc91377
MD5 4dd073924d03ce183fa42498c1a76003
BLAKE2b-256 2b259862bbffebf47400b40e74f8e1240c87917e082af52188281ffc9d27cae9

See more details on using hashes here.

File details

Details for the file tensorfeed-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: tensorfeed-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for tensorfeed-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ad334faa3068478db6d129d71913a0e73efd14f8eb2cba38523f885ef62cbf6
MD5 1608c2a02fd1cccbbf53420db4f4d0ba
BLAKE2b-256 d61e11cdd4999b16a0a344f43042f20e662305b2ef2f3d16db155a2e74864b9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page