Expand description
Per-model USD pricing for cost reporting.
Values in $ per 1M tokens. Returns None for unknown models so that the
caller can set total_cost_usd = None. DeepSeek bills prompt tokens at two
rates: a discounted cache-hit rate for prefix tokens served from their
context cache, and the full cache-miss rate for everything else. The
API reports the split in usage.prompt_cache_hit_tokens /
prompt_cache_miss_tokens; when present we use the split rates, otherwise
we fall back to charging the entire prompt at the miss rate.
Structs§
Functions§
- map_
stop_ reason - Map OpenAI
finish_reasonto a Claude-stylestop_reason. - model_
pricing - turn_
cost_ usd - Convert a turn’s
UsageInfointo a USD cost given the model. Uses the cache-hit/miss split when the API reported it; otherwise charges the full prompt at the miss rate. ReturnsNoneif pricing is unknown.