MCPcopy Index your code
hub / github.com/BlockRunAI/ClawRouter / estimateImageCost

Function estimateImageCost

src/proxy.ts:1670–1676  ·  view source on GitHub ↗

* Estimate the cost of an image generation/editing request. * Matches server-side calculateImagePrice() including 5% margin.

(model: string, size?: string, n: number = 1)

Source from the content-addressed store, hash-verified

1668 * Matches server-side calculateImagePrice() including 5% margin.
1669 */
1670function estimateImageCost(model: string, size?: string, n: number = 1): number {
1671 const pricing = IMAGE_PRICING[model];
1672 if (!pricing) return 0.04 * n * 1.05; // fallback: assume $0.04/image + margin
1673 const sizePrice = size && pricing.sizes ? pricing.sizes[size] : undefined;
1674 const pricePerImage = sizePrice ?? pricing.default;
1675 return pricePerImage * n * 1.05; // 5% server margin
1676}
1677
1678/**
1679 * Proxy a paid BlockRun data request through x402 payment flow.

Callers 2

startProxyFunction · 0.85
proxyRequestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected