@blockrun/llm 1.2.0 → 1.3.0

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.
package/README.md CHANGED
@@ -1,6 +1,9 @@
1
- # @blockrun/llm
1
+ # @blockrun/llm (TypeScript SDK)
2
2
 
3
- Pay-per-request access to GPT-4o, Claude 4, Gemini 3.1, and more via x402 micropayments on Base and Solana.
3
+ > **@blockrun/llm** is a TypeScript/Node.js SDK for accessing 40+ large language models (GPT-5, Claude, Gemini, Grok, DeepSeek, Kimi, and more) with automatic pay-per-request USDC micropayments via the x402 protocol. No API keys required — your wallet signature is your authentication. Supports Base and Solana chains.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@blockrun/llm.svg)](https://www.npmjs.com/package/@blockrun/llm)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
4
7
 
5
8
  **Networks:**
6
9
  - **Base Mainnet:** Chain ID 8453 - Production with real USDC
@@ -159,6 +162,7 @@ const tweet = await client.chat('xai/grok-3-mini', 'What is trending on X?', { s
159
162
  ### MiniMax
160
163
  | Model | Input Price | Output Price |
161
164
  |-------|-------------|--------------|
165
+ | `minimax/minimax-m2.7` | $0.30/M | $1.20/M |
162
166
  | `minimax/minimax-m2.5` | $0.30/M | $1.20/M |
163
167
 
164
168
  ### NVIDIA (Free & Hosted)
@@ -343,6 +347,67 @@ const [gpt, claude, gemini] = await Promise.all([
343
347
  ]);
344
348
  ```
345
349
 
350
+ ## Prediction Markets (Powered by Predexon)
351
+
352
+ Access real-time prediction market data from Polymarket, Kalshi, and Binance Futures via [Predexon](https://predexon.com). No API keys needed — pay-per-request via x402.
353
+
354
+ ### Polymarket
355
+
356
+ ```typescript
357
+ import { LLMClient } from '@blockrun/llm';
358
+
359
+ const client = new LLMClient();
360
+
361
+ // List markets with optional filters ($0.001/request)
362
+ const markets = await client.pm("polymarket/markets");
363
+ const filtered = await client.pm("polymarket/markets", { status: "active", limit: 10 });
364
+ const searched = await client.pm("polymarket/markets", { search: "bitcoin" });
365
+
366
+ // List events ($0.001/request)
367
+ const events = await client.pm("polymarket/events");
368
+
369
+ // Historical trades ($0.001/request)
370
+ const trades = await client.pm("polymarket/trades");
371
+
372
+ // OHLCV candlestick data for a specific condition ($0.001/request)
373
+ const candles = await client.pm("polymarket/candlesticks/0x1234abcd...");
374
+
375
+ // Wallet profile ($0.005/request — tier 2)
376
+ const profile = await client.pm("polymarket/wallet/0xABC123...");
377
+
378
+ // Wallet P&L ($0.005/request — tier 2)
379
+ const pnl = await client.pm("polymarket/wallet/pnl/0xABC123...");
380
+
381
+ // Global leaderboard ($0.001/request)
382
+ const leaderboard = await client.pm("polymarket/leaderboard");
383
+ ```
384
+
385
+ ### Kalshi & Binance
386
+
387
+ ```typescript
388
+ // Kalshi markets ($0.001/request)
389
+ const kalshiMarkets = await client.pm("kalshi/markets");
390
+
391
+ // Kalshi trades ($0.001/request)
392
+ const kalshiTrades = await client.pm("kalshi/trades");
393
+
394
+ // Binance candles for supported pairs ($0.001/request)
395
+ const btcCandles = await client.pm("binance/candles/BTCUSDT");
396
+ const ethCandles = await client.pm("binance/candles/ETHUSDT");
397
+ // Also: SOLUSDT, XRPUSDT
398
+ ```
399
+
400
+ ### Cross-Platform
401
+
402
+ ```typescript
403
+ // Cross-platform matching pairs ($0.001/request)
404
+ const pairs = await client.pm("matching-markets/pairs");
405
+ ```
406
+
407
+ All current endpoints are GET. The `pmQuery()` method is available for future POST endpoints.
408
+
409
+ Works on both `LLMClient` (Base) and `SolanaLLMClient`.
410
+
346
411
  ## Configuration
347
412
 
348
413
  ```typescript
@@ -493,6 +558,84 @@ import {
493
558
  } from '@blockrun/llm';
494
559
  ```
495
560
 
561
+ ## Agent Wallet Setup
562
+
563
+ One-line setup for agent runtimes (Claude Code skills, MCP servers, etc.):
564
+
565
+ ```typescript
566
+ import { setupAgentWallet } from '@blockrun/llm';
567
+
568
+ // Auto-creates wallet if none exists, returns ready client
569
+ const client = setupAgentWallet();
570
+ const response = await client.chat('openai/gpt-5.4', 'Hello!');
571
+ ```
572
+
573
+ For Solana:
574
+
575
+ ```typescript
576
+ import { setupAgentSolanaWallet } from '@blockrun/llm';
577
+
578
+ const client = await setupAgentSolanaWallet();
579
+ const response = await client.chat('anthropic/claude-sonnet-4.6', 'Hello!');
580
+ ```
581
+
582
+ Check wallet status:
583
+
584
+ ```typescript
585
+ import { status } from '@blockrun/llm';
586
+
587
+ await status();
588
+ // Wallet: 0xCC8c...5EF8
589
+ // Balance: $5.30 USDC
590
+ ```
591
+
592
+ ## Wallet Scanning
593
+
594
+ The SDK auto-detects wallets from any provider on your system:
595
+
596
+ ```typescript
597
+ import { scanWallets, scanSolanaWallets } from '@blockrun/llm';
598
+
599
+ // Scans ~/.<dir>/wallet.json for Base wallets
600
+ const baseWallets = scanWallets();
601
+
602
+ // Scans ~/.<dir>/solana-wallet.json and ~/.brcc/wallet.json
603
+ const solWallets = scanSolanaWallets();
604
+ ```
605
+
606
+ `getOrCreateWallet()` checks scanned wallets first, so if you already have a wallet from another BlockRun tool, it will be reused automatically.
607
+
608
+ ## Response Caching
609
+
610
+ The SDK caches responses to avoid duplicate payments:
611
+
612
+ ```typescript
613
+ import { getCachedByRequest, saveToCache, clearCache } from '@blockrun/llm';
614
+
615
+ // Automatic TTLs by endpoint:
616
+ // - X/Twitter: 1 hour
617
+ // - Search: 15 minutes
618
+ // - Models: 24 hours
619
+ // - Chat/Image: no cache (every call is unique)
620
+
621
+ // Manual cache management
622
+ clearCache(); // Remove all cached responses
623
+ ```
624
+
625
+ ## Cost Logging
626
+
627
+ Track spending across sessions:
628
+
629
+ ```typescript
630
+ import { logCost, getCostSummary } from '@blockrun/llm';
631
+
632
+ // Costs are logged to ~/.blockrun/data/costs.jsonl
633
+ const summary = getCostSummary();
634
+ console.log(`Total: $${summary.totalUsd.toFixed(2)}`);
635
+ console.log(`Calls: ${summary.calls}`);
636
+ console.log(`By model:`, summary.byModel);
637
+ ```
638
+
496
639
  ## Links
497
640
 
498
641
  - [Website](https://blockrun.ai)
@@ -500,6 +643,23 @@ import {
500
643
  - [GitHub](https://github.com/blockrunai/blockrun-llm-ts)
501
644
  - [Telegram](https://t.me/+mroQv4-4hGgzOGUx)
502
645
 
646
+ ## Frequently Asked Questions
647
+
648
+ ### What is @blockrun/llm?
649
+ @blockrun/llm is a TypeScript SDK that provides pay-per-request access to 40+ large language models from OpenAI, Anthropic, Google, xAI, DeepSeek, Moonshot, and more. It uses the x402 protocol for automatic USDC micropayments — no API keys, no subscriptions, no vendor lock-in.
650
+
651
+ ### How does payment work?
652
+ When you make an API call, the SDK automatically handles x402 payment. It signs a USDC transaction locally using your wallet private key (which never leaves your machine), and includes the payment proof in the request header. Settlement is non-custodial and instant on Base or Solana.
653
+
654
+ ### What is smart routing / ClawRouter?
655
+ ClawRouter is a built-in smart routing engine that analyzes your request across 14 dimensions and automatically picks the cheapest model capable of handling it. Routing happens locally in under 1ms. It can save up to 78% on LLM costs compared to using premium models for every request.
656
+
657
+ ### How much does it cost?
658
+ Pay only for what you use. Prices start at $0.0002 per request (GPT-5 Nano). There are no minimums, subscriptions, or monthly fees. $5 in USDC gets you thousands of requests.
659
+
660
+ ### Does it support both Base and Solana?
661
+ Yes. Use `LLMClient` for Base (EVM) payments and `SolanaLLMClient` for Solana payments. Same API, different payment chain.
662
+
503
663
  ## License
504
664
 
505
665
  MIT