@blockrun/llm 2.13.0 → 3.1.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 +32 -49
- package/dist/index.cjs +262 -528
- package/dist/index.d.cts +127 -347
- package/dist/index.d.ts +127 -347
- package/dist/index.js +261 -526
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ Four call shapes cover every endpoint type:
|
|
|
83
83
|
- `stream<T>(path, body?)` — async iterator over SSE chunks (chat)
|
|
84
84
|
|
|
85
85
|
The per-API client classes (`LLMClient`, `ImageClient`, `VideoClient`,
|
|
86
|
-
`PortraitClient`, `VoiceClient`, `MusicClient`, `SearchClient`, `
|
|
86
|
+
`PortraitClient`, `VoiceClient`, `MusicClient`, `SearchClient`, `RpcClient`,
|
|
87
87
|
`PriceClient`, `SurfClient`) all remain — they will be soft-deprecated in 2.6 (rewritten as
|
|
88
88
|
shims over `BlockrunClient`) and removed in 3.0.
|
|
89
89
|
|
|
@@ -593,21 +593,6 @@ console.log(result.summary);
|
|
|
593
593
|
for (const url of result.citations ?? []) console.log(url);
|
|
594
594
|
```
|
|
595
595
|
|
|
596
|
-
### X/Twitter (AttentionVC)
|
|
597
|
-
|
|
598
|
-
`XClient` covers the full `/v1/x/*` endpoint family — previously the `X*`
|
|
599
|
-
types were exported but there was no client to call them with.
|
|
600
|
-
|
|
601
|
-
```ts
|
|
602
|
-
import { XClient } from '@blockrun/llm';
|
|
603
|
-
|
|
604
|
-
const x = new XClient();
|
|
605
|
-
const info = await x.userInfo('elonmusk');
|
|
606
|
-
const followers = await x.followers('paulg');
|
|
607
|
-
const results = await x.search('x402 micropayments', { queryType: 'Latest' });
|
|
608
|
-
const tweets = await x.userTweets({ username: 'vitalikbuterin', includeReplies: false });
|
|
609
|
-
```
|
|
610
|
-
|
|
611
596
|
### Surf Crypto Data
|
|
612
597
|
|
|
613
598
|
`SurfClient` exposes the full `/v1/surf/*` catalog — 84+ pay-per-call
|
|
@@ -684,6 +669,37 @@ const symbols = await p.listSymbols('crypto', { query: 'sol', limit: 20 });
|
|
|
684
669
|
|
|
685
670
|
Supported `StockMarket` values: `us, hk, jp, kr, gb, de, fr, nl, ie, lu, cn, ca`.
|
|
686
671
|
|
|
672
|
+
### DeFi Data, DEX Swaps & Cloud Compute
|
|
673
|
+
|
|
674
|
+
Three passthrough families live directly on `LLMClient` / `SolanaLLMClient`:
|
|
675
|
+
|
|
676
|
+
```ts
|
|
677
|
+
const client = new LLMClient();
|
|
678
|
+
|
|
679
|
+
// DefiLlama — protocols / TVL / yields / prices ($0.005/call, prices $0.001)
|
|
680
|
+
const protocols = await client.defiProtocols();
|
|
681
|
+
const aave = await client.defiProtocol('aave');
|
|
682
|
+
const prices = await client.defiPrices(['coingecko:bitcoin', 'base:0x833589...']);
|
|
683
|
+
|
|
684
|
+
// 0x DEX — swap + gasless quotes (FREE; BlockRun takes an on-chain affiliate
|
|
685
|
+
// fee on executed swaps instead of x402)
|
|
686
|
+
const quote = await client.dexQuote({
|
|
687
|
+
chainId: '8453', sellToken: '0x...', buyToken: '0x...',
|
|
688
|
+
sellAmount: '1000000', taker: '0xYourWallet',
|
|
689
|
+
});
|
|
690
|
+
const gq = await client.dexGaslessQuote({ /* ... */ });
|
|
691
|
+
const res = await client.dexGaslessSubmit({ trade: { /* signed eip712 */ } });
|
|
692
|
+
const status = await client.dexGaslessStatus(res.tradeHash as string);
|
|
693
|
+
|
|
694
|
+
// Modal — sandboxed compute ($0.01 create CPU / $0.05 GPU, $0.001 exec)
|
|
695
|
+
const sb = await client.modalSandboxCreate({ image: 'python:3.11' });
|
|
696
|
+
const out = await client.modalSandboxExec(sb.sandbox_id as string, ['python', '-c', 'print(42)']);
|
|
697
|
+
await client.modalSandboxTerminate(sb.sandbox_id as string);
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
Generic escape hatches: `client.defi(path, params)`, `client.dex(path, params, body?)`,
|
|
701
|
+
`client.modal(path, body)`.
|
|
702
|
+
|
|
687
703
|
### Multi-chain RPC
|
|
688
704
|
|
|
689
705
|
`RpcClient` wraps `POST /v1/rpc/{network}` — standard JSON-RPC 2.0 access to
|
|
@@ -737,38 +753,6 @@ gateway cache — same price, lower latency.
|
|
|
737
753
|
|
|
738
754
|
*Testnet models use flat pricing (no token counting) for simplicity.*
|
|
739
755
|
|
|
740
|
-
## X/Twitter Data (Powered by AttentionVC)
|
|
741
|
-
|
|
742
|
-
Access X/Twitter user profiles, followers, and followings via [AttentionVC](https://attentionvc.ai) partner API. No API keys needed — pay-per-request via x402.
|
|
743
|
-
|
|
744
|
-
```typescript
|
|
745
|
-
import { LLMClient } from '@blockrun/llm';
|
|
746
|
-
|
|
747
|
-
const client = new LLMClient();
|
|
748
|
-
|
|
749
|
-
// Look up user profiles ($0.002/user, min $0.02)
|
|
750
|
-
const users = await client.xUserLookup(['elonmusk', 'blockaborr']);
|
|
751
|
-
for (const user of users.users) {
|
|
752
|
-
console.log(`@${user.userName}: ${user.followers} followers`);
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
// Get followers ($0.05/page, ~200 accounts)
|
|
756
|
-
let result = await client.xFollowers('blockaborr');
|
|
757
|
-
for (const f of result.followers) {
|
|
758
|
-
console.log(` @${f.screen_name}`);
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
// Paginate through all followers
|
|
762
|
-
while (result.has_next_page) {
|
|
763
|
-
result = await client.xFollowers('blockaborr', result.next_cursor);
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
// Get followings ($0.05/page)
|
|
767
|
-
const followings = await client.xFollowings('blockaborr');
|
|
768
|
-
```
|
|
769
|
-
|
|
770
|
-
Works on both `LLMClient` (Base) and `SolanaLLMClient`.
|
|
771
|
-
|
|
772
756
|
## Standalone Search
|
|
773
757
|
|
|
774
758
|
Search web, X/Twitter, and news without using a chat model:
|
|
@@ -1290,7 +1274,6 @@ The SDK caches responses to avoid duplicate payments:
|
|
|
1290
1274
|
import { getCachedByRequest, saveToCache, clearCache } from '@blockrun/llm';
|
|
1291
1275
|
|
|
1292
1276
|
// Automatic TTLs by endpoint:
|
|
1293
|
-
// - X/Twitter: 1 hour
|
|
1294
1277
|
// - Search: 15 minutes
|
|
1295
1278
|
// - Models: 24 hours
|
|
1296
1279
|
// - Chat/Image: no cache (every call is unique)
|