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
test(e2e): drop the passthrough streaming-cost test, it needs a config flag
mateo-berriaa8e7278e3d2
diff --git a/tests/e2e/coverage_registry/quota_management.yaml b/tests/e2e/coverage_registry/quota_management.yamlindex 5438ed8534a..98a45eefb2d 100644--- a/tests/e2e/coverage_registry/quota_management.yaml+++ b/tests/e2e/coverage_registry/quota_management.yaml@@ -50,4 +50,4 @@- {id: quota_management.spend_tracking.messages_bridge.keeps_cache_tokens, module: quota_management, tier: P1, behavior: spend_tracking, variant: messages_bridge, assertions: [keeps_cache_tokens], exercised_on: [messages], source: "llms/anthropic/experimental_pass_through/responses_adapters/handler.py", rationale: "A /v1/messages request served by a Responses-only OpenAI model keeps its cache-read tokens and their discounted billing across the bridge (#34957)"}- {id: quota_management.spend_tracking.service_tier.bills_tier_rates, module: quota_management, tier: P1, behavior: spend_tracking, variant: service_tier, assertions: [bills_tier_rates], exercised_on: [chat_completions], source: "cost_calculator.py", rationale: "A priority service_tier call bills input, output, and reasoning at the deployment's *_priority rates and records the tier on the row (#35923, #35925)"}- {id: quota_management.spend_tracking.cost_headers.additive_components, module: quota_management, tier: P1, behavior: spend_tracking, variant: cost_headers, assertions: [additive_components], exercised_on: [chat_completions], source: "proxy/common_request_processing.py", rationale: "The x-litellm-response-cost-* component headers sum to the total, input covers only fresh tokens, and reasoning stays a subset of output (#36965)"}-- {id: quota_management.spend_tracking.passthrough_stream.injects_usage_cost, module: quota_management, tier: P1, behavior: spend_tracking, variant: passthrough_stream, assertions: [injects_usage_cost], exercised_on: [openai_passthrough], source: "proxy/pass_through_endpoints/streaming_handler.py", rationale: "With include_cost_in_streaming_usage on, the /openai passthrough's final streaming usage frame carries the proxy-computed cost (#36503)"}+- {id: quota_management.spend_tracking.passthrough_stream.injects_usage_cost, module: quota_management, tier: P1, behavior: spend_tracking, variant: passthrough_stream, assertions: [injects_usage_cost], exercised_on: [openai_passthrough], source: "proxy/pass_through_endpoints/streaming_handler.py", rationale: "With include_cost_in_streaming_usage on, the /openai passthrough's final streaming usage frame carries the proxy-computed cost (#36503). Uncovered: the flag is only settable in litellm_settings, and the shared e2e proxy's config is not in this repo"}diff --git a/tests/e2e/models.py b/tests/e2e/models.pyindex fe93b13e0a4..f1d5733253a 100644--- a/tests/e2e/models.py+++ b/tests/e2e/models.py@@ -216,19 +216,10 @@ class McpChatTool(BaseModel):allowed_tools: list[str] | None = None-class StreamOptions(BaseModel):- """OpenAI `stream_options`: `include_usage` asks for a final usage-only SSE- frame, which is where the proxy's `include_cost_in_streaming_usage` setting- injects `usage.cost`."""-- include_usage: bool = True--class ChatBody(BaseModel):model: strmessages: list[ChatMessage]stream: bool = False- stream_options: StreamOptions | None = Nonemax_tokens: int | None = Nonemax_completion_tokens: int | None = Nonetemperature: float | None = None@@ -331,9 +322,6 @@ class CompletionTokensDetails(BaseModel):class Usage(BaseModel):- """`cost` exists only on streaming usage frames from a proxy running with- `include_cost_in_streaming_usage: true`; providers never send it."""-prompt_tokens: int | None = Nonecompletion_tokens: int | None = Nonetotal_tokens: int | None = None@@ -341,7 +329,6 @@ class Usage(BaseModel):cache_creation_input_tokens: int | None = Noneprompt_tokens_details: PromptTokensDetails | None = Nonecompletion_tokens_details: CompletionTokensDetails | None = None- cost: float | None = Noneclass ChatResponse(BaseModel):@@ -462,7 +449,6 @@ class AnthropicMessagesResponse(BaseModel):for triage."""model_config = ConfigDict(extra="allow")- id: str | None = Nonemodel: str | None = Nonecontent: list[AnthropicContentBlock] | None = Nonechoices: list[ChatChoice] | None = Nonediff --git a/tests/e2e/quota_management/spend_tracking/test_passthrough_stream_cost_e2e.py b/tests/e2e/quota_management/spend_tracking/test_passthrough_stream_cost_e2e.pydeleted file mode 100644index 4c3a2a4509f..00000000000--- a/tests/e2e/quota_management/spend_tracking/test_passthrough_stream_cost_e2e.py+++ /dev/null@@ -1,68 +0,0 @@-"""Live e2e: the /openai passthrough injects usage.cost into streaming usage frames.--Pins #36503: with the proxy running `include_cost_in_streaming_usage: true`, a-streamed call through the provider passthrough surface must carry the computed-cost inside the final usage-only SSE frame, the same contract the native-/chat/completions stream has. Providers never send `cost` themselves, so a-nonzero value proves the proxy computed and injected it on the passthrough path.--The row-side spend accounting for passthrough calls is covered elsewhere; this-test pins only the in-stream cost surface, which clients read without ever-touching /spend/logs.-"""--import pytest-from pydantic import BaseModel--from e2e_config import unique_marker-from models import ChatBody, ChatMessage, StreamOptions, Usage-from spend_e2e_client import SpendClient--pytestmark = pytest.mark.e2e--OPENAI_MODEL = "gpt-5.6-luna"---class _StreamFrame(BaseModel):- usage: Usage | None = None---class TestPassthroughStreamCost:- @pytest.mark.covers("quota_management.spend_tracking.passthrough_stream.injects_usage_cost")- def test_passthrough_stream_final_usage_frame_carries_cost(- self, client: SpendClient, scoped_key: str- ) -> None:- result = client.proxy.transport.send(- "/openai/v1/chat/completions",- headers=client.proxy.transport.bearer(scoped_key),- json=ChatBody(- model=OPENAI_MODEL,- messages=[- ChatMessage(- role="user",- content=f"{unique_marker()} Reply with the single word passthrough.",- )- ],- stream=True,- stream_options=StreamOptions(),- ),- stream=True,- )- assert result.ok and result.stream_events, (- f"passthrough stream failed (status {result.status_code}): {result.body[:300]}"- )-- usage_frames = [- frame.usage- for frame in (_StreamFrame.model_validate_json(event) for event in result.stream_events)- if frame.usage is not None- ]- assert usage_frames, (- f"no usage frame in the passthrough stream despite stream_options.include_usage; "- f"last event: {result.stream_events[-1][:300]}"- )-- final_usage = usage_frames[-1]- assert final_usage.cost is not None and final_usage.cost > 0, (- f"final passthrough usage frame carries no injected cost: {final_usage}"- )