MCPcopy Create free account
hub / github.com/TanStack/ai / convertPricing

Function convertPricing

scripts/convert-openrouter-models.ts:28–36  ·  view source on GitHub ↗
(priceStr: string, isImage: boolean = false)

Source from the content-addressed store, hash-verified

26}
27
28function 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}
37function finalPrice(price: number): number {
38 // Ensure price is non-negative and rounded to avoid floating-point errors
39 const result = price * 1_000_000

Callers 1

generateModelMetaStringFunction · 0.85

Calls 1

finalPriceFunction · 0.85

Tested by

no test coverage detected