diff --git a/README.md b/README.md index 5bbce2e..248ce3b 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ claude mcp add blockrun -s user -- npx -y @blockrun/mcp@latest
- 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. + 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.
@@ -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 | @@ -370,7 +370,7 @@ npx -y @blockrun/mcp@latest skills install --to ~/.codex/skills | Tool | Data source | Cost | |------|-------------|------| | `blockrun_chat` | 91 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 | diff --git a/assets/context-cost-dark.svg b/assets/context-cost-dark.svg index 458ed18..63db525 100644 --- a/assets/context-cost-dark.svg +++ b/assets/context-cost-dark.svg @@ -1,9 +1,9 @@ - + CONTEXT COST - 14.4K tokens + 14.5K tokens 7% of a 200K context window · every turn, whether or not you call a tool 5.6K with --profile trading — 61% less measured, not estimated diff --git a/assets/context-cost.svg b/assets/context-cost.svg index ed4086f..0957960 100644 --- a/assets/context-cost.svg +++ b/assets/context-cost.svg @@ -1,9 +1,9 @@ - + CONTEXT COST - 14.4K tokens + 14.5K tokens 7% of a 200K context window · every turn, whether or not you call a tool 5.6K with --profile trading — 61% less measured, not estimated diff --git a/docs/mcp-schema-overhead.md b/docs/mcp-schema-overhead.md index a0c8fcd..4809f08 100644 --- a/docs/mcp-schema-overhead.md +++ b/docs/mcp-schema-overhead.md @@ -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 | diff --git a/scripts/verify-prices.ts b/scripts/verify-prices.ts index a2802bc..af9469e 100644 --- a/scripts/verify-prices.ts +++ b/scripts/verify-prices.ts @@ -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. diff --git a/skills/image-prompting/SKILL.md b/skills/image-prompting/SKILL.md index 90dde7b..80faae9 100644 --- a/skills/image-prompting/SKILL.md +++ b/skills/image-prompting/SKILL.md @@ -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` | @@ -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` diff --git a/src/tools/image.ts b/src/tools/image.ts index 03f96dd..12aacc7 100644 --- a/src/tools/image.ts +++ b/src/tools/image.ts @@ -123,7 +123,13 @@ export async function resolveImageRef(ref: string): Promise { // 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 = { +// +// 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 = { "zai/cogview-4": 0.015, "xai/grok-imagine-image": 0.02, "xai/grok-imagine-image-2.0": 0.04, @@ -134,12 +140,16 @@ const GENERATE_MODEL_COST: Record = { "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 = { +// 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 = { "openai/gpt-image-1": 0.04, "openai/gpt-image-2": 0.12, "openai/gpt-image-2.5-flare": 0.56, // 1536x1024 / 1024x1536 @@ -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", ]); @@ -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", @@ -360,6 +374,8 @@ 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 @@ -367,7 +383,7 @@ Generation models (1024x1024 base price; larger sizes cost more on gpt-image-*): - 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, diff --git a/test/image-cost.test.ts b/test/image-cost.test.ts index b69f8c8..9ec5156 100644 --- a/test/image-cost.test.ts +++ b/test/image-cost.test.ts @@ -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 @@ -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) => Promise) | 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) => handler!(args), budget }; + return { + call: (args: Record) => 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) => z.object(shape!).parse(args) as Record, + description, + budget, + }; } // The Cost footer and the ledger must report what the user is CHARGED, not the @@ -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. diff --git a/test/readme-image-price.test.ts b/test/readme-image-price.test.ts new file mode 100644 index 0000000..bfa0ee2 --- /dev/null +++ b/test/readme-image-price.test.ts @@ -0,0 +1,29 @@ +// Run with: npm test (tsx --test) +// +// The README tool table's `blockrun_image` cost cell is a public price claim. +// It said "$0.015–0.15" for months while the tool's own tables reached $0.30 +// (nano-banana-pro at 4096x4096) and $0.56 (gpt-image-2.5 at 1536x1024 / +// 1024x1536), because nothing compared it with anything. Derive the range +// from the same catalog tables estimateCost() reads, so the next reprice or +// model addition fails here instead of leaving the README behind. +// +// The figures are CATALOG prices (what the tool description quotes per +// model), not the charged amount — the README states the catalog range, and +// the charge (x1.05 + fee) is verified separately by verify:prices. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { GENERATE_MODEL_COST, LARGE_SIZE_COST } from "../src/tools/image.js"; + +const README = readFileSync(new URL("../README.md", import.meta.url), "utf8"); + +test("README blockrun_image price range is the min and max of the image price tables", () => { + const prices = [...Object.values(GENERATE_MODEL_COST), ...Object.values(LARGE_SIZE_COST)]; + assert.ok(prices.length > 0 && prices.every((p) => p > 0), "price tables must be populated"); + const range = `$${Math.min(...prices)}–${Math.max(...prices)}`; + + const row = README.split("\n").find((line) => line.startsWith("| `blockrun_image` |")); + assert.ok(row, "README tool table has no blockrun_image row"); + const cells = row.split("|").map((c) => c.trim()).filter(Boolean); + assert.equal(cells.at(-1), range, `README blockrun_image cost should read ${range}`); +});