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
chore: merge litellm_cost_shard_audio_images into litellm_cost_shard_passthrough
kerry61ea3e0226b0
diff --cc tests/integration/cost_calculation/test_cost_tracking.pyindex c2ac6e77a3f,32ecd573363..9adc194f88d--- a/tests/integration/cost_calculation/test_cost_tracking.py+++ b/tests/integration/cost_calculation/test_cost_tracking.py@@@ -4,18 -4,16 +4,16 @@@ from __future__ import annotationimport ioimport json--from hashlib import sha256import struct--from typing import Final, castimport waveimport zlib++from hashlib import sha256++from typing import Final, castimport httpximport pytest- from pydantic import JsonValue--from integration._support.client import JSON_OBJECT, Gateway+from integration._support.upstream import delete_scenario, register_scenariofrom integration.cost_calculation.conftest import (CostBreakdown,approx_equal,@@@ -25,14 -23,14 +23,15 @@@register_scenario_deployment,)from integration.cost_calculation.cost_tracking_case import (-- BinaryResponse,CASES,++ BinaryResponse,CostTrackingTestCase,ExactExpected,FailureExpected,RecountExpected,data_errors,)++from pydantic import JsonValueif _data_errors := data_errors():raise ValueError("\n".join(_data_errors))@@@ -272,14 -220,13 +271,14 @@@ def test_case_bills_expected_cost(gatew)elif case.response.content_type == "application/json":header: Final = cast(str | None, response.headers.get("x-litellm-response-cost"))- if expected.cost_header:- assert (- (header is None or approx_equal(float(header), 0.0))- if expected.spend == 0- else (header is not None and approx_equal(float(header), expected.spend))- ), (- f"{case.name}: x-litellm-response-cost {header} != expected {expected.spend}"- )++ if expected.cost_header and expected.spend != 0:+ assert header is not None and approx_equal(float(header), expected.spend), (+ f"{case.name}: x-litellm-response-cost {header} != expected {expected.spend}"+ )+ elif header is not None:+ assert approx_equal(float(header), expected.spend), (+ f"{case.name}: x-litellm-response-cost {header} != expected {expected.spend}"+ )assert row.spend is not None and approx_equal(row.spend, expected.spend), (f"{case.name}: spend {row.spend} != expected {expected.spend} "f"(breakdown {row.breakdown.model_dump() if row.breakdown is not None else None})"