tensorfeed 1.3.0__tar.gz → 1.19.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tensorfeed
3
- Version: 1.3.0
4
- Summary: Python SDK for the TensorFeed.ai API: AI news, status, model pricing, premium history series + routing, agent payments via USDC on Base (optional web3 auto-send)
3
+ Version: 1.19.0
4
+ Summary: Python SDK for the TensorFeed.ai API: AI news, status, model pricing, premium routing + history series + webhook watches, agent payments via USDC on Base (optional web3 auto-send)
5
5
  Author-email: "TensorFeed.ai" <feedback@tensorfeed.ai>
6
6
  License-Expression: MIT
7
7
  Project-URL: Homepage, https://tensorfeed.ai
@@ -24,6 +24,12 @@ Description-Content-Type: text/markdown
24
24
  Provides-Extra: web3
25
25
  Requires-Dist: web3>=6.0; extra == "web3"
26
26
  Requires-Dist: eth-account>=0.10; extra == "web3"
27
+ Provides-Extra: langchain
28
+ Requires-Dist: langchain-core>=0.3; extra == "langchain"
29
+ Provides-Extra: llamaindex
30
+ Requires-Dist: llama-index-core>=0.11; extra == "llamaindex"
31
+ Provides-Extra: crewai
32
+ Requires-Dist: crewai>=0.70; extra == "crewai"
27
33
 
28
34
  # tensorfeed
29
35
 
@@ -117,6 +123,31 @@ diff = tf.history_compare(
117
123
  )
118
124
  print(f'{len(diff["changed"])} price changes, {len(diff["added"])} new models')
119
125
 
126
+ # Premium webhook watches (1 credit per registration, free reads)
127
+ created = tf.create_watch(
128
+ spec={
129
+ "type": "price",
130
+ "model": "Claude Opus 4.7",
131
+ "field": "blended",
132
+ "op": "lt",
133
+ "threshold": 30,
134
+ },
135
+ callback_url="https://agent.example.com/hook",
136
+ secret="any-shared-secret", # used to sign deliveries
137
+ )
138
+ watch_id = created["watch"]["id"]
139
+ print(f"Watch {watch_id} active until {created['watch']['expires_at']}")
140
+
141
+ # When a delivery arrives, verify it:
142
+ # sig = request.headers["X-TensorFeed-Signature"] # "sha256=<hex>"
143
+ # import hmac, hashlib
144
+ # expected = "sha256=" + hmac.new(b"any-shared-secret", body, hashlib.sha256).hexdigest()
145
+ # assert hmac.compare_digest(sig, expected)
146
+
147
+ print(tf.list_watches()) # see all your active watches
148
+ print(tf.get_watch(watch_id)) # check fire_count, last_fired_at
149
+ tf.delete_watch(watch_id) # remove when done
150
+
120
151
  # Check remaining credits
121
152
  print(tf.balance())
122
153
  ```
@@ -212,11 +243,24 @@ except TensorFeedError as e:
212
243
  | Method | Cost | Description |
213
244
  |--------|------|-------------|
214
245
  | `tf.balance()` | Free | Check remaining credits |
246
+ | `tf.usage()` | Free | Per-token call history (last 100 calls aggregated by endpoint) |
215
247
  | `tf.routing(task=, budget=, top_n=, weights=)` | 1 credit | Top-N ranked routing with full detail |
216
248
  | `tf.pricing_series(model=, from_date=, to_date=)` | 1 credit | Daily price points for one model with min/max/delta summary |
217
249
  | `tf.benchmark_series(model=, benchmark=, from_date=, to_date=)` | 1 credit | Score evolution for a benchmark on one model, returns delta_pp |
218
250
  | `tf.status_uptime(provider=, from_date=, to_date=)` | 1 credit | Uptime % per provider with incident days (degraded = half) |
219
251
  | `tf.history_compare(from_date=, to_date=, snapshot_type=)` | 1 credit | Diff two snapshots: added, removed, changed entries with deltas |
252
+ | `tf.create_watch(spec=, callback_url=, secret=, fire_cap=)` | 1 credit | Register a webhook watch (price / status / digest) |
253
+ | `tf.create_digest_watch(cadence=, callback_url=, secret=, fire_cap=)` | 1 credit | Convenience: scheduled daily/weekly digest of pricing changes |
254
+ | `tf.list_watches()` | Free | List all active watches owned by the current token |
255
+ | `tf.get_watch(watch_id)` | Free | Read one watch including fire_count and last_fired_at |
256
+ | `tf.delete_watch(watch_id)` | Free | Remove an owned watch |
257
+ | `tf.premium_agents_directory(category=, status=, sort=, limit=, ...)` | 1 credit | Enriched directory: status, news, traffic, pricing, trending_score per agent |
258
+ | `tf.news_search(q=, from_date=, to_date=, provider=, category=, limit=)` | 1 credit | Full-text news search with date/provider filters, relevance scoring, recency boost |
259
+ | `tf.cost_projection(models=, input_tokens_per_day=, output_tokens_per_day=, horizon=)` | 1 credit | Project workload cost across 1-10 models, 4 horizons, cheapest-monthly ranking |
260
+ | `tf.forecast(target=, model=, field=, benchmark=, lookback=, horizon=)` | 1 credit | Linear-regression forecast for a price or benchmark series with 95% CI and confidence label |
261
+ | `tf.provider_deepdive(provider)` | 1 credit | One provider's full profile: status + all models + benchmarks joined + news + traffic |
262
+ | `tf.compare_models(ids=)` | 1 credit | Side-by-side compare of 2-5 models with normalized benchmarks + rankings |
263
+ | `tf.whats_new(days=, news_limit=)` | 1 credit | Agent morning brief: pricing changes + incidents + top news from last 1-7 days |
220
264
 
221
265
  ### Auto-send (requires `tensorfeed[web3]`)
222
266
 
@@ -239,11 +283,15 @@ If any source disagrees, do not send.
239
283
 
240
284
  ## Premium Data Terms
241
285
 
242
- 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.
286
+ 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 (Section 17.1 of the [Terms](https://tensorfeed.ai/terms#premium)).
287
+
288
+ ## No refunds; credits do not expire
289
+
290
+ All credit purchases are final and non-refundable per Section 17.5 of the [Terms](https://tensorfeed.ai/terms#premium). Credits never expire and are jointly redeemable on tensorfeed.ai and terminalfeed.io. The recommended pattern is to buy in small increments (for example, $1 USDC for 50 credits) until call volume is calibrated, then top up as needed.
243
291
 
244
- ## Refunds
292
+ ## Sanctions
245
293
 
246
- Email `evan@tensorfeed.ai` with the tx hash within 24 hours of the charge for a manual USDC refund.
294
+ Premium API access is unavailable to persons or entities subject to OFAC, EU, UK, or UN sanctions, and to residents of comprehensively sanctioned jurisdictions (Cuba, Iran, North Korea, Syria, Crimea, Donetsk, Luhansk). Inbound credit-purchase transactions are screened against the Chainalysis public sanctions API. See Section 17.9 of the [Terms](https://tensorfeed.ai/terms#premium).
247
295
 
248
296
  ## Links
249
297
 
@@ -1,257 +1,272 @@
1
- Metadata-Version: 2.4
2
- Name: tensorfeed
3
- Version: 1.3.0
4
- Summary: Python SDK for the TensorFeed.ai API: AI news, status, model pricing, premium history series + routing, agent payments via USDC on Base (optional web3 auto-send)
5
- Author-email: "TensorFeed.ai" <feedback@tensorfeed.ai>
6
- License-Expression: MIT
7
- Project-URL: Homepage, https://tensorfeed.ai
8
- Project-URL: Documentation, https://tensorfeed.ai/developers/agent-payments
9
- Project-URL: Repository, https://github.com/RipperMercs/tensorfeed
10
- Project-URL: Bug Tracker, https://github.com/RipperMercs/tensorfeed/issues
11
- Project-URL: Changelog, https://tensorfeed.ai/changelog
12
- Keywords: tensorfeed,ai,agents,x402,usdc,base,model-routing,llm,api,stablecoin
13
- Classifier: Development Status :: 4 - Beta
14
- Classifier: Intended Audience :: Developers
15
- Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.9
17
- Classifier: Programming Language :: Python :: 3.10
18
- Classifier: Programming Language :: Python :: 3.11
19
- Classifier: Programming Language :: Python :: 3.12
20
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
- Requires-Python: >=3.9
23
- Description-Content-Type: text/markdown
24
- Provides-Extra: web3
25
- Requires-Dist: web3>=6.0; extra == "web3"
26
- Requires-Dist: eth-account>=0.10; extra == "web3"
27
-
28
- # tensorfeed
29
-
30
- Python SDK for the [TensorFeed.ai](https://tensorfeed.ai) API.
31
-
32
- 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.
33
-
34
- ## Install
35
-
36
- ```bash
37
- pip install tensorfeed
38
- ```
39
-
40
- Stdlib-only. No external dependencies.
41
-
42
- ## Free Tier
43
-
44
- ```python
45
- from tensorfeed import TensorFeed
46
-
47
- tf = TensorFeed()
48
-
49
- # News
50
- for article in tf.news(category="research", limit=10)["articles"]:
51
- print(article["title"])
52
-
53
- # Live AI service status
54
- for svc in tf.status()["services"]:
55
- print(f'{svc["name"]}: {svc["status"]}')
56
-
57
- # Is a service down?
58
- print(tf.is_down("claude"))
59
-
60
- # Model pricing and benchmarks
61
- print(tf.models())
62
- print(tf.benchmarks())
63
-
64
- # Daily history snapshots (the moat)
65
- print(tf.history()) # list of available dates
66
- print(tf.history_snapshot("2026-04-27", "pricing"))
67
-
68
- # Free routing preview (top-1 model, 5 calls/day per IP)
69
- preview = tf.routing_preview(task="code")
70
- print(preview["recommendation"])
71
- ```
72
-
73
- ## Premium Tier (paid, USDC on Base)
74
-
75
- ```python
76
- from tensorfeed import TensorFeed, PaymentRequired
77
-
78
- tf = TensorFeed()
79
-
80
- # Step 1: get a 30-minute quote
81
- quote = tf.buy_credits(amount_usd=1.00)
82
- print(f"Send {quote['amount_usd']} USDC on Base to {quote['wallet']}")
83
- print(f"Memo: {quote['memo']} (expires in {quote['ttl_seconds']}s)")
84
- print(f"Will get: {quote['credits']} credits")
85
-
86
- # Step 2: send the USDC tx with your wallet
87
- # (auto-send via web3 is on the roadmap; for v1.1 you sign and send manually)
88
-
89
- # Step 3: confirm with the tx hash
90
- result = tf.confirm(tx_hash="0xYOUR_TX_HASH", nonce=quote["memo"])
91
- print(f"Got {result['credits']} credits, token: {result['token']}")
92
- # The token is also stored on `tf` automatically; routing() will use it.
93
-
94
- # Step 4: call premium endpoints
95
- rec = tf.routing(task="code", budget=5.0, top_n=5)
96
- for r in rec["recommendations"]:
97
- print(f'#{r["rank"]}: {r["model"]["name"]} (score: {r["composite_score"]:.2f})')
98
-
99
- # Custom routing weights
100
- rec = tf.routing(
101
- task="general",
102
- weights={"quality": 0.6, "cost": 0.3, "availability": 0.1, "latency": 0.0},
103
- )
104
-
105
- # Premium history series (1 credit each, range default = last 30 days, max 90)
106
- prices = tf.pricing_series(model="Claude Opus 4.7")
107
- print(f'Price changed {prices["summary"]["delta_pct_blended"]}% over the window')
108
-
109
- scores = tf.benchmark_series(model="Claude Opus 4.7", benchmark="swe_bench")
110
- print(f'SWE-bench moved {scores["summary"]["delta_pp"]} pp')
111
-
112
- uptime = tf.status_uptime(provider="anthropic")
113
- print(f'Anthropic uptime: {uptime["uptime_pct"]}% over {uptime["days_with_data"]} days')
114
-
115
- diff = tf.history_compare(
116
- from_date="2026-04-01", to_date="2026-04-27", snapshot_type="pricing",
117
- )
118
- print(f'{len(diff["changed"])} price changes, {len(diff["added"])} new models')
119
-
120
- # Check remaining credits
121
- print(tf.balance())
122
- ```
123
-
124
- ## Auto-Send (optional, web3 extra)
125
-
126
- The base SDK keeps you dependency-free, but if you want to skip the manual tx step, install with the `web3` extra:
127
-
128
- ```bash
129
- pip install 'tensorfeed[web3]'
130
- ```
131
-
132
- Then `tf.purchase_credits()` quotes, signs, broadcasts, and confirms in one call:
133
-
134
- ```python
135
- import os
136
- from tensorfeed import TensorFeed
137
-
138
- tf = TensorFeed()
139
-
140
- result = tf.purchase_credits(
141
- amount_usd=1.00,
142
- private_key=os.environ["TENSORFEED_PRIVATE_KEY"], # NEVER hardcode
143
- # rpc_url="https://base-mainnet.g.alchemy.com/v2/<key>", # optional
144
- )
145
- print(result["token"]) # auto-stored on tf
146
- print(result["tx_hash"]) # for your records
147
- print(result["credits"]) # how many credits were minted
148
-
149
- # Token already on tf, so:
150
- rec = tf.routing(task="code")
151
- ```
152
-
153
- 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.
154
-
155
- ## Reusing a Token Across Sessions
156
-
157
- Save the token after `confirm()`. Reuse it next time:
158
-
159
- ```python
160
- # Save once
161
- token = result["token"]
162
-
163
- # Reuse in another process / job
164
- tf = TensorFeed(token=token)
165
- print(tf.balance())
166
- rec = tf.routing(task="code")
167
- ```
168
-
169
- ## Error Handling
170
-
171
- ```python
172
- from tensorfeed import TensorFeed, PaymentRequired, RateLimited, TensorFeedError
173
-
174
- tf = TensorFeed(token="bad_token")
175
- try:
176
- tf.routing(task="code")
177
- except PaymentRequired as e:
178
- # 402: token invalid, expired, or out of credits
179
- # e.payload contains wallet, credits required, top_up_at, etc.
180
- print("Need to top up:", e.payload)
181
- except RateLimited as e:
182
- # 429: free preview tier hit its 5/day per-IP limit
183
- print("Hit the rate limit:", e.payload)
184
- except TensorFeedError as e:
185
- # Other API errors
186
- print("API error", e.status_code, e.payload)
187
- ```
188
-
189
- ## API Reference
190
-
191
- ### Free
192
-
193
- | Method | Description |
194
- |--------|-------------|
195
- | `tf.news(category=, limit=)` | Latest AI news articles |
196
- | `tf.status()` | Real-time AI service status |
197
- | `tf.status_summary()` | Lightweight status summary |
198
- | `tf.models()` | Model pricing and specs |
199
- | `tf.benchmarks()` | Benchmark scores |
200
- | `tf.is_down(service_name)` | Check if a specific service is down |
201
- | `tf.agent_activity()` | Agent traffic metrics |
202
- | `tf.history()` | List of available daily snapshot dates |
203
- | `tf.history_snapshot(date, type)` | Read a specific snapshot |
204
- | `tf.routing_preview(task=)` | Top-1 routing recommendation (5/day/IP) |
205
- | `tf.health()` | API health check |
206
- | `tf.payment_info()` | Wallet, pricing, supported payment flows |
207
- | `tf.buy_credits(amount_usd=)` | Generate a 30-min payment quote |
208
- | `tf.confirm(tx_hash=, nonce=)` | Verify USDC tx, mint credit token |
209
-
210
- ### Token-required
211
-
212
- | Method | Cost | Description |
213
- |--------|------|-------------|
214
- | `tf.balance()` | Free | Check remaining credits |
215
- | `tf.routing(task=, budget=, top_n=, weights=)` | 1 credit | Top-N ranked routing with full detail |
216
- | `tf.pricing_series(model=, from_date=, to_date=)` | 1 credit | Daily price points for one model with min/max/delta summary |
217
- | `tf.benchmark_series(model=, benchmark=, from_date=, to_date=)` | 1 credit | Score evolution for a benchmark on one model, returns delta_pp |
218
- | `tf.status_uptime(provider=, from_date=, to_date=)` | 1 credit | Uptime % per provider with incident days (degraded = half) |
219
- | `tf.history_compare(from_date=, to_date=, snapshot_type=)` | 1 credit | Diff two snapshots: added, removed, changed entries with deltas |
220
-
221
- ### Auto-send (requires `tensorfeed[web3]`)
222
-
223
- | Method | Description |
224
- |--------|-------------|
225
- | `tf.purchase_credits(amount_usd=, private_key=, rpc_url=)` | One-call quote + sign + broadcast + confirm. Returns token, credits, tx_hash, block_number. |
226
-
227
- ## Wallet & Trust
228
-
229
- The TensorFeed payment wallet is `0x549c82e6bfc54bdae9a2073744cbc2af5d1fc6d1` on Base mainnet. USDC contract: `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`.
230
-
231
- Cross-check this address before sending funds at:
232
-
233
- - https://tensorfeed.ai/llms.txt
234
- - https://tensorfeed.ai/api/payment/info
235
- - https://github.com/RipperMercs/tensorfeed (README)
236
- - https://x.com/tensorfeed (bio)
237
-
238
- If any source disagrees, do not send.
239
-
240
- ## Premium Data Terms
241
-
242
- 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.
243
-
244
- ## Refunds
245
-
246
- Email `evan@tensorfeed.ai` with the tx hash within 24 hours of the charge for a manual USDC refund.
247
-
248
- ## Links
249
-
250
- - [API Docs](https://tensorfeed.ai/developers)
251
- - [TensorFeed.ai](https://tensorfeed.ai)
252
- - [GitHub](https://github.com/RipperMercs/tensorfeed)
253
- - [Changelog](https://tensorfeed.ai/changelog)
254
-
255
- ## License
256
-
257
- MIT
1
+ # tensorfeed
2
+
3
+ Python SDK for the [TensorFeed.ai](https://tensorfeed.ai) API.
4
+
5
+ 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.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install tensorfeed
11
+ ```
12
+
13
+ Stdlib-only. No external dependencies.
14
+
15
+ ## Free Tier
16
+
17
+ ```python
18
+ from tensorfeed import TensorFeed
19
+
20
+ tf = TensorFeed()
21
+
22
+ # News
23
+ for article in tf.news(category="research", limit=10)["articles"]:
24
+ print(article["title"])
25
+
26
+ # Live AI service status
27
+ for svc in tf.status()["services"]:
28
+ print(f'{svc["name"]}: {svc["status"]}')
29
+
30
+ # Is a service down?
31
+ print(tf.is_down("claude"))
32
+
33
+ # Model pricing and benchmarks
34
+ print(tf.models())
35
+ print(tf.benchmarks())
36
+
37
+ # Daily history snapshots (the moat)
38
+ print(tf.history()) # list of available dates
39
+ print(tf.history_snapshot("2026-04-27", "pricing"))
40
+
41
+ # Free routing preview (top-1 model, 5 calls/day per IP)
42
+ preview = tf.routing_preview(task="code")
43
+ print(preview["recommendation"])
44
+ ```
45
+
46
+ ## Premium Tier (paid, USDC on Base)
47
+
48
+ ```python
49
+ from tensorfeed import TensorFeed, PaymentRequired
50
+
51
+ tf = TensorFeed()
52
+
53
+ # Step 1: get a 30-minute quote
54
+ quote = tf.buy_credits(amount_usd=1.00)
55
+ print(f"Send {quote['amount_usd']} USDC on Base to {quote['wallet']}")
56
+ print(f"Memo: {quote['memo']} (expires in {quote['ttl_seconds']}s)")
57
+ print(f"Will get: {quote['credits']} credits")
58
+
59
+ # Step 2: send the USDC tx with your wallet
60
+ # (auto-send via web3 is on the roadmap; for v1.1 you sign and send manually)
61
+
62
+ # Step 3: confirm with the tx hash
63
+ result = tf.confirm(tx_hash="0xYOUR_TX_HASH", nonce=quote["memo"])
64
+ print(f"Got {result['credits']} credits, token: {result['token']}")
65
+ # The token is also stored on `tf` automatically; routing() will use it.
66
+
67
+ # Step 4: call premium endpoints
68
+ rec = tf.routing(task="code", budget=5.0, top_n=5)
69
+ for r in rec["recommendations"]:
70
+ print(f'#{r["rank"]}: {r["model"]["name"]} (score: {r["composite_score"]:.2f})')
71
+
72
+ # Custom routing weights
73
+ rec = tf.routing(
74
+ task="general",
75
+ weights={"quality": 0.6, "cost": 0.3, "availability": 0.1, "latency": 0.0},
76
+ )
77
+
78
+ # Premium history series (1 credit each, range default = last 30 days, max 90)
79
+ prices = tf.pricing_series(model="Claude Opus 4.7")
80
+ print(f'Price changed {prices["summary"]["delta_pct_blended"]}% over the window')
81
+
82
+ scores = tf.benchmark_series(model="Claude Opus 4.7", benchmark="swe_bench")
83
+ print(f'SWE-bench moved {scores["summary"]["delta_pp"]} pp')
84
+
85
+ uptime = tf.status_uptime(provider="anthropic")
86
+ print(f'Anthropic uptime: {uptime["uptime_pct"]}% over {uptime["days_with_data"]} days')
87
+
88
+ diff = tf.history_compare(
89
+ from_date="2026-04-01", to_date="2026-04-27", snapshot_type="pricing",
90
+ )
91
+ print(f'{len(diff["changed"])} price changes, {len(diff["added"])} new models')
92
+
93
+ # Premium webhook watches (1 credit per registration, free reads)
94
+ created = tf.create_watch(
95
+ spec={
96
+ "type": "price",
97
+ "model": "Claude Opus 4.7",
98
+ "field": "blended",
99
+ "op": "lt",
100
+ "threshold": 30,
101
+ },
102
+ callback_url="https://agent.example.com/hook",
103
+ secret="any-shared-secret", # used to sign deliveries
104
+ )
105
+ watch_id = created["watch"]["id"]
106
+ print(f"Watch {watch_id} active until {created['watch']['expires_at']}")
107
+
108
+ # When a delivery arrives, verify it:
109
+ # sig = request.headers["X-TensorFeed-Signature"] # "sha256=<hex>"
110
+ # import hmac, hashlib
111
+ # expected = "sha256=" + hmac.new(b"any-shared-secret", body, hashlib.sha256).hexdigest()
112
+ # assert hmac.compare_digest(sig, expected)
113
+
114
+ print(tf.list_watches()) # see all your active watches
115
+ print(tf.get_watch(watch_id)) # check fire_count, last_fired_at
116
+ tf.delete_watch(watch_id) # remove when done
117
+
118
+ # Check remaining credits
119
+ print(tf.balance())
120
+ ```
121
+
122
+ ## Auto-Send (optional, web3 extra)
123
+
124
+ The base SDK keeps you dependency-free, but if you want to skip the manual tx step, install with the `web3` extra:
125
+
126
+ ```bash
127
+ pip install 'tensorfeed[web3]'
128
+ ```
129
+
130
+ Then `tf.purchase_credits()` quotes, signs, broadcasts, and confirms in one call:
131
+
132
+ ```python
133
+ import os
134
+ from tensorfeed import TensorFeed
135
+
136
+ tf = TensorFeed()
137
+
138
+ result = tf.purchase_credits(
139
+ amount_usd=1.00,
140
+ private_key=os.environ["TENSORFEED_PRIVATE_KEY"], # NEVER hardcode
141
+ # rpc_url="https://base-mainnet.g.alchemy.com/v2/<key>", # optional
142
+ )
143
+ print(result["token"]) # auto-stored on tf
144
+ print(result["tx_hash"]) # for your records
145
+ print(result["credits"]) # how many credits were minted
146
+
147
+ # Token already on tf, so:
148
+ rec = tf.routing(task="code")
149
+ ```
150
+
151
+ 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.
152
+
153
+ ## Reusing a Token Across Sessions
154
+
155
+ Save the token after `confirm()`. Reuse it next time:
156
+
157
+ ```python
158
+ # Save once
159
+ token = result["token"]
160
+
161
+ # Reuse in another process / job
162
+ tf = TensorFeed(token=token)
163
+ print(tf.balance())
164
+ rec = tf.routing(task="code")
165
+ ```
166
+
167
+ ## Error Handling
168
+
169
+ ```python
170
+ from tensorfeed import TensorFeed, PaymentRequired, RateLimited, TensorFeedError
171
+
172
+ tf = TensorFeed(token="bad_token")
173
+ try:
174
+ tf.routing(task="code")
175
+ except PaymentRequired as e:
176
+ # 402: token invalid, expired, or out of credits
177
+ # e.payload contains wallet, credits required, top_up_at, etc.
178
+ print("Need to top up:", e.payload)
179
+ except RateLimited as e:
180
+ # 429: free preview tier hit its 5/day per-IP limit
181
+ print("Hit the rate limit:", e.payload)
182
+ except TensorFeedError as e:
183
+ # Other API errors
184
+ print("API error", e.status_code, e.payload)
185
+ ```
186
+
187
+ ## API Reference
188
+
189
+ ### Free
190
+
191
+ | Method | Description |
192
+ |--------|-------------|
193
+ | `tf.news(category=, limit=)` | Latest AI news articles |
194
+ | `tf.status()` | Real-time AI service status |
195
+ | `tf.status_summary()` | Lightweight status summary |
196
+ | `tf.models()` | Model pricing and specs |
197
+ | `tf.benchmarks()` | Benchmark scores |
198
+ | `tf.is_down(service_name)` | Check if a specific service is down |
199
+ | `tf.agent_activity()` | Agent traffic metrics |
200
+ | `tf.history()` | List of available daily snapshot dates |
201
+ | `tf.history_snapshot(date, type)` | Read a specific snapshot |
202
+ | `tf.routing_preview(task=)` | Top-1 routing recommendation (5/day/IP) |
203
+ | `tf.health()` | API health check |
204
+ | `tf.payment_info()` | Wallet, pricing, supported payment flows |
205
+ | `tf.buy_credits(amount_usd=)` | Generate a 30-min payment quote |
206
+ | `tf.confirm(tx_hash=, nonce=)` | Verify USDC tx, mint credit token |
207
+
208
+ ### Token-required
209
+
210
+ | Method | Cost | Description |
211
+ |--------|------|-------------|
212
+ | `tf.balance()` | Free | Check remaining credits |
213
+ | `tf.usage()` | Free | Per-token call history (last 100 calls aggregated by endpoint) |
214
+ | `tf.routing(task=, budget=, top_n=, weights=)` | 1 credit | Top-N ranked routing with full detail |
215
+ | `tf.pricing_series(model=, from_date=, to_date=)` | 1 credit | Daily price points for one model with min/max/delta summary |
216
+ | `tf.benchmark_series(model=, benchmark=, from_date=, to_date=)` | 1 credit | Score evolution for a benchmark on one model, returns delta_pp |
217
+ | `tf.status_uptime(provider=, from_date=, to_date=)` | 1 credit | Uptime % per provider with incident days (degraded = half) |
218
+ | `tf.history_compare(from_date=, to_date=, snapshot_type=)` | 1 credit | Diff two snapshots: added, removed, changed entries with deltas |
219
+ | `tf.create_watch(spec=, callback_url=, secret=, fire_cap=)` | 1 credit | Register a webhook watch (price / status / digest) |
220
+ | `tf.create_digest_watch(cadence=, callback_url=, secret=, fire_cap=)` | 1 credit | Convenience: scheduled daily/weekly digest of pricing changes |
221
+ | `tf.list_watches()` | Free | List all active watches owned by the current token |
222
+ | `tf.get_watch(watch_id)` | Free | Read one watch including fire_count and last_fired_at |
223
+ | `tf.delete_watch(watch_id)` | Free | Remove an owned watch |
224
+ | `tf.premium_agents_directory(category=, status=, sort=, limit=, ...)` | 1 credit | Enriched directory: status, news, traffic, pricing, trending_score per agent |
225
+ | `tf.news_search(q=, from_date=, to_date=, provider=, category=, limit=)` | 1 credit | Full-text news search with date/provider filters, relevance scoring, recency boost |
226
+ | `tf.cost_projection(models=, input_tokens_per_day=, output_tokens_per_day=, horizon=)` | 1 credit | Project workload cost across 1-10 models, 4 horizons, cheapest-monthly ranking |
227
+ | `tf.forecast(target=, model=, field=, benchmark=, lookback=, horizon=)` | 1 credit | Linear-regression forecast for a price or benchmark series with 95% CI and confidence label |
228
+ | `tf.provider_deepdive(provider)` | 1 credit | One provider's full profile: status + all models + benchmarks joined + news + traffic |
229
+ | `tf.compare_models(ids=)` | 1 credit | Side-by-side compare of 2-5 models with normalized benchmarks + rankings |
230
+ | `tf.whats_new(days=, news_limit=)` | 1 credit | Agent morning brief: pricing changes + incidents + top news from last 1-7 days |
231
+
232
+ ### Auto-send (requires `tensorfeed[web3]`)
233
+
234
+ | Method | Description |
235
+ |--------|-------------|
236
+ | `tf.purchase_credits(amount_usd=, private_key=, rpc_url=)` | One-call quote + sign + broadcast + confirm. Returns token, credits, tx_hash, block_number. |
237
+
238
+ ## Wallet & Trust
239
+
240
+ The TensorFeed payment wallet is `0x549c82e6bfc54bdae9a2073744cbc2af5d1fc6d1` on Base mainnet. USDC contract: `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`.
241
+
242
+ Cross-check this address before sending funds at:
243
+
244
+ - https://tensorfeed.ai/llms.txt
245
+ - https://tensorfeed.ai/api/payment/info
246
+ - https://github.com/RipperMercs/tensorfeed (README)
247
+ - https://x.com/tensorfeed (bio)
248
+
249
+ If any source disagrees, do not send.
250
+
251
+ ## Premium Data Terms
252
+
253
+ 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 (Section 17.1 of the [Terms](https://tensorfeed.ai/terms#premium)).
254
+
255
+ ## No refunds; credits do not expire
256
+
257
+ All credit purchases are final and non-refundable per Section 17.5 of the [Terms](https://tensorfeed.ai/terms#premium). Credits never expire and are jointly redeemable on tensorfeed.ai and terminalfeed.io. The recommended pattern is to buy in small increments (for example, $1 USDC for 50 credits) until call volume is calibrated, then top up as needed.
258
+
259
+ ## Sanctions
260
+
261
+ Premium API access is unavailable to persons or entities subject to OFAC, EU, UK, or UN sanctions, and to residents of comprehensively sanctioned jurisdictions (Cuba, Iran, North Korea, Syria, Crimea, Donetsk, Luhansk). Inbound credit-purchase transactions are screened against the Chainalysis public sanctions API. See Section 17.9 of the [Terms](https://tensorfeed.ai/terms#premium).
262
+
263
+ ## Links
264
+
265
+ - [API Docs](https://tensorfeed.ai/developers)
266
+ - [TensorFeed.ai](https://tensorfeed.ai)
267
+ - [GitHub](https://github.com/RipperMercs/tensorfeed)
268
+ - [Changelog](https://tensorfeed.ai/changelog)
269
+
270
+ ## License
271
+
272
+ MIT