Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ claude mcp add blockrun -s user -- npx -y @blockrun/mcp@latest
<div align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/context-cost-dark.svg">
<img src="assets/context-cost.svg" width="620" alt="Context cost: 14.4K tokens, 7% of a 200K context window, charged every turn whether or not you call a tool. 5.6K with --profile trading, 61% less.">
<img src="assets/context-cost.svg" width="620" alt="Context cost: 14.5K tokens, 7% of a 200K context window, charged every turn whether or not you call a tool. 5.6K with --profile trading, 61% less.">
</picture>
</div>

Expand Down Expand Up @@ -252,9 +252,9 @@ Package managers have shown install size for decades. Almost no MCP server shows

| Profile | Tools | Context |
|---------|-------|---------|
| `full` *(default)* | 19 | 14,425 |
| `full` *(default)* | 19 | 14,533 |
| `trading` | 8 | 5,619 |
| `media` | 7 | 7,016 |
| `media` | 7 | 7,124 |
| `research` | 5 | 2,819 |
| `chat` | 3 | 2,167 |

Expand Down Expand Up @@ -370,7 +370,7 @@ npx -y @blockrun/mcp@latest skills install --to ~/.codex/skills
| Tool | Data source | Cost |
|------|-------------|------|
| `blockrun_chat` | <!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> LLMs (GPT, Claude, Gemini, DeepSeek, Kimi K3.1 Pro, GLM, NVIDIA free tier, …) with `mode` tier routing | per token |
| `blockrun_image` | Generate: openai/gpt-image-2, gpt-image-1, google/nano-banana(-2/-pro), xai/grok-imagine-image(-pro), zai/cogview-4, bytedance/seedream-5-pro. Edit: img2img, inpaint, fusion. | $0.015–0.15 |
| `blockrun_image` | Generate: openai/gpt-image-2, gpt-image-1, google/nano-banana(-2/-2-lite/-2.1/-pro), xai/grok-imagine-image(-pro), zai/cogview-4, bytedance/seedream-5-pro. Edit: img2img, inpaint, fusion. | $0.015–0.56 |
| `blockrun_video` | xAI Grok Imagine Video 1.0/1.5 + ByteDance Seedance 1.5/2.0-mini/2.0-fast/2.0/2.5 (720p + audio; 4K on 2.0, up to 30s on 2.5); RealFace asset → real-person video; [reference images, video and audio](docs/seedance-capabilities.md) on the account rail | $0.053–0.32/sec charged; reference clips billed at the model's ceiling (15.2s on 2.0, 30.2s on 2.5) |
| `blockrun_realface` | Enroll a real person (phone liveness) or AI character (Virtual Portrait) as a `ta_xxxx` asset for Seedance 2.0 / 2.0-fast / 2.0-mini video (not 2.5) | free; $0.01 to enroll |
| `blockrun_music` | MiniMax music generation | per track |
Expand Down
4 changes: 2 additions & 2 deletions assets/context-cost-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions assets/context-cost.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/mcp-schema-overhead.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Written 2026-09-01, verified against `@modelcontextprotocol/sdk` 1.29.0. Numbers

| Profile | Tools | Context |
|---------|-------|---------|
| `full` *(default)* | 19 | 14,425 |
| `full` *(default)* | 19 | 14,533 |
| `trading` | 8 | 5,619 |
| `media` | 7 | 7,016 |
| `media` | 7 | 7,124 |
| `research` | 5 | 2,819 |
| `chat` | 3 | 2,167 |

Expand Down
9 changes: 9 additions & 0 deletions scripts/verify-prices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ const PROBES: Probe[] = [
// nano-banana-2 is 1024-only upstream (the gateway 400s any other size), so a
// single probe covers its whole price surface.
{ label: "image nano-banana-2 1024", path: "images/generations", body: { model: "google/nano-banana-2", prompt: "a cube", size: "1024x1024" }, expected: estimateImageCost("google/nano-banana-2", "1024x1024") },
// Added 2026-11-24 with their rows. Same shape as nano-banana-2: 1024-only
// (every other size is a 400 before any payment), so one probe each is the
// whole price surface. Edits quote the same figure on /images/image2image.
...(["google/nano-banana-2-lite", "google/nano-banana-2.1"] as const).map((model) => ({
label: `image ${model.slice(model.indexOf("/") + 1)} 1024`,
path: "images/generations",
body: { model, prompt: "a cube", size: "1024x1024" },
expected: estimateImageCost(model, "1024x1024"),
})),
// Added 2026-10-20 with their rows: the 2.5 pair at both size tiers (flat
// across quality, $0.28 / $0.56), Grok Imagine 2.0, and the Pro row that
// had sat at $0.07 for six weeks after the gateway cut it to $0.05.
Expand Down
4 changes: 3 additions & 1 deletion skills/image-prompting/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ doubles the price ($0.064 → $0.127). Ask for `1536x1024` only when you need it
| Clean product / UI mockup | `openai/gpt-image-2` | generate | `1024x1024` |
| Photoreal / fashion / editorial | `openai/gpt-image-2` or `google/nano-banana-pro` | generate | `1024x1024` |
| Pro-level photoreal at Flash speed | `google/nano-banana-2` | generate | `1024x1024` (only size) |
| Newer Flash tier, thinks before it draws | `google/nano-banana-2.1` | generate | `1024x1024` (only size) |
| Cheapest Nano Banana 2 drafts | `google/nano-banana-2-lite` | generate | `1024x1024` (only size) |
| Artistic / stylized / fast | `google/nano-banana` | generate | `1024x1024` |
| Cheapest usable draft | `zai/cogview-4` | generate | `1024x1024` |
| Widescreen / banner on a budget | `bytedance/seedream-5-pro` | generate | `2048x1024` or `1280x720` |
Expand Down Expand Up @@ -314,4 +316,4 @@ CONSTRAINTS:

## Reference

BlockRun image models: `openai/gpt-image-2`, `openai/gpt-image-1`, `google/nano-banana`, `google/nano-banana-2`, `google/nano-banana-pro`, `openai/gpt-image-2.5-flare`, `openai/gpt-image-2.5-sunburst`, `zai/cogview-4`, `xai/grok-imagine-image`, `xai/grok-imagine-image-2.0`, `xai/grok-imagine-image-pro`, `bytedance/seedream-5-pro`
BlockRun image models: `openai/gpt-image-2`, `openai/gpt-image-1`, `google/nano-banana`, `google/nano-banana-2`, `google/nano-banana-2-lite`, `google/nano-banana-2.1`, `google/nano-banana-pro`, `openai/gpt-image-2.5-flare`, `openai/gpt-image-2.5-sunburst`, `zai/cogview-4`, `xai/grok-imagine-image`, `xai/grok-imagine-image-2.0`, `xai/grok-imagine-image-pro`, `bytedance/seedream-5-pro`
22 changes: 19 additions & 3 deletions src/tools/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ export async function resolveImageRef(ref: string): Promise<ResolvedImageRef> {
// the old prices, so every Pro render reserved $0.107001 against a $0.1795
// charge (4K: $0.1595 against $0.316) — the Base ledger books the reserve, so
// the shortfall was written to budget.spent as well.
const GENERATE_MODEL_COST: Record<string, number> = {
//
// 2026-11-24: added nano-banana-2-lite ($0.05) and nano-banana-2.1 ($0.07), the
// gateway's rows from 2026-11-16 (blockrun #1080, sol port). Both are
// 1024x1024 only: the gateway 400s every other size before a payment exists,
// so one base price is their whole surface. Unpaid 402 quotes the same day:
// Base $0.0535 / $0.0745, Solana $0.0525 / $0.0735, generate and edit alike.
export const GENERATE_MODEL_COST: Record<string, number> = {
"zai/cogview-4": 0.015,
"xai/grok-imagine-image": 0.02,
"xai/grok-imagine-image-2.0": 0.04,
Expand All @@ -134,12 +140,16 @@ const GENERATE_MODEL_COST: Record<string, number> = {
"openai/gpt-image-2.5-sunburst": 0.28,
"google/nano-banana": 0.05,
"google/nano-banana-2": 0.09,
"google/nano-banana-2-lite": 0.05,
"google/nano-banana-2.1": 0.07,
"google/nano-banana-pro": 0.17,
"bytedance/seedream-5-pro": 0.045,
};

// Non-square / oversized renders cost more on these models (live catalog).
const LARGE_SIZE_COST: Record<string, number> = {
// Both tables are exported for test/readme-image-price.test.ts, which derives
// the README's blockrun_image price range from them.
export const LARGE_SIZE_COST: Record<string, number> = {
"openai/gpt-image-1": 0.04,
"openai/gpt-image-2": 0.12,
"openai/gpt-image-2.5-flare": 0.56, // 1536x1024 / 1024x1536
Expand All @@ -156,6 +166,8 @@ const EDIT_MODELS = new Set([
"openai/gpt-image-2.5-sunburst",
"google/nano-banana",
"google/nano-banana-2",
"google/nano-banana-2-lite",
"google/nano-banana-2.1",
"google/nano-banana-pro",
]);

Expand All @@ -174,6 +186,8 @@ const IMAGE_MODELS = [
"zai/cogview-4",
"google/nano-banana",
"google/nano-banana-2",
"google/nano-banana-2-lite",
"google/nano-banana-2.1",
"google/nano-banana-pro",
"openai/gpt-image-1",
"openai/gpt-image-2",
Expand Down Expand Up @@ -360,14 +374,16 @@ Generation models (1024x1024 base price; larger sizes cost more on gpt-image-*):
- openai/gpt-image-1 ($0.02–0.04) — GPT native image generation
- google/nano-banana ($0.05) — Gemini-family image model
- google/nano-banana-2 ($0.09) — Gemini 3.1 Flash, pro-level quality at Flash speed (1024x1024 only)
- google/nano-banana-2-lite ($0.05) — Gemini 3.1 Flash Lite, lowest-cost Nano Banana 2 (1024x1024 only)
- google/nano-banana-2.1 ($0.07) — newer Flash-tier Nano Banana with thinking (1024x1024 only)
- google/nano-banana-pro ($0.17; $0.30 at 4096px) — up to 4K, strongest photorealism
- xai/grok-imagine-image ($0.02) — stylized, fast
- xai/grok-imagine-image-2.0 ($0.04) — Grok Imagine 2.0, between Grok Imagine and Pro on price
- xai/grok-imagine-image-pro ($0.06) — Grok Imagine 2.0 at medium quality, finer detail
- zai/cogview-4 ($0.015) — cheapest, photorealistic detailed scenes
- bytedance/seedream-5-pro ($0.045; $0.09 when both dimensions exceed 1024) — Seedream 5.0 Pro; cheap widescreen at 1280x720 / 2048x1024, large formats up to 2848x1600

Edit (img2img) models: openai/gpt-image-2 (default), openai/gpt-image-2.5-sunburst, openai/gpt-image-1, google/nano-banana, google/nano-banana-2, google/nano-banana-pro
Edit (img2img) models: openai/gpt-image-2 (default), openai/gpt-image-2.5-sunburst, openai/gpt-image-1, google/nano-banana, google/nano-banana-2, google/nano-banana-2-lite, google/nano-banana-2.1, google/nano-banana-pro
Multi-image edit: pass an array of 2–4 source images to "image" to fuse them in one render (openai/* up to 4, google/* up to 3) — e.g. a subject plus a sprite layout guide, or a reference plus a brand logo.
Source images and masks accept a base64 data URI, an http(s) URL, or a local file path (auto-encoded). Inpaint mask (openai/gpt-image-* only) via "mask"; not combinable with multiple source images.`,
annotations: TOOL_ANNOTATIONS.generative,
Expand Down
73 changes: 71 additions & 2 deletions test/image-cost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import assert from "node:assert/strict";
import * as fs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";
import { z } from "zod";
import type { BudgetState } from "../src/types.js";

// Pin the RAIL before anything can load utils/auth.ts. image.ts asks
Expand Down Expand Up @@ -83,13 +84,26 @@ test("the suite runs on the wallet rail whatever the developer's account setup",
// Minimal McpServer stub: capture the handler registerImageTool installs.
function makeHarness() {
let handler: ((args: Record<string, unknown>) => Promise<any>) | undefined;
let shape: z.ZodRawShape | undefined;
let description = "";
const server = {
registerTool: (_name: string, _cfg: unknown, h: any) => { handler = h; },
registerTool: (_name: string, cfg: { inputSchema: z.ZodRawShape; description: string }, h: any) => {
handler = h;
shape = cfg.inputSchema;
description = cfg.description;
},
server: { getClientCapabilities: () => ({}) },
} as any;
const budget: BudgetState = { limit: null, spent: 0, calls: 0, agents: new Map() };
registerImageTool(server, budget);
return { call: (args: Record<string, unknown>) => handler!(args), budget };
return {
call: (args: Record<string, unknown>) => handler!(args),
// The schema the MCP client validates against before the handler runs —
// a model missing from the enum is refused here, not in the handler.
parse: (args: Record<string, unknown>) => z.object(shape!).parse(args) as Record<string, unknown>,
description,
budget,
};
}

// The Cost footer and the ledger must report what the user is CHARGED, not the
Expand Down Expand Up @@ -224,6 +238,61 @@ test("nano-banana-2 bills its flat 1024 price and is accepted for edits", async
assert.equal(edit.isError, undefined);
});

// nano-banana-2-lite and nano-banana-2.1: the gateway's 2026-11-16 rows
// (blockrun #1080 and its sol port), $0.05 and $0.07 catalog, 1024x1024 only —
// every other size is a 400 before any payment exists, so one price is each
// model's whole surface. LIVE below is the unpaid 402 quote, probed 2026-11-24,
// on /v1/images/generations and /v1/images/image2image alike (edits quote the
// same figure). Base adds its $0.001 fee; Solana adds none. The reserve is
// catalog x 1.05 + the $0.002 reserved fee, ceiled with the gateway's float
// drift (+1 micro, see estimateCost); Base books reserve - $0.001.
const NB2_FAMILY_LIVE: Array<{ model: string; base: number; solana: number; reserve: number; booked: number }> = [
{ model: "google/nano-banana-2-lite", base: 0.0535, solana: 0.0525, reserve: 0.054501, booked: 0.053501 },
{ model: "google/nano-banana-2.1", base: 0.0745, solana: 0.0735, reserve: 0.075501, booked: 0.074501 },
];

test("nano-banana-2-lite and nano-banana-2.1 are in the model enum and the description", () => {
const { parse, description } = makeHarness();
for (const { model } of NB2_FAMILY_LIVE) {
assert.equal(parse({ prompt: "a pear", model }).model, model);
assert.ok(description.includes(`- ${model} (`), `${model} has no generate line in the tool description`);
assert.match(description, new RegExp(`Edit \\(img2img\\) models:[^\\n]*${model.replace(/[.]/g, "\\.")}[,\\n]`), `${model} missing from the edit list`);
}
// Mirrors the gateway's catalog; a typo'd id must still be refused by the schema.
assert.throws(() => parse({ prompt: "a pear", model: "google/nano-banana-2-light" }));
});

test("nano-banana-2-lite and nano-banana-2.1 reserve at least the live charge on both chains", () => {
for (const { model, base, solana, reserve } of NB2_FAMILY_LIVE) {
const reserved = estimateCost(model, "1024x1024");
assert.equal(reserved, reserve, `${model}: reserve moved`);
for (const [chain, charged] of [["base", base], ["solana", solana]] as const) {
assert.ok(reserved >= charged, `${model} ${chain}: reserved ${reserved} < charged ${charged}`);
assert.ok(reserved <= charged + 0.002 + 1e-6, `${model} ${chain}: reserved ${reserved} sits more than the reserved-fee cushion above ${charged}`);
}
}
});

test("nano-banana-2-lite and nano-banana-2.1 book the Base charge and are accepted for edits", async () => {
for (const { model, base, booked } of NB2_FAMILY_LIVE) {
const { call, budget } = makeHarness();
const res = await call({ prompt: "a pear", model });
assert.equal(res.isError, undefined, `${model} generate failed`);
assert.equal(res.structuredContent.cost_usd, booked, `${model}: booked ${res.structuredContent.cost_usd}`);
assert.ok(booked >= base, `${model}: booked ${booked} below the live Base charge ${base}`);
assert.equal(budget.spent, res.structuredContent.cost_usd);
// The gateway's EDIT_SUPPORTED_MODELS lists both on Base and Solana, so the
// local gate must not refuse them before the paid call.
const edit = await call({
prompt: "make it red",
action: "edit",
model,
image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==",
});
assert.equal(edit.isError, undefined, `${model} edit was refused locally`);
}
});

// Seedream's large tier is keyed on min(w,h), probed live: 2048x1024 and
// 1280x720 bill the $0.045 base while 2048x2048 bills $0.09. A max(w,h) rule
// gets one of the two 2048 sizes wrong whichever threshold it picks.
Expand Down
Loading
Loading