Skip to main content

Module pricing

Module pricing 

Source
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§

ModelPricing

Functions§

map_stop_reason
Map OpenAI finish_reason to a Claude-style stop_reason.
model_pricing
turn_cost_usd
Convert a turn’s UsageInfo into 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. Returns None if pricing is unknown.