@blockrun/llm 3.24.5 → 3.24.7
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 +3 -3
- package/dist/index.cjs +30 -7
- package/dist/index.js +30 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
### Cut your LLM bill by <!-- br:savings.autoVsBaselinePct -->84<!-- /br:savings.autoVsBaselinePct -->%. One line of TypeScript.
|
|
6
6
|
|
|
7
|
-
The smart-routing SDK for <!-- br:models.chatVisible -->
|
|
7
|
+
The smart-routing SDK for <!-- br:models.chatVisible -->90<!-- /br:models.chatVisible --> models — every request goes to the cheapest model that can handle it,
|
|
8
8
|
paid with an API key or per-request USDC on Solana, Base or Arc. No vendor lock-in.
|
|
9
9
|
|
|
10
10
|
[](https://www.npmjs.com/package/@blockrun/llm)
|
|
@@ -56,7 +56,7 @@ console.log(r.response); // the proof
|
|
|
56
56
|
| | OpenAI SDK | OpenRouter | LiteLLM | **@blockrun/llm** |
|
|
57
57
|
| ------------------ | -------------- | ----------------- | ---------------- | ----------------------------------------------------------------------- |
|
|
58
58
|
| **Cost routing** | ✗ one vendor | Manual selection | Manual selection | **Automatic — <!-- br:savings.autoVsBaselinePct -->84<!-- /br:savings.autoVsBaselinePct -->% cheaper** |
|
|
59
|
-
| **Models** | GPT only | 200+ | 100+ (BYO keys) | **<!-- br:models.chatVisible -->
|
|
59
|
+
| **Models** | GPT only | 200+ | 100+ (BYO keys) | **<!-- br:models.chatVisible -->90<!-- /br:models.chatVisible -->, one credential** |
|
|
60
60
|
| **Free tier** | ✗ | Rate-limited | ✗ | **<!-- br:models.free -->7<!-- /br:models.free --> models, no signup** |
|
|
61
61
|
| **Auth** | API key | Account + API key | Your API keys | **API key *or* wallet signature** |
|
|
62
62
|
| **Payment** | Card + invoice | Credit card | BYO keys | **Account credit or USDC per-request** |
|
|
@@ -1811,7 +1811,7 @@ to pick up security fixes.
|
|
|
1811
1811
|
## Frequently Asked Questions
|
|
1812
1812
|
|
|
1813
1813
|
### What is @blockrun/llm?
|
|
1814
|
-
A TypeScript SDK that cuts LLM costs by <!-- br:savings.autoVsBaselinePct -->84<!-- /br:savings.autoVsBaselinePct -->% on a realistic workload with built-in smart routing: every request goes to the cheapest of <!-- br:models.chatVisible -->
|
|
1814
|
+
A TypeScript SDK that cuts LLM costs by <!-- br:savings.autoVsBaselinePct -->84<!-- /br:savings.autoVsBaselinePct -->% on a realistic workload with built-in smart routing: every request goes to the cheapest of <!-- br:models.chatVisible -->90<!-- /br:models.chatVisible --> models (OpenAI, Anthropic, Google, xAI, DeepSeek, Moonshot, and more) that can handle it, paid with an account API key or per-request USDC via x402 on Solana, Base or Arc.
|
|
1815
1815
|
|
|
1816
1816
|
### What is smart routing?
|
|
1817
1817
|
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).
|
package/dist/index.cjs
CHANGED
|
@@ -571,7 +571,7 @@ function withCost(body, response, bookedUsd, scheme) {
|
|
|
571
571
|
// src/client.ts
|
|
572
572
|
var import_accounts2 = require("viem/accounts");
|
|
573
573
|
|
|
574
|
-
// node_modules/.pnpm/@blockrun+router-core@https+++codeload.github.com+BlockRunAI+router-core+tar.gz+
|
|
574
|
+
// node_modules/.pnpm/@blockrun+router-core@https+++codeload.github.com+BlockRunAI+router-core+tar.gz+fd6d03d035ff6_meidvh7c7i3y7wjjl6r2ymc4py/node_modules/@blockrun/router-core/dist/index.js
|
|
575
575
|
var UNSEGMENTED_SCRIPT = /[-ۿ -ヿ㐀-䶿一-鿿가-豈--]/;
|
|
576
576
|
var WORD_CHAR = /[\p{L}\p{N}]/u;
|
|
577
577
|
var ASCII_PHRASE = /^[a-z0-9' -]+$/;
|
|
@@ -2903,10 +2903,10 @@ function isEligible(modelId, features, maxOutputTokens, options) {
|
|
|
2903
2903
|
return model.contextWindow >= (features.estimatedInputTokens + maxOutputTokens) * 1.1;
|
|
2904
2904
|
}
|
|
2905
2905
|
function estimatedCost(modelId, options, inputTokens, outputTokens) {
|
|
2906
|
-
const
|
|
2907
|
-
if (!
|
|
2908
|
-
if (
|
|
2909
|
-
return (inputTokens *
|
|
2906
|
+
const price2 = options.modelPricing.get(modelId);
|
|
2907
|
+
if (!price2) return Number.POSITIVE_INFINITY;
|
|
2908
|
+
if (price2.flatPrice !== void 0) return price2.flatPrice;
|
|
2909
|
+
return (inputTokens * price2.inputPrice + outputTokens * price2.outputPrice) / 1e6;
|
|
2910
2910
|
}
|
|
2911
2911
|
function profileScore(modelId, options, now) {
|
|
2912
2912
|
const profile = options.modelPerformance?.[modelId] ?? LIVE_MODEL_PROFILES[modelId] ?? HISTORICAL_MODEL_PROFILES[modelId];
|
|
@@ -5089,7 +5089,7 @@ function getCostSummary() {
|
|
|
5089
5089
|
}
|
|
5090
5090
|
|
|
5091
5091
|
// src/version.ts
|
|
5092
|
-
var SDK_VERSION = "3.24.
|
|
5092
|
+
var SDK_VERSION = "3.24.7";
|
|
5093
5093
|
var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
|
|
5094
5094
|
|
|
5095
5095
|
// src/client.ts
|
|
@@ -10809,6 +10809,7 @@ function checkChannelLayout() {
|
|
|
10809
10809
|
return layoutChecked;
|
|
10810
10810
|
}
|
|
10811
10811
|
var LANDING_MARGIN_BLOCKS = 300;
|
|
10812
|
+
var SECONDS_PER_SLOT = 0.4;
|
|
10812
10813
|
function maxOf(a, b) {
|
|
10813
10814
|
if (a === void 0) return b;
|
|
10814
10815
|
if (b === void 0) return a;
|
|
@@ -12363,7 +12364,29 @@ var SolanaBatchPayer = class {
|
|
|
12363
12364
|
`could not read channel ${record.channelId} before topping it up: ${err instanceof Error ? err.message : String(err)}`
|
|
12364
12365
|
);
|
|
12365
12366
|
}
|
|
12366
|
-
if (channel === void 0)
|
|
12367
|
+
if (channel === void 0) {
|
|
12368
|
+
const openSlot = Number(record.channelConfig.openSlot);
|
|
12369
|
+
const delaySlots = Math.ceil((record.channelConfig.withdrawDelay ?? 86400) / SECONDS_PER_SLOT);
|
|
12370
|
+
let finalizedSlot;
|
|
12371
|
+
try {
|
|
12372
|
+
const epoch = await rpcRequest(this.init.rpcUrl, "getEpochInfo", [{ commitment: "finalized" }], this.init.rpcHeaders);
|
|
12373
|
+
finalizedSlot = rpcInteger(epoch.absoluteSlot, "getEpochInfo absoluteSlot");
|
|
12374
|
+
} catch {
|
|
12375
|
+
return;
|
|
12376
|
+
}
|
|
12377
|
+
if (!Number.isSafeInteger(openSlot) || openSlot <= 0 || finalizedSlot <= openSlot + delaySlots) return;
|
|
12378
|
+
addResyncTarget(wallet, {
|
|
12379
|
+
key,
|
|
12380
|
+
channelId: record.channelId,
|
|
12381
|
+
channelConfig: record.channelConfig,
|
|
12382
|
+
cumulative: parseAtomic(record.chargedCumulativeAmount),
|
|
12383
|
+
knownDeposit: deposit,
|
|
12384
|
+
// No deposit is in doubt: nothing can still land in a reclaimed account.
|
|
12385
|
+
anchorHeight: 0,
|
|
12386
|
+
reason: "channel_unusable"
|
|
12387
|
+
});
|
|
12388
|
+
throw new ChannelResyncRequiredError(record.channelId);
|
|
12389
|
+
}
|
|
12367
12390
|
if (!channel.open || channel.payer !== await this.init.address() || channel.authorizedSigner !== record.channelConfig.payerAuthorizer || channel.mint !== record.channelConfig.token) {
|
|
12368
12391
|
addResyncTarget(wallet, {
|
|
12369
12392
|
key,
|
package/dist/index.js
CHANGED
|
@@ -440,7 +440,7 @@ function withCost(body, response, bookedUsd, scheme) {
|
|
|
440
440
|
// src/client.ts
|
|
441
441
|
import { privateKeyToAccount } from "viem/accounts";
|
|
442
442
|
|
|
443
|
-
// node_modules/.pnpm/@blockrun+router-core@https+++codeload.github.com+BlockRunAI+router-core+tar.gz+
|
|
443
|
+
// node_modules/.pnpm/@blockrun+router-core@https+++codeload.github.com+BlockRunAI+router-core+tar.gz+fd6d03d035ff6_meidvh7c7i3y7wjjl6r2ymc4py/node_modules/@blockrun/router-core/dist/index.js
|
|
444
444
|
var UNSEGMENTED_SCRIPT = /[-ۿ -ヿ㐀-䶿一-鿿가-豈--]/;
|
|
445
445
|
var WORD_CHAR = /[\p{L}\p{N}]/u;
|
|
446
446
|
var ASCII_PHRASE = /^[a-z0-9' -]+$/;
|
|
@@ -2772,10 +2772,10 @@ function isEligible(modelId, features, maxOutputTokens, options) {
|
|
|
2772
2772
|
return model.contextWindow >= (features.estimatedInputTokens + maxOutputTokens) * 1.1;
|
|
2773
2773
|
}
|
|
2774
2774
|
function estimatedCost(modelId, options, inputTokens, outputTokens) {
|
|
2775
|
-
const
|
|
2776
|
-
if (!
|
|
2777
|
-
if (
|
|
2778
|
-
return (inputTokens *
|
|
2775
|
+
const price2 = options.modelPricing.get(modelId);
|
|
2776
|
+
if (!price2) return Number.POSITIVE_INFINITY;
|
|
2777
|
+
if (price2.flatPrice !== void 0) return price2.flatPrice;
|
|
2778
|
+
return (inputTokens * price2.inputPrice + outputTokens * price2.outputPrice) / 1e6;
|
|
2779
2779
|
}
|
|
2780
2780
|
function profileScore(modelId, options, now) {
|
|
2781
2781
|
const profile = options.modelPerformance?.[modelId] ?? LIVE_MODEL_PROFILES[modelId] ?? HISTORICAL_MODEL_PROFILES[modelId];
|
|
@@ -4958,7 +4958,7 @@ function getCostSummary() {
|
|
|
4958
4958
|
}
|
|
4959
4959
|
|
|
4960
4960
|
// src/version.ts
|
|
4961
|
-
var SDK_VERSION = "3.24.
|
|
4961
|
+
var SDK_VERSION = "3.24.7";
|
|
4962
4962
|
var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
|
|
4963
4963
|
|
|
4964
4964
|
// src/client.ts
|
|
@@ -10678,6 +10678,7 @@ function checkChannelLayout() {
|
|
|
10678
10678
|
return layoutChecked;
|
|
10679
10679
|
}
|
|
10680
10680
|
var LANDING_MARGIN_BLOCKS = 300;
|
|
10681
|
+
var SECONDS_PER_SLOT = 0.4;
|
|
10681
10682
|
function maxOf(a, b) {
|
|
10682
10683
|
if (a === void 0) return b;
|
|
10683
10684
|
if (b === void 0) return a;
|
|
@@ -12232,7 +12233,29 @@ var SolanaBatchPayer = class {
|
|
|
12232
12233
|
`could not read channel ${record.channelId} before topping it up: ${err instanceof Error ? err.message : String(err)}`
|
|
12233
12234
|
);
|
|
12234
12235
|
}
|
|
12235
|
-
if (channel === void 0)
|
|
12236
|
+
if (channel === void 0) {
|
|
12237
|
+
const openSlot = Number(record.channelConfig.openSlot);
|
|
12238
|
+
const delaySlots = Math.ceil((record.channelConfig.withdrawDelay ?? 86400) / SECONDS_PER_SLOT);
|
|
12239
|
+
let finalizedSlot;
|
|
12240
|
+
try {
|
|
12241
|
+
const epoch = await rpcRequest(this.init.rpcUrl, "getEpochInfo", [{ commitment: "finalized" }], this.init.rpcHeaders);
|
|
12242
|
+
finalizedSlot = rpcInteger(epoch.absoluteSlot, "getEpochInfo absoluteSlot");
|
|
12243
|
+
} catch {
|
|
12244
|
+
return;
|
|
12245
|
+
}
|
|
12246
|
+
if (!Number.isSafeInteger(openSlot) || openSlot <= 0 || finalizedSlot <= openSlot + delaySlots) return;
|
|
12247
|
+
addResyncTarget(wallet, {
|
|
12248
|
+
key,
|
|
12249
|
+
channelId: record.channelId,
|
|
12250
|
+
channelConfig: record.channelConfig,
|
|
12251
|
+
cumulative: parseAtomic(record.chargedCumulativeAmount),
|
|
12252
|
+
knownDeposit: deposit,
|
|
12253
|
+
// No deposit is in doubt: nothing can still land in a reclaimed account.
|
|
12254
|
+
anchorHeight: 0,
|
|
12255
|
+
reason: "channel_unusable"
|
|
12256
|
+
});
|
|
12257
|
+
throw new ChannelResyncRequiredError(record.channelId);
|
|
12258
|
+
}
|
|
12236
12259
|
if (!channel.open || channel.payer !== await this.init.address() || channel.authorizedSigner !== record.channelConfig.payerAuthorizer || channel.mint !== record.channelConfig.token) {
|
|
12237
12260
|
addResyncTarget(wallet, {
|
|
12238
12261
|
key,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockrun/llm",
|
|
3
|
-
"version": "3.24.
|
|
3
|
+
"version": "3.24.7",
|
|
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",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@blockrun/core": "^0.1.0",
|
|
61
|
-
"@blockrun/router-core": "https://codeload.github.com/BlockRunAI/router-core/tar.gz/
|
|
61
|
+
"@blockrun/router-core": "https://codeload.github.com/BlockRunAI/router-core/tar.gz/fd6d03d035ff676642ba1683c333d929939f8a00",
|
|
62
62
|
"@eslint/js": "^10.0.1",
|
|
63
63
|
"@solana/kit": "^5.5.1",
|
|
64
64
|
"@types/node": "^26.4.1",
|