ccproxy.pricing.loader¶
ccproxy.pricing.loader
¶
Pricing data loader and format converter for LiteLLM pricing data.
PricingLoader
¶
Loads and converts pricing data from LiteLLM format to internal format.
extract_claude_models
staticmethod
¶
Extract Claude model entries from LiteLLM data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
litellm_data
|
dict[str, Any]
|
Raw LiteLLM pricing data |
required |
verbose
|
bool
|
Whether to log individual model discoveries |
True
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Dictionary with only Claude models |
Source code in ccproxy/pricing/loader.py
convert_to_internal_format
staticmethod
¶
Convert LiteLLM pricing format to internal format.
LiteLLM format uses cost per token, we use cost per 1M tokens as Decimal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
claude_models
|
dict[str, Any]
|
Claude models in LiteLLM format |
required |
verbose
|
bool
|
Whether to log individual model conversions |
True
|
Returns:
Type | Description |
---|---|
dict[str, dict[str, Decimal]]
|
Dictionary in internal pricing format |
Source code in ccproxy/pricing/loader.py
load_pricing_from_data
staticmethod
¶
Load and convert pricing data from LiteLLM format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
litellm_data
|
dict[str, Any]
|
Raw LiteLLM pricing data |
required |
verbose
|
bool
|
Whether to enable verbose logging |
True
|
Returns:
Type | Description |
---|---|
PricingData | None
|
Validated pricing data as PricingData model, or None if invalid |
Source code in ccproxy/pricing/loader.py
validate_pricing_data
staticmethod
¶
Validate pricing data using Pydantic models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pricing_data
|
Any
|
Pricing data to validate (dict or PricingData) |
required |
verbose
|
bool
|
Whether to enable verbose logging |
True
|
Returns:
Type | Description |
---|---|
PricingData | None
|
Valid PricingData model or None if validation fails |