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(cost): cover reasoning nested in text_tokens beside audio output
mateo-berri92e449d4d0c4
diff --git a/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py b/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.pyindex 19464dfd2a0..29874c5cca7 100644--- a/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py+++ b/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py@@ -4774,3 +4774,22 @@ def test_generic_cost_per_token_keeps_billing_reasoning_reported_beside_text_tokinfo = litellm.get_model_info(model=model, custom_llm_provider="openai")assert completion_cost == pytest.approx(44 * info["output_cost_per_token"])+++def test_generic_cost_per_token_bills_nested_reasoning_once_beside_audio_output(_local_model_cost_map: None) -> None:+ """Audio-output realtime usage nests reasoning inside text_tokens next to audio_tokens; text is billed net of it."""++ model = "gpt-realtime-2.1-mini"+ usage = Usage(+ prompt_tokens=120,+ completion_tokens=100,+ total_tokens=220,+ completion_tokens_details=CompletionTokensDetailsWrapper(text_tokens=30, audio_tokens=70, reasoning_tokens=20),+ )++ _, completion_cost = generic_cost_per_token(model=model, usage=usage, custom_llm_provider="openai")+ breakdown = get_token_type_cost_breakdown(model=model, custom_llm_provider="openai", usage=usage)++ info = litellm.get_model_info(model=model, custom_llm_provider="openai")+ assert breakdown.reasoning_cost == pytest.approx(20 * info["output_cost_per_token"])+ assert completion_cost == pytest.approx(30 * info["output_cost_per_token"] + 70 * info["output_cost_per_audio_token"])