MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _estimate_cost

Function _estimate_cost

uncommon_route/proxy.py:318–323  ·  view source on GitHub ↗

Compute dollar cost from token counts using the model pricing table.

(model: str, input_tokens: int, output_tokens: int)

Source from the content-addressed store, hash-verified

316
317
318def _estimate_cost(model: str, input_tokens: int, output_tokens: int) -> float:
319 """Compute dollar cost from token counts using the model pricing table."""
320 mp = _get_pricing().get(model)
321 if mp is None:
322 return 0.0
323 return (input_tokens / 1_000_000) * mp.input_price + (output_tokens / 1_000_000) * mp.output_price
324
325
326def _estimate_baseline_cost(input_tokens: int, output_tokens: int) -> float:

Callers 4

_estimate_baseline_costFunction · 0.85
_run_taskMethod · 0.85
_handle_chat_coreFunction · 0.85

Calls 2

_get_pricingFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected