Skip to content

feat(media): report USDC cost in image/video/music results#31

Merged
VickyXAI merged 1 commit into
BlockRunAI:mainfrom
KillerQueen-Z:feat/media-cost-footer
Jul 5, 2026
Merged

feat(media): report USDC cost in image/video/music results#31
VickyXAI merged 1 commit into
BlockRunAI:mainfrom
KillerQueen-Z:feat/media-cost-footer

Conversation

@KillerQueen-Z

Copy link
Copy Markdown
Contributor

Problem

blockrun_image, blockrun_video, and blockrun_music return the URL and model but no price. On a bare MCP — without the plugin's announce-cost skill — the user never sees what a generation charged. The cost is already computed and booked to the budget ledger; it just isn't surfaced in the result.

blockrun_speech and blockrun_realface already print a Cost: line, so this closes the gap on the remaining media tools.

Change

Each of the three tools now appends to its result:

  • a Cost: $X.XXXX line in the text output
  • a cost_usd field in structuredContent

Cost source, per tool:

  • video / music — the real 402-settled amount (amountToUsd(details.amount)). Both are token-priced upstream, so 1080p/4K clips and long tracks can exceed the per-unit estimate — showing the settled figure is the accurate one.
  • image — catalog estimate on Base (the SDK response carries no billed amount), real 402 amount on Solana.
  • All three fall back to the estimate only if the quote doesn't parse.

No new spend path and no change to what is charged — the figure shown is the same amount already recorded to the budget.

Example (video)

🎬 Video ready!
URL: https://blockrun.ai/media/vid_123.mp4
Duration: 8s
Model: xai/grok-imagine-video
Cost: $0.4000        ← new
Backed up to BlockRun storage (URL is permanent)
Request ID: req_789
Tx: 0xabc123txhash

Tests

Adds handler-level tests for the image / video / music footers with the HTTP layer and the x402 payment helpers mocked — no network, no real spend. node --test isolates each file in its own process, so the module mocks don't leak. The test script now runs with --experimental-test-module-mocks.

npm test → 96 passing. npm run typecheck clean.

Not included

chat / chat-anthropic (LLM completions — have a real settled price) and the small-ticket data tools (search, exa, surf, markets, rpc, defi, modal, phone) still omit a cost line. Happy to follow up in a separate PR if wanted — kept this one scoped to the media-generation tools.

blockrun_image, blockrun_video and blockrun_music returned the URL and
model but no price, so on a bare MCP (without the plugin's announce-cost
skill) the user never saw what a generation charged — the cost was booked
to the budget ledger but never shown. Each now appends a `Cost: $X.XXXX`
line and a cost_usd field to structuredContent, matching blockrun_speech
and blockrun_realface which already did this.

Video and music report the real 402-settled amount (token-priced upstream,
so hi-res clips and long tracks can exceed the estimate); image uses the
catalog estimate on Base and the 402 amount on Solana, each falling back
to the estimate only if the quote doesn't parse. No new spend path — the
figure shown is the same amount already recorded to the budget.

Adds handler-level tests for the image/video/music footers with the HTTP
layer and x402 helpers mocked (no network, no real spend); npm test now
runs with --experimental-test-module-mocks.
@VickyXAI VickyXAI merged commit 7321e44 into BlockRunAI:main Jul 5, 2026
@VickyXAI

VickyXAI commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Merged via 7321e44. Branch was cut from 0.25.2, so rebasing over the 0.25.3 audit pass needed two conflict resolutions: CHANGELOG (placed 0.26.0 above 0.25.3) and package.json (0.26.0). src/tools/image.ts and music.ts auto-merged cleanly — the cost-footer code sits correctly alongside the 0.25.3 budget-gate hardening. Combined suite green: typecheck clean, 109 tests pass, build OK.

Note: VERSION is now 0.26.0. Heads-up that the 0.25.3 release (e566acd) bumped package.json + CHANGELOG but left VERSION at 0.25.2 — this merge realigned it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants