Calculate the three token buckets
Divide each token count by one million, multiply by its published rate, then add the results. Cache creation or uncached prompt tokens belong to the cache-miss bucket; only reported cache-read tokens receive the hit rate.
cost = (cache_hit_tokens / 1M × $0.0028)
+ (cache_miss_tokens / 1M × $0.14)
+ (output_tokens / 1M × $0.28)