diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.py index 3910a554905..e9ff3888cd1 100644 --- a/litellm/cost_calculator.py +++ b/litellm/cost_calculator.py @@ -2051,6 +2051,7 @@ def completion_cost( call_type=call_type, model_info=_deployment_model_info(litellm_logging_obj, custom_pricing, router_model_id), vertex_location=vertex_location, + data_residency=data_residency, ) elif call_type in _VIDEO_CALL_TYPES: ### VIDEO GENERATION COST CALCULATION ### diff --git a/litellm/litellm_core_utils/llm_cost_calc/utils.py b/litellm/litellm_core_utils/llm_cost_calc/utils.py index 9ac4f9d5ee8..b38d254c07c 100644 --- a/litellm/litellm_core_utils/llm_cost_calc/utils.py +++ b/litellm/litellm_core_utils/llm_cost_calc/utils.py @@ -2287,6 +2287,7 @@ class CostCalculatorUtils: call_type: str | None = None, model_info: ModelInfo | None = None, vertex_location: str | None = None, + data_residency: str | None = None, ) -> float: """ Route the image generation cost calculator based on the custom_llm_provider @@ -2398,6 +2399,8 @@ class CostCalculatorUtils: image_response=completion_response, custom_llm_provider=custom_llm_provider, model_info=pricing, + data_residency=data_residency, + optional_params=optional_params, ) # Fall through to default for DALL-E models return default_image_cost_calculator( diff --git a/litellm/llms/openai/image_generation/cost_calculator.py b/litellm/llms/openai/image_generation/cost_calculator.py index 350fdbaee2d..696d416b050 100644 --- a/litellm/llms/openai/image_generation/cost_calculator.py +++ b/litellm/llms/openai/image_generation/cost_calculator.py @@ -21,6 +21,8 @@ def cost_calculator( image_response: ImageResponse, custom_llm_provider: str | None = None, model_info: ModelInfo | None = None, + data_residency: str | None = None, + optional_params: dict | None = None, ) -> float: """Calculate cost for OpenAI gpt-image models (token-based pricing).""" provider: Final = custom_llm_provider or "openai" @@ -38,7 +40,12 @@ def cost_calculator( # A chat Usage with an explicit output breakdown: cost via generic_cost_per_token. if isinstance(usage, Usage) and usage.completion_tokens_details is not None: prompt_cost, completion_cost = generic_cost_per_token( - model=model, usage=usage, custom_llm_provider=provider, model_info=price_table + model=model, + usage=usage, + custom_llm_provider=provider, + model_info=price_table, + data_residency=data_residency, + optional_params=optional_params, ) return prompt_cost + completion_cost @@ -48,7 +55,12 @@ def cost_calculator( # does not itemize output and splitting text/image when it does. if getattr(usage, "input_tokens", None) is not None: token_based_cost: Final = calculate_image_response_cost_from_usage( - model=model, image_response=image_response, custom_llm_provider=provider, model_info=price_table + model=model, + image_response=image_response, + custom_llm_provider=provider, + model_info=price_table, + data_residency=data_residency, + optional_params=optional_params, ) if token_based_cost is not None: return token_based_cost @@ -57,7 +69,12 @@ def cost_calculator( # cost via generic_cost_per_token (text rate) instead of returning 0.0. if isinstance(usage, Usage): prompt_cost, completion_cost = generic_cost_per_token( - model=model, usage=usage, custom_llm_provider=provider, model_info=price_table + model=model, + usage=usage, + custom_llm_provider=provider, + model_info=price_table, + data_residency=data_residency, + optional_params=optional_params, ) return prompt_cost + completion_cost