(
*,
input_tokens_uncached: int,
cache_read_input_tokens: int,
cache_write_input_tokens: int,
pricing: ModelPricing,
)
| 405 | |
| 406 | |
| 407 | def estimate_input_cost( |
| 408 | *, |
| 409 | input_tokens_uncached: int, |
| 410 | cache_read_input_tokens: int, |
| 411 | cache_write_input_tokens: int, |
| 412 | pricing: ModelPricing, |
| 413 | ) -> float: |
| 414 | cached_read_price = ( |
| 415 | pricing.cached_input_price |
| 416 | if pricing.cached_input_price is not None |
| 417 | else pricing.input_price |
| 418 | ) |
| 419 | cache_write_price = ( |
| 420 | pricing.cache_write_price |
| 421 | if pricing.cache_write_price is not None |
| 422 | else pricing.input_price |
| 423 | ) |
| 424 | return ( |
| 425 | (input_tokens_uncached / 1_000_000) * pricing.input_price |
| 426 | + (cache_read_input_tokens / 1_000_000) * cached_read_price |
| 427 | + (cache_write_input_tokens / 1_000_000) * cache_write_price |
| 428 | ) |
| 429 | |
| 430 | |
| 431 | def estimate_usage_cost( |
no outgoing calls
no test coverage detected