File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,14 +46,30 @@ class LiteLLMCostCalculator:
4646 ```
4747 """
4848
49- def __init__ (self , custom_pricing : Optional [Dict [str , Dict [str , float ]]] = None ):
49+ def __init__ (
50+ self ,
51+ custom_pricing : Optional [Dict [str , Dict [str , float ]]] = None ,
52+ model_id_map : Optional [Dict [str , str ]] = None ,
53+ ):
5054 """Initialize the LiteLLM cost calculator.
5155
5256 Args:
5357 custom_pricing: Optional overrides for specific models. Keys are
5458 model IDs, values are dicts with ``"input_cost_per_token"``
5559 and ``"output_cost_per_token"``. These take precedence over
5660 LiteLLM's built-in pricing.
61+ model_id_map: Optional mapping from adapter model IDs to LiteLLM
62+ model IDs. Use this when your adapter's ``model_id`` doesn't
63+ match LiteLLM's naming convention — e.g., when using Google's
64+ OpenAI-compatible endpoint where the adapter sees
65+ ``"gemini-2.0-flash"`` but LiteLLM expects
66+ ``"gemini/gemini-2.0-flash"``.
67+
68+ Example::
69+
70+ LiteLLMCostCalculator(model_id_map={
71+ "gemini-2.0-flash": "gemini/gemini-2.0-flash",
72+ })
5773 """
5874 try :
5975 import litellm # noqa: F401
You can’t perform that action at this time.
0 commit comments