Cost from token usage
cost_from_usageCalculate the USD cost of AI model token usage, including input, output, and cached tokens, using historical or current prices.
Instructions
Value a token rollup in USD at a point in time, using the shared cache multipliers (cache read 0.1x input, cache write 1.25x for 5m / 2x for 1h). tokens accepts input, output, cache_read, cache_write_5m, cache_write_1h. Defaults to today if no date is given.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Model id or alias to price the usage against. | |
| tokens | Yes | Token counts to value. All fields optional and non-negative; missing fields count as 0. | |
| date | No | Optional date (YYYY-MM-DD). Omit for today. | |
| provider | No | Optional provider slug to disambiguate a bare id. |