@blockrun/llm 4.2.0 โ 4.2.1
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 +40 -26
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ console.log(r.response); // the proof
|
|
|
44
44
|
## Why This SDK
|
|
45
45
|
|
|
46
46
|
- ๐ง **Smart routing that pays for itself.** The bundled [Router Core V3](https://github.com/BlockRunAI/router-core) engine (shared with [ClawRouter](https://github.com/BlockRunAI/ClawRouter)) classifies every request locally in <1ms across <!-- br:clawrouter.dimensions -->15<!-- /br:clawrouter.dimensions --> dimensions and routes to the cheapest capable model.
|
|
47
|
-
- ๐ **<!-- br:models.free -->9<!-- /br:models.free --> genuinely free models.** $0 in and out, including two 1M-context Nemotrons, two that accept images,
|
|
47
|
+
- ๐ **<!-- br:models.free -->9<!-- /br:models.free --> genuinely free models.** $0 in and out, including two 1M-context Nemotrons, two that accept images, a 1M-context MiniMax and a free Poolside coding model.
|
|
48
48
|
- ๐ **Two ways to connect.** A **BlockRun API key** billed against account credit ([sign up](https://user.blockrun.ai), [create a key](https://user.blockrun.ai/dashboard/keys), [add credit](https://user.blockrun.ai/dashboard/credits)), or a wallet signature with x402 micropayments and no account at all. Same code either way.
|
|
49
49
|
- ๐ธ **Pay per request in USDC.** x402 micropayments on Solana, Base or Arc. Agents can fund and pay their own way.
|
|
50
50
|
- ๐ก๏ธ **Automatic failover.** Transient errors (timeouts, 429, 5xx) before payment walk the router's ranked fallback chain instead of failing your request; a failure after a payment was sent never buys a second model.
|
|
@@ -111,6 +111,7 @@ The Anthropic SDK is a runtime dependency because the public compatibility wrapp
|
|
|
111
111
|
| Try it for $0 | [Try It Free](#try-it-free-no-usdc-required) and [Free Tier](#free-tier) |
|
|
112
112
|
| Understand wallet payments and settlement | [How Payment Works](#how-payment-works) |
|
|
113
113
|
| Pay from a Solana wallet | [Solana Support](#solana-support) |
|
|
114
|
+
| Pay with USDC on Circle's Arc | [Arc Support](#arc-support) |
|
|
114
115
|
| Enable metered batch settlement | [Batch settlement](#batch-settlement-optional-metered-billing) and the [full reference](https://github.com/BlockRunAI/blockrun-llm-ts/blob/main/docs/solana-batch.md) |
|
|
115
116
|
| Stream tokens, use tools | [Chat, Tools and Streaming](#chat-tools-and-streaming) |
|
|
116
117
|
| Generate media or query data services | [Models and Service APIs](#models-and-service-apis) |
|
|
@@ -227,7 +228,7 @@ console.log(result.response); // 'The capital of France is Paris.'
|
|
|
227
228
|
console.log(result.routing.savings); // 1 (100%)
|
|
228
229
|
```
|
|
229
230
|
|
|
230
|
-
The
|
|
231
|
+
The free models to pin are listed under [Free Tier](#free-tier). `eco` lands on
|
|
231
232
|
a free model when one can handle the request and moves to the cheapest paid
|
|
232
233
|
model when none can; pin a free id when the call must cost $0.
|
|
233
234
|
|
|
@@ -404,7 +405,7 @@ anchors the portfolio's candidate pool):
|
|
|
404
405
|
|
|
405
406
|
| Tier | Example Tasks | ECO | AUTO | PREMIUM |
|
|
406
407
|
|------|---------------|-----|------|---------|
|
|
407
|
-
| SIMPLE | "What is the capital of France?", definitions | nemotron-3.5-lightning (**FREE**) | gemini-2.5-flash | gemini-
|
|
408
|
+
| SIMPLE | "What is the capital of France?", definitions | nemotron-3.5-lightning (**FREE**) | gemini-2.5-flash | gemini-3.5-flash |
|
|
408
409
|
| MEDIUM | Code snippets, explanations | glm-5.3-flash | gemini-3.5-flash | gpt-5.3-codex |
|
|
409
410
|
| COMPLEX | Architecture, long documents | glm-5.3-flash | gemini-3.1-pro | claude-fable-5 |
|
|
410
411
|
| REASONING | Proofs, multi-step reasoning | deepseek-reasoner | deepseek-reasoner | claude-sonnet-5 |
|
|
@@ -437,7 +438,7 @@ picked:
|
|
|
437
438
|
| `costEstimate` / `baselineCost` | Estimated cost of the pick vs that baseline, in USD |
|
|
438
439
|
| `confidence` | Sigmoid-calibrated classifier confidence, 0โ1 |
|
|
439
440
|
| `routerVersion` | `'v3-portfolio'` or `'v2-rules'` |
|
|
440
|
-
| `profile` |
|
|
441
|
+
| `profile` | Tier set the decision used: `'auto'`, `'eco'`, `'premium'`, or `'agentic'` (the router's own set for agentic requests; not a `routingProfile` you can pass) |
|
|
441
442
|
| `reasoning` | Human-readable explanation of the decision |
|
|
442
443
|
| `tierConfigs` | The tier โ primary/fallback map the decision was made against |
|
|
443
444
|
|
|
@@ -639,6 +640,7 @@ own default applies, and some default to their highest effort (Reflection Beam
|
|
|
639
640
|
defaults to `"max"`); reasoning tokens bill as output:
|
|
640
641
|
|
|
641
642
|
```typescript
|
|
643
|
+
const messages = [{ role: 'user' as const, content: 'Summarize x402 in one line' }];
|
|
642
644
|
const quick = await client.chatCompletion('reflection/beam-1.0-501b-a23b', messages, {
|
|
643
645
|
reasoningEffort: 'low', // none | minimal | low | medium | high | xhigh | max, per model
|
|
644
646
|
maxTokens: 8192, // reasoning counts toward max_tokens
|
|
@@ -648,9 +650,12 @@ const quick = await client.chatCompletion('reflection/beam-1.0-501b-a23b', messa
|
|
|
648
650
|
`costUsd`, `settlement` and the per-call `timeout` work the same on `LLMClient`
|
|
649
651
|
(Base / Arc). Both clients default to a 600 s request timeout
|
|
650
652
|
(`BLOCKRUN_CHAT_TIMEOUT`, in seconds, overrides it; the `timeout` option, in
|
|
651
|
-
ms, overrides both)
|
|
652
|
-
charged
|
|
653
|
-
|
|
653
|
+
ms, overrides both). A call aborted after its payment was sent may already
|
|
654
|
+
have been charged; under Solana batch settlement such a call raises
|
|
655
|
+
`BatchPaymentUnresolvedError` rather than being paid again (see
|
|
656
|
+
[Batch settlement](#batch-settlement-optional-metered-billing)).
|
|
657
|
+
|
|
658
|
+
`costUsd` is what the call added to `getSpending()`: the signed price under `exact`, the metered `extra.chargedAmount` under batch settlement,
|
|
654
659
|
`0` for a free model; it is undefined in API-key mode (billed to the account).
|
|
655
660
|
When the gateway answers a paid request from a free fallback model it skips
|
|
656
661
|
settlement: `costUsd` is `0`, `settlement.skipped` is `"free-fallback"`, and
|
|
@@ -734,6 +739,7 @@ await client.closeBatchChannel();
|
|
|
734
739
|
- **Never pays twice.** Anything that goes wrong before a batch payment is sent falls back to `exact`. Once one is sent, a call whose payment may have been charged throws `BatchPaymentUnresolvedError` and is never paid again (no new payment, no `exact`, no fallback model).
|
|
735
740
|
- **Chat, buffered and streamed.** `chat`, `chatCompletion`, `smartChat`, `smartChatCompletion` and `stream()` use batch; media jobs pay `exact`. A stream's receipt arrives as a final SSE event the SDK reads and removes before your loop sees it (it never reaches your chunks), or, for a stream that is cut, from `POST /v1/batch/receipt` afterwards. Its charge is booked in `getSpending()` once that receipt is in, which can be a few seconds after your loop ends: the model may keep generating after a disconnect, and that is charged too.
|
|
736
741
|
- **One channel per wallet.** All clients for a wallet share one channel, saved to `~/.blockrun/solana-batch/<wallet>.json` (mode `0600`) so a restart reuses it.
|
|
742
|
+
- **One call at a time per wallet.** A channel carries one pending authorization, and each voucher builds on the previous call's metered charge, which is known only once that call's answer is in. So the wallet stays busy from payment until the answer is reconciled: the whole generation, and for `stream()` the whole stream (including a stream your loop stopped reading: the SDK keeps reading it to its receipt, because everything generated is charged). A concurrent chat call on the same wallet (`chat`, `chatCompletion`, `smartChat`, `smartChatCompletion`, `stream()`) falls back to `exact` meanwhile, reported as `channel_busy`; it does not queue. For parallel batch calls, give each worker its own wallet ([#98](https://github.com/BlockRunAI/blockrun-llm-ts/issues/98) tracks queueing and multi-channel options).
|
|
737
743
|
- **One process per wallet.** The process that opens the channel holds its store's lock until it exits. Other processes on that wallet (worker pools, PM2/cluster workers, parallel runs) pay `exact`, reported as `channel_store_locked`. Give each worker its own wallet, or route calls through one process. `batch.onLocked: "wait"` waits up to `batch.lockWaitMs` (default 60 s) for the lock, and `"throw"` raises `BatchChannelLockedError` (unpaid, nothing signed) instead of paying `exact`.
|
|
738
744
|
- **Observable.** Every fallback, backoff, recovery and re-read writes one stderr line; `batch.onEvent` and `client.getBatchStats()` expose the same events and counters.
|
|
739
745
|
|
|
@@ -760,7 +766,7 @@ The 402 from that host names `eip155:5042`, and the SDK signs the EIP-3009 autho
|
|
|
760
766
|
|
|
761
767
|
**Setup:**
|
|
762
768
|
1. Same wallet key as Base: `export BASE_CHAIN_WALLET_KEY="0x..."`
|
|
763
|
-
2. Fund it with USDC on Arc (Arc's native token
|
|
769
|
+
2. Fund it with USDC on Arc (Arc's native gas token; the SDK pays through its ERC-20 interface at `0x3600โฆ0000`)
|
|
764
770
|
3. `apiUrl: 'https://arc.blockrun.ai/api'` โ payments are automatic via x402
|
|
765
771
|
|
|
766
772
|
**Endpoint:** `https://arc.blockrun.ai/api` ยท **Payment:** USDC on Arc (chain 5042), settled by Circle
|
|
@@ -808,9 +814,10 @@ console.log(result.choices[0].message.content);
|
|
|
808
814
|
### Streaming
|
|
809
815
|
|
|
810
816
|
Every client streams with automatic payment. On `LLMClient` in Base / Arc
|
|
811
|
-
wallet mode, `chatCompletionStream()` also keeps a **pre-auth cache**:
|
|
812
|
-
first call
|
|
813
|
-
(about
|
|
817
|
+
wallet mode, `chatCompletionStream()` also keeps a **pre-auth cache**: once a
|
|
818
|
+
first call has learned a model's price, later calls to that model sign the
|
|
819
|
+
payment before sending and skip the 402 round-trip (about 200 ms saved per
|
|
820
|
+
request).
|
|
814
821
|
|
|
815
822
|
#### OpenAI-compatible (recommended)
|
|
816
823
|
|
|
@@ -871,8 +878,10 @@ while (true) {
|
|
|
871
878
|
yields each `data:` frame already parsed as JSON and stops at `[DONE]`. The
|
|
872
879
|
x402 handshake happens before the first frame โ 402, sign an SPL
|
|
873
880
|
TransferChecked authorization locally, replay with `PAYMENT-SIGNATURE` โ
|
|
874
|
-
including the fresh-blockhash re-sign on a verification-phase rejection.
|
|
875
|
-
|
|
881
|
+
including the fresh-blockhash re-sign on a verification-phase rejection. When
|
|
882
|
+
the client is constructed with `batch`, the stream is paid with a channel
|
|
883
|
+
voucher instead and charged the metered cost (see [Batch settlement](#batch-settlement-optional-metered-billing)).
|
|
884
|
+
A free model, or an account key, is answered `200` with no handshake at all and
|
|
876
885
|
settles nothing. Pass a concrete model id: `stream()` does not resolve the
|
|
877
886
|
`blockrun/*` aliases.
|
|
878
887
|
|
|
@@ -928,16 +937,17 @@ prefix, or let `routingProfile: 'eco'` rank them first.
|
|
|
928
937
|
| `nvidia/nemotron-3.5-lightning` | 1M | Thinking-mode reasoning at 1M context |
|
|
929
938
|
| `nvidia/nemotron-3-ultra-550b` | 1M | Largest free model โ 550B, 1M context |
|
|
930
939
|
| `nvidia/nemotron-3-nano-omni-30b-a3b-reasoning` | 256K | Multimodal reasoning โ text + images |
|
|
940
|
+
| `nvidia/minimax-m3.1-flash` | 1M | MiniMax M3.1 Flash โ reasons, calls tools |
|
|
931
941
|
| `nvidia/nemotron-3.5-bolt` | 128K | Free vision โ verified on real image probes on Base and Solana |
|
|
932
942
|
| `poolside/laguna-xs-2.1` | 128K | Coding model |
|
|
933
943
|
|
|
934
944
|
A free model can be briefly marked unavailable in the live catalog while the
|
|
935
945
|
gateway's health check holds it back; it stays on the free tier.
|
|
936
946
|
|
|
937
|
-
`nvidia/llama-3.2-11b-vision`, `
|
|
938
|
-
still answer, but
|
|
939
|
-
|
|
940
|
-
|
|
947
|
+
`nvidia/llama-3.2-11b-vision`, `nvidia/nemotron-3-super-120b`,
|
|
948
|
+
`cohere/north-mini-code` and `nvidia/muse-glimmer-30b` still answer, but since
|
|
949
|
+
2026-11 the gateway serves them with a different model. Don't pin them; use
|
|
950
|
+
`nemotron-3.5-bolt` for free image input.
|
|
941
951
|
|
|
942
952
|
<details>
|
|
943
953
|
<summary><strong>Paid chat models</strong> โ OpenAI, Anthropic, Google, DeepSeek, xAI, Moonshot, MiniMax, Z.ai, Qwen, Mistral, Tencent, Poolside, Xiaomi</summary>
|
|
@@ -976,7 +986,6 @@ token price.
|
|
|
976
986
|
| `openai/gpt-5-mini` | 200K | |
|
|
977
987
|
| `openai/gpt-4.1` | 128K | |
|
|
978
988
|
| `openai/gpt-4.1-mini` | 128K | |
|
|
979
|
-
| `openai/gpt-4.1-nano` | 128K | |
|
|
980
989
|
| `openai/gpt-4o` | 128K | |
|
|
981
990
|
| `openai/gpt-4o-mini` | 128K | |
|
|
982
991
|
| `openai/o1` | 200K | Reasoning |
|
|
@@ -988,7 +997,8 @@ token price.
|
|
|
988
997
|
|
|
989
998
|
| Model | Context | Notes |
|
|
990
999
|
|---|---|---|
|
|
991
|
-
| `anthropic/claude-fable-5.
|
|
1000
|
+
| `anthropic/claude-fable-5.2` | 1M | Most capable โ successor to Fable 5.1 at a lower price, 128K output |
|
|
1001
|
+
| `anthropic/claude-fable-5.1` | 1M | Successor to Fable 5 at the same tier and price |
|
|
992
1002
|
| `anthropic/claude-fable-5` | 1M | Mythos-class flagship above Opus โ always-on thinking, 128K output |
|
|
993
1003
|
| `anthropic/claude-opus-5.5` | 1M | Newest Opus โ Opus-class reasoning at a lower price than Opus 5 |
|
|
994
1004
|
| `anthropic/claude-opus-5` | 1M | Flagship โ the baseline the routing savings claim is measured against |
|
|
@@ -1005,6 +1015,7 @@ token price.
|
|
|
1005
1015
|
|
|
1006
1016
|
| Model | Context |
|
|
1007
1017
|
|---|---|
|
|
1018
|
+
| `google/gemini-4-carbon` | 1M |
|
|
1008
1019
|
| `google/gemini-4-argon` | 1M |
|
|
1009
1020
|
| `google/gemini-3.1-pro` | 1M |
|
|
1010
1021
|
| `google/gemini-3.8-flash` | 1M |
|
|
@@ -1026,6 +1037,7 @@ paid SKU; the vision SKU is an experimental preview.
|
|
|
1026
1037
|
| Model | Context | Notes |
|
|
1027
1038
|
|---|---|---|
|
|
1028
1039
|
| `deepseek/deepseek-v4-pro` | 1M | V4 flagship โ strongest open-weight reasoner |
|
|
1040
|
+
| `deepseek/deepseek-v4.1-flash` | 1M | V4.1 Flash non-thinking |
|
|
1029
1041
|
| `deepseek/deepseek-v4-flash-vision-exp` | 1M | Experimental vision preview |
|
|
1030
1042
|
| `deepseek/deepseek-chat` | 1M | V4 Flash non-thinking |
|
|
1031
1043
|
| `deepseek/deepseek-reasoner` | 1M | V4 Flash thinking (same upstream, thinking on by default) |
|
|
@@ -1048,7 +1060,7 @@ callable โ the gateway redirects them to a healthy model.
|
|
|
1048
1060
|
|
|
1049
1061
|
| Model | Context | Notes |
|
|
1050
1062
|
|---|---|---|
|
|
1051
|
-
| `moonshot/kimi-k3` | 1M |
|
|
1063
|
+
| `moonshot/kimi-k3.1-pro` | 1M | Flagship, image + text input; `kimi-k3` stays callable but is unlisted |
|
|
1052
1064
|
| `minimax/minimax-m3` | 1M | |
|
|
1053
1065
|
| `minimax/minimax-m2.7` | 200K | |
|
|
1054
1066
|
| `zai/glm-5.3` | 1M | |
|
|
@@ -1196,7 +1208,8 @@ console.log(fused.data[0].url);
|
|
|
1196
1208
|
| `bytedance/seedance-2.0-mini` | 5s | 15s | 480p/720p, lowest-cost Seedance 2.0. RealFace supported |
|
|
1197
1209
|
| `bytedance/seedance-2.0` | 5s | 15s | Premium, up to 4K, synced audio. RealFace supported |
|
|
1198
1210
|
| `bytedance/seedance-2.5` | 5s | 30s | Long-form โ up to 30s, 480p/720p, multilingual, up to 30 reference images |
|
|
1199
|
-
|
|
1211
|
+
|
|
1212
|
+
Sora 2 (`azure/sora-2`, `openai/sora-2`) was retired by its providers on 2026-11-02 and is no longer served.
|
|
1200
1213
|
|
|
1201
1214
|
```typescript
|
|
1202
1215
|
import { VideoClient } from '@blockrun/llm';
|
|
@@ -1417,7 +1430,7 @@ Supported `StockMarket` values: `us, hk, jp, kr, gb, de, fr, nl, ie, lu, cn, ca`
|
|
|
1417
1430
|
Prediction-market data from Polymarket, Kalshi, Limitless, Opinion,
|
|
1418
1431
|
Predict.Fun, Binance Futures, UMA oracle resolutions and sports markets via
|
|
1419
1432
|
[Predexon](https://predexon.com). Every endpoint costs the same flat price per
|
|
1420
|
-
call
|
|
1433
|
+
call. Use an account API key or x402 wallet
|
|
1421
1434
|
payments; no separate Predexon key is needed. `pm()` works on both `LLMClient`
|
|
1422
1435
|
and `SolanaLLMClient`; query parameters are strings.
|
|
1423
1436
|
|
|
@@ -1593,8 +1606,9 @@ const gptResponse = await client.messages.create({
|
|
|
1593
1606
|
|
|
1594
1607
|
This wrapper proxies straight to the gateway's `/v1/messages` and does not
|
|
1595
1608
|
resolve `blockrun/*` aliases; pass a concrete model id. Anthropic's own dashed
|
|
1596
|
-
ids resolve, including the Mythos-class `claude-fable-5
|
|
1597
|
-
`claude-fable-5-1` / `claude-fable-5.1`
|
|
1609
|
+
ids resolve, including the Mythos-class `claude-fable-5`,
|
|
1610
|
+
`claude-fable-5-1` / `claude-fable-5.1` and `claude-fable-5-2` /
|
|
1611
|
+
`claude-fable-5.2` (1M context, always-on thinking).
|
|
1598
1612
|
|
|
1599
1613
|
## Wallets
|
|
1600
1614
|
|
|
@@ -1835,10 +1849,10 @@ A TypeScript SDK that cuts LLM costs by <!-- br:savings.autoVsBaselinePct -->84<
|
|
|
1835
1849
|
Router Core V3, bundled into the SDK: the same deterministic engine that powers ClawRouter. It analyzes each request across <!-- br:clawrouter.dimensions -->15<!-- /br:clawrouter.dimensions --> dimensions locally, in under 1ms, and picks the cheapest capable model. Use `smartChat()`, `smartChatCompletion()`, or the `blockrun/auto` model alias. See [Smart Routing](#smart-routing-router-core-v3).
|
|
1836
1850
|
|
|
1837
1851
|
### Does it support streaming?
|
|
1838
|
-
Yes: `LLMClient.chatCompletionStream()`, `stream: true` in the OpenAI-compatible client, and `
|
|
1852
|
+
Yes: `LLMClient.chatCompletionStream()`, `stream: true` in the OpenAI-compatible client, `SolanaLLMClient.stream()`, and `BlockrunClient.stream()`. The payment is signed before the first token (under Solana batch settlement the metered charge is booked once the stream's receipt arrives), and with an API key the stream is billed to your account.
|
|
1839
1853
|
|
|
1840
1854
|
### How much does it cost?
|
|
1841
|
-
Pay only for what you use: no minimums, subscriptions, or monthly fees, and
|
|
1855
|
+
Pay only for what you use: no minimums, subscriptions, or monthly fees, and the [free tier](#free-tier) costs $0. Live per-model rates are at [blockrun.ai/models](https://blockrun.ai/models).
|
|
1842
1856
|
|
|
1843
1857
|
### Do I need a crypto wallet?
|
|
1844
1858
|
No. An account API key from [user.blockrun.ai](https://user.blockrun.ai) works without any wallet or chain. Wallets are for x402 pay-per-request on Solana (`SolanaLLMClient`, recommended), Base or Arc (`LLMClient`).
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockrun/llm",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "TypeScript SDK for BlockRun - every frontier model behind one OpenAI-compatible client. Pay with a BlockRun API key or per-call in USDC. Smart routing picks the cheapest capable model. No rate limits.",
|
|
6
6
|
"main": "dist/index.cjs",
|