This commit is contained in:
Marty Sullivan 2026-09-12 13:05:12 +00:00 committed by GitHub
commit b6d1d64ac7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 90 additions and 9 deletions

View file

@ -5578,6 +5578,7 @@
"supports_tool_choice": true
},
"azure/gpt-realtime-2": {
"cache_creation_input_audio_token_cost": 4e-07,
"cache_read_input_audio_token_cost": 4e-07,
"cache_read_input_token_cost": 4e-07,
"deprecation_date": "2026-08-31",
@ -24152,7 +24153,6 @@
"input_cost_per_image_token": 3e-06
},
"gemini-live-2.5-flash-preview-native-audio-09-2025": {
"cache_read_input_token_cost": 7.5e-08,
"input_cost_per_audio_token": 3e-06,
"input_cost_per_token": 5e-07,
"litellm_provider": "vertex_ai-language-models",
@ -24181,7 +24181,7 @@
"supports_function_calling": true,
"supports_parallel_function_calling": true,
"supports_pdf_input": true,
"supports_prompt_caching": true,
"supports_prompt_caching": false,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,
@ -24196,7 +24196,6 @@
"gemini_native_audio": true
},
"gemini/gemini-live-2.5-flash-preview-native-audio-09-2025": {
"cache_read_input_token_cost": 7.5e-08,
"input_cost_per_audio_token": 3e-06,
"input_cost_per_token": 5e-07,
"litellm_provider": "gemini",
@ -24226,7 +24225,7 @@
"supports_function_calling": true,
"supports_parallel_function_calling": true,
"supports_pdf_input": true,
"supports_prompt_caching": true,
"supports_prompt_caching": false,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,

View file

@ -5578,6 +5578,7 @@
"supports_tool_choice": true
},
"azure/gpt-realtime-2": {
"cache_creation_input_audio_token_cost": 4e-07,
"cache_read_input_audio_token_cost": 4e-07,
"cache_read_input_token_cost": 4e-07,
"deprecation_date": "2026-08-31",
@ -24152,7 +24153,6 @@
"input_cost_per_image_token": 3e-06
},
"gemini-live-2.5-flash-preview-native-audio-09-2025": {
"cache_read_input_token_cost": 7.5e-08,
"input_cost_per_audio_token": 3e-06,
"input_cost_per_token": 5e-07,
"litellm_provider": "vertex_ai-language-models",
@ -24181,7 +24181,7 @@
"supports_function_calling": true,
"supports_parallel_function_calling": true,
"supports_pdf_input": true,
"supports_prompt_caching": true,
"supports_prompt_caching": false,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,
@ -24196,7 +24196,6 @@
"gemini_native_audio": true
},
"gemini/gemini-live-2.5-flash-preview-native-audio-09-2025": {
"cache_read_input_token_cost": 7.5e-08,
"input_cost_per_audio_token": 3e-06,
"input_cost_per_token": 5e-07,
"litellm_provider": "gemini",
@ -24226,7 +24225,7 @@
"supports_function_calling": true,
"supports_parallel_function_calling": true,
"supports_pdf_input": true,
"supports_prompt_caching": true,
"supports_prompt_caching": false,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,

View file

@ -26,7 +26,7 @@ from litellm.types.utils import (
PromptTokensDetailsWrapper,
Usage,
)
from litellm.utils import TranscriptionResponse
from litellm.utils import TranscriptionResponse, supports_prompt_caching
@pytest.fixture
@ -305,6 +305,71 @@ def test_github_copilot_mai_code_1_flash_pricing(_local_model_cost_map, model):
assert completion_usd == pytest.approx(500 * 4.5e-06)
GPT_REALTIME_2_FAMILY: Final = (
"azure/gpt-realtime-2",
"azure/gpt-realtime-2.1",
"azure/gpt-realtime-2.1-mini",
"gpt-realtime-2",
"gpt-realtime-2.1",
"gpt-realtime-2.1-mini",
)
def test_gpt_realtime_2_family_prices_audio_cache_writes_and_reads_alike(_local_model_cost_map: None) -> None:
"""Azure publishes one cached-audio meter per gpt-realtime-2 deployment, so the write rate equals the read."""
audio_cache_rates: Final = {
model: (
litellm.model_cost[model].get("cache_read_input_audio_token_cost"),
litellm.model_cost[model].get("cache_creation_input_audio_token_cost"),
)
for model in GPT_REALTIME_2_FAMILY
}
assert all(read is not None and write == read for read, write in audio_cache_rates.values()), audio_cache_rates
assert audio_cache_rates["azure/gpt-realtime-2"] == (4e-07, 4e-07)
GEMINI_LIVE_NATIVE_AUDIO_CASES: Final = (
("gemini-live-2.5-flash-native-audio", "vertex_ai"),
("gemini-live-2.5-flash-preview-native-audio-09-2025", "vertex_ai"),
("gemini/gemini-live-2.5-flash-preview-native-audio-09-2025", "gemini"),
)
@pytest.mark.parametrize(("model", "provider"), GEMINI_LIVE_NATIVE_AUDIO_CASES)
def test_gemini_live_native_audio_carries_no_cached_input_rate(
_local_model_cost_map: None, model: str, provider: str
) -> None:
"""Google prints N/A in both cached columns for every Live API row, so no cached-input rate can be charged."""
assert litellm.get_model_info(model, custom_llm_provider=provider)["cache_read_input_token_cost"] is None
prompt_usd, _ = cost_per_token(
model=model,
prompt_tokens=101_000,
completion_tokens=0,
custom_llm_provider=provider,
usage_object=Usage(
prompt_tokens=101_000,
completion_tokens=0,
prompt_tokens_details=PromptTokensDetailsWrapper(cached_tokens=100_000),
),
)
assert prompt_usd == pytest.approx(1_000 * 5e-07), "the 100k cached tokens drop out with no cached rate to charge"
@pytest.mark.parametrize(("model", "provider"), GEMINI_LIVE_NATIVE_AUDIO_CASES)
def test_gemini_live_native_audio_declares_prompt_caching_unsupported(
_local_model_cost_map: None, model: str, provider: str
) -> None:
"""The vendor's documented no has to be recorded as False, since an absent key reads back as None."""
assert litellm.get_model_info(model, custom_llm_provider=provider)["supports_prompt_caching"] is False
assert supports_prompt_caching(model=model, custom_llm_provider=provider) is False
assert supports_prompt_caching(model="gemini-2.5-flash", custom_llm_provider="vertex_ai") is True, (
"control: the helper swallows a lookup error into False, so without this a broken lookup reads as a pass"
)
def test_cost_calculator_with_usage(_local_model_cost_map, monkeypatch):
usage = Usage(
@ -4501,6 +4566,24 @@ def test_gemini_live_native_audio_ga_realtime_cost(_local_model_cost_map: None)
assert cost == pytest.approx(expected_cost, rel=1e-9)
@pytest.mark.parametrize(
"model",
["gemini-live-2.5-flash-native-audio", "vertex_ai/gemini-live-2.5-flash-native-audio"],
)
def test_gemini_live_native_audio_limits_and_capabilities_match_vendor_model_card(
_local_model_cost_map: None, model: str
) -> None:
"""Google's card for model ID gemini-live-2.5-flash-native-audio is the source for these limits and flags."""
info = litellm.get_model_info(model)
assert info["max_input_tokens"] == 131072
assert info["max_output_tokens"] == 65536
assert info["max_tokens"] == 65536
assert info["supports_response_schema"] is False
assert info["supports_url_context"] is False
assert info["supports_pdf_input"] is False
@pytest.mark.parametrize(
"priceless_entry",
[