Compute dollar cost from token counts using the model pricing table.
(model: str, input_tokens: int, output_tokens: int)
| 316 | |
| 317 | |
| 318 | def _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 | |
| 326 | def _estimate_baseline_cost(input_tokens: int, output_tokens: int) -> float: |
no test coverage detected