ccproxy.plugins.pricing.service¶
ccproxy.plugins.pricing.service
¶
Pricing service providing unified interface for pricing functionality.
PricingService
¶
Main service interface for pricing functionality.
Source code in ccproxy/plugins/pricing/service.py
initialize
async
¶
Initialize the pricing service.
Source code in ccproxy/plugins/pricing/service.py
get_current_pricing
async
¶
Get current pricing data.
Source code in ccproxy/plugins/pricing/service.py
get_model_pricing
async
¶
Get pricing for specific model.
Source code in ccproxy/plugins/pricing/service.py
calculate_cost
async
¶
calculate_cost(
model_name,
input_tokens=0,
output_tokens=0,
cache_read_tokens=0,
cache_write_tokens=0,
)
Calculate cost for token usage.
Raises:
| Type | Description |
|---|---|
PricingServiceDisabledError
|
If pricing service is disabled |
ModelPricingNotFoundError
|
If model pricing is not found |
Source code in ccproxy/plugins/pricing/service.py
calculate_cost_sync
¶
calculate_cost_sync(
model_name,
input_tokens=0,
output_tokens=0,
cache_read_tokens=0,
cache_write_tokens=0,
)
Calculate cost synchronously using cached pricing data.
This method uses the cached pricing data and doesn't make any async calls, making it safe to use in streaming contexts where we can't await.
Raises:
| Type | Description |
|---|---|
PricingServiceDisabledError
|
If pricing service is disabled |
PricingDataNotLoadedError
|
If pricing data is not loaded yet |
ModelPricingNotFoundError
|
If model pricing is not found |
Source code in ccproxy/plugins/pricing/service.py
force_refresh_pricing
async
¶
Force refresh of pricing data.
Source code in ccproxy/plugins/pricing/service.py
get_available_models
async
¶
Get list of available models with pricing.