* Estimate the cost of an image generation/editing request. * Matches server-side calculateImagePrice() including 5% margin.
(model: string, size?: string, n: number = 1)
| 1668 | * Matches server-side calculateImagePrice() including 5% margin. |
| 1669 | */ |
| 1670 | function 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. |
no outgoing calls
no test coverage detected