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

Function estimateCostFromBytes

examples/ts-code-mode-web/src/lib/efficiency.ts:210–217  ·  view source on GitHub ↗
(bytes: number, model?: string)

Source from the content-addressed store, hash-verified

208}
209
210export function estimateCostFromBytes(bytes: number, model?: string): number {
211 const pricingKey = model ? MODEL_MAPPING[model] || model : 'claude-haiku-4.5'
212 const pricing =
213 EFFICIENCY_CONSTANTS.PRICING[pricingKey] ??
214 EFFICIENCY_CONSTANTS.PRICING['claude-haiku-4.5']
215 const tokens = bytes / EFFICIENCY_CONSTANTS.BYTES_PER_TOKEN
216 return calculateCost(tokens, pricing)
217}
218
219// === Formatters ===
220

Callers 1

NoCodeMetricsFunction · 0.90

Calls 1

calculateCostFunction · 0.85

Tested by

no test coverage detected