diff --git a/tests/test_litellm/proxy/common_utils/test_callback_utils.py b/tests/test_litellm/proxy/common_utils/test_callback_utils.py new file mode 100644 index 0000000000..ffcab13571 --- /dev/null +++ b/tests/test_litellm/proxy/common_utils/test_callback_utils.py @@ -0,0 +1,27 @@ +import sys +import os + +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + +from litellm.proxy.common_utils.callback_utils import get_remaining_tokens_and_requests_from_request_data + +def test_get_remaining_tokens_and_requests_from_request_data(): + model_group = "openrouter/google/gemini-2.0-flash-001" + casedata = { + "metadata": { + "model_group": model_group, + f"litellm-key-remaining-requests-{model_group}": 100, + f"litellm-key-remaining-tokens-{model_group}": 200 + } + } + + headers = get_remaining_tokens_and_requests_from_request_data(casedata) + + expected_name = "openrouter-google-gemini-2.0-flash-001" + assert headers == { + f"x-litellm-key-remaining-requests-{expected_name}": 100, + f"x-litellm-key-remaining-tokens-{expected_name}": 200 + } +