Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test_embedding_response_ratelimit_headers

Ishaan Jaff311c70698f98
diff --git a/tests/local_testing/test_embedding.py b/tests/local_testing/test_embedding.py
index b0e8d75516f..9146944aa28 100644
--- a/tests/local_testing/test_embedding.py
+++ b/tests/local_testing/test_embedding.py
@@ -1075,9 +1075,14 @@ def test_embedding_response_ratelimit_headers(model):
hidden_params = response._hidden_params
additional_headers = hidden_params.get("additional_headers", {})
- print(additional_headers)
- assert "x-ratelimit-remaining-requests" in additional_headers
- assert int(additional_headers["x-ratelimit-remaining-requests"]) > 0
+ print("additional_headers", additional_headers)
+
+ # Azure is flaky with returning x-ratelimit-remaining-requests, we need to verify the upstream api returns this header
+ # if upstream api returns this header, we need to verify the header is transformed by litellm
+ if "llm_provider-x-ratelimit-limit-requests" in additional_headers or "x-ratelimit-limit-requests" in additional_headers:
+ assert "x-ratelimit-remaining-requests" in additional_headers
+ assert int(additional_headers["x-ratelimit-remaining-requests"]) > 0
+
assert "x-ratelimit-remaining-tokens" in additional_headers
assert int(additional_headers["x-ratelimit-remaining-tokens"]) > 0