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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
tests(vcr): assert response shape, not exact bytes, in replay tests
mateo-berri95bce9a72eb8
diff --git a/tests/llm_translation/test_anthropic_completion.py b/tests/llm_translation/test_anthropic_completion.pyindex 8c5ac830010..faff76edb68 100644--- a/tests/llm_translation/test_anthropic_completion.py+++ b/tests/llm_translation/test_anthropic_completion.py@@ -1888,19 +1888,28 @@ def test_metadata_filter_applies_to_azure_anthropic():def test_anthropic_basic_completion_replay():+ """Smoke-test the Anthropic completion pipeline end-to-end via VCR.++ Asserts on response shape rather than specific bytes, so the test is+ valid both on a fresh CI Redis (records on first run) and on a hot+ cache (replays). Drift in the *shape* of Anthropic's response surfaces+ here; drift in the exact text/token counts is expected and ignored.+ """response = litellm.completion(model="anthropic/claude-sonnet-4-5-20250929",messages=[{"role": "user", "content": "Hello!"}],)assert response is not None- assert response.choices[0].message.content == ("Hello! How can I help you today?")- assert response.usage.prompt_tokens == 12- assert response.usage.completion_tokens == 11- assert response.choices[0].finish_reason == "stop"+ content = response.choices[0].message.content+ assert isinstance(content, str) and content.strip(), content+ assert response.usage.prompt_tokens > 0+ assert response.usage.completion_tokens > 0+ assert response.choices[0].finish_reason in {"stop", "length"}def test_anthropic_streaming_completion_replay():+ """Same as above for the streaming path; asserts on shape, not bytes."""stream = litellm.completion(model="anthropic/claude-sonnet-4-5-20250929",messages=[{"role": "user", "content": "Hello!"}],@@ -1909,7 +1918,9 @@ def test_anthropic_streaming_completion_replay():collected_text = ""finish_reason = None+ chunk_count = 0for chunk in stream:+ chunk_count += 1if not chunk.choices:continuedelta = chunk.choices[0].delta@@ -1918,5 +1929,6 @@ def test_anthropic_streaming_completion_replay():if chunk.choices[0].finish_reason:finish_reason = chunk.choices[0].finish_reason- assert collected_text == "Hello from LiteLLM!"- assert finish_reason == "stop"+ assert chunk_count > 1, "expected multiple SSE chunks from streaming response"+ assert collected_text.strip(), collected_text+ assert finish_reason in {"stop", "length"}