mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
test(cost): cover reasoning nested in text_tokens beside audio output
This commit is contained in:
parent
5a7e938f37
commit
92e449d4d0
1 changed files with 19 additions and 0 deletions
|
|
@ -4774,3 +4774,22 @@ def test_generic_cost_per_token_keeps_billing_reasoning_reported_beside_text_tok
|
|||
|
||||
info = 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"])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue