(priceStr: string, isImage: boolean = false)
| 26 | } |
| 27 | |
| 28 | function convertPricing(priceStr: string, isImage: boolean = false): number { |
| 29 | // OpenRouter pricing is typically per token (in dollars) |
| 30 | // Convert to number |
| 31 | const price = parseFloat(priceStr) |
| 32 | if (isImage) { |
| 33 | return isNaN(price) ? 0 : price |
| 34 | } |
| 35 | return finalPrice(isNaN(price) ? 0 : price) |
| 36 | } |
| 37 | function finalPrice(price: number): number { |
| 38 | // Ensure price is non-negative and rounded to avoid floating-point errors |
| 39 | const result = price * 1_000_000 |
no test coverage detected