ccproxy.plugins.pricing.utils¶
ccproxy.plugins.pricing.utils
¶
Cost calculation utilities for token-based pricing (plugin-owned).
These helpers live inside the pricing plugin to avoid coupling core to pricing logic. They accept an optional PricingService instance for callers that already have one; otherwise they create a default service on demand.
calculate_token_cost
async
¶
calculate_token_cost(
tokens_input,
tokens_output,
model,
cache_read_tokens=None,
cache_write_tokens=None,
pricing_service=None,
)
Calculate total cost in USD for the given token usage.
If no pricing_service is provided, a default PricingService is created using PricingConfig(). Returns None if model or tokens are missing or if pricing information is unavailable.
Source code in ccproxy/plugins/pricing/utils.py
calculate_cost_breakdown
async
¶
calculate_cost_breakdown(
tokens_input,
tokens_output,
model,
cache_read_tokens=None,
cache_write_tokens=None,
pricing_service=None,
)
Return a detailed cost breakdown using current pricing data.
If no pricing_service is provided, a default PricingService is created. Returns None if inputs are insufficient or model pricing is unavailable.