diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index b9c8824aa675..d15a624eedff 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -6501,6 +6501,10 @@ "supports_web_search": true }, "azure/gpt-5.6": { + "cache_creation_input_token_cost": 6.25e-06, + "cache_creation_input_token_cost_above_272k_tokens": 1.25e-05, + "cache_creation_input_token_cost_priority": 1.25e-05, + "cache_creation_input_token_cost_above_272k_tokens_priority": 2.5e-05, "cache_read_input_token_cost": 5e-07, "cache_read_input_token_cost_above_272k_tokens": 1e-06, "cache_read_input_token_cost_priority": 1e-06, @@ -6551,6 +6555,10 @@ "supports_minimal_reasoning_effort": false }, "azure/gpt-5.6-sol": { + "cache_creation_input_token_cost": 6.25e-06, + "cache_creation_input_token_cost_above_272k_tokens": 1.25e-05, + "cache_creation_input_token_cost_priority": 1.25e-05, + "cache_creation_input_token_cost_above_272k_tokens_priority": 2.5e-05, "cache_read_input_token_cost": 5e-07, "cache_read_input_token_cost_above_272k_tokens": 1e-06, "cache_read_input_token_cost_priority": 1e-06, @@ -6602,6 +6610,10 @@ "supports_minimal_reasoning_effort": false }, "azure/gpt-5.6-terra": { + "cache_creation_input_token_cost": 2.5e-06, + "cache_creation_input_token_cost_above_272k_tokens": 5e-06, + "cache_creation_input_token_cost_priority": 5e-06, + "cache_creation_input_token_cost_above_272k_tokens_priority": 1e-05, "cache_read_input_token_cost": 2e-07, "cache_read_input_token_cost_above_272k_tokens": 4e-07, "cache_read_input_token_cost_priority": 4e-07, @@ -6653,6 +6665,10 @@ "supports_minimal_reasoning_effort": false }, "azure/gpt-5.6-luna": { + "cache_creation_input_token_cost": 2.5e-07, + "cache_creation_input_token_cost_above_272k_tokens": 5e-07, + "cache_creation_input_token_cost_priority": 5e-07, + "cache_creation_input_token_cost_above_272k_tokens_priority": 1e-06, "cache_read_input_token_cost": 2e-08, "cache_read_input_token_cost_above_272k_tokens": 4e-08, "cache_read_input_token_cost_priority": 4e-08, @@ -6704,12 +6720,15 @@ "supports_minimal_reasoning_effort": false }, "azure/us/gpt-5.6": { + "cache_creation_input_token_cost": 6.875e-06, + "cache_creation_input_token_cost_above_272k_tokens": 1.375e-05, + "cache_creation_input_token_cost_priority": 1.375e-05, "cache_read_input_token_cost": 5.5e-07, "cache_read_input_token_cost_above_272k_tokens": 1.1e-06, - "cache_read_input_token_cost_priority": 1.375e-06, + "cache_read_input_token_cost_priority": 1.1e-06, "input_cost_per_token": 5.5e-06, "input_cost_per_token_above_272k_tokens": 1.1e-05, - "input_cost_per_token_priority": 1.375e-05, + "input_cost_per_token_priority": 1.1e-05, "litellm_provider": "azure", "max_input_tokens": 1050000, "max_output_tokens": 128000, @@ -6717,7 +6736,7 @@ "mode": "chat", "output_cost_per_token": 3.3e-05, "output_cost_per_token_above_272k_tokens": 4.95e-05, - "output_cost_per_token_priority": 8.25e-05, + "output_cost_per_token_priority": 6.6e-05, "search_context_cost_per_query": { "search_context_size_high": 0.01, "search_context_size_low": 0.01, @@ -6751,13 +6770,16 @@ "supports_minimal_reasoning_effort": false }, "azure/us/gpt-5.6-sol": { + "cache_creation_input_token_cost": 6.875e-06, + "cache_creation_input_token_cost_above_272k_tokens": 1.375e-05, + "cache_creation_input_token_cost_priority": 1.375e-05, "cache_read_input_token_cost": 5.5e-07, "cache_read_input_token_cost_above_272k_tokens": 1.1e-06, - "cache_read_input_token_cost_priority": 1.375e-06, + "cache_read_input_token_cost_priority": 1.1e-06, "deprecation_date": "2028-01-11", "input_cost_per_token": 5.5e-06, "input_cost_per_token_above_272k_tokens": 1.1e-05, - "input_cost_per_token_priority": 1.375e-05, + "input_cost_per_token_priority": 1.1e-05, "litellm_provider": "azure", "max_input_tokens": 1050000, "max_output_tokens": 128000, @@ -6765,7 +6787,7 @@ "mode": "chat", "output_cost_per_token": 3.3e-05, "output_cost_per_token_above_272k_tokens": 4.95e-05, - "output_cost_per_token_priority": 8.25e-05, + "output_cost_per_token_priority": 6.6e-05, "search_context_cost_per_query": { "search_context_size_high": 0.01, "search_context_size_low": 0.01, @@ -6799,6 +6821,9 @@ "supports_minimal_reasoning_effort": false }, "azure/us/gpt-5.6-terra": { + "cache_creation_input_token_cost": 2.75e-06, + "cache_creation_input_token_cost_above_272k_tokens": 5.5e-06, + "cache_creation_input_token_cost_priority": 6.875e-06, "cache_read_input_token_cost": 2.2e-07, "cache_read_input_token_cost_above_272k_tokens": 4.4e-07, "cache_read_input_token_cost_priority": 5.5e-07, @@ -6847,6 +6872,9 @@ "supports_minimal_reasoning_effort": false }, "azure/us/gpt-5.6-luna": { + "cache_creation_input_token_cost": 2.75e-07, + "cache_creation_input_token_cost_above_272k_tokens": 5.5e-07, + "cache_creation_input_token_cost_priority": 6.875e-07, "cache_read_input_token_cost": 2.2e-08, "cache_read_input_token_cost_above_272k_tokens": 4.4e-08, "cache_read_input_token_cost_priority": 5.5e-08, @@ -6895,12 +6923,15 @@ "supports_minimal_reasoning_effort": false }, "azure/eu/gpt-5.6": { + "cache_creation_input_token_cost": 6.875e-06, + "cache_creation_input_token_cost_above_272k_tokens": 1.375e-05, + "cache_creation_input_token_cost_priority": 1.375e-05, "cache_read_input_token_cost": 5.5e-07, "cache_read_input_token_cost_above_272k_tokens": 1.1e-06, - "cache_read_input_token_cost_priority": 1.375e-06, + "cache_read_input_token_cost_priority": 1.1e-06, "input_cost_per_token": 5.5e-06, "input_cost_per_token_above_272k_tokens": 1.1e-05, - "input_cost_per_token_priority": 1.375e-05, + "input_cost_per_token_priority": 1.1e-05, "litellm_provider": "azure", "max_input_tokens": 1050000, "max_output_tokens": 128000, @@ -6908,7 +6939,7 @@ "mode": "chat", "output_cost_per_token": 3.3e-05, "output_cost_per_token_above_272k_tokens": 4.95e-05, - "output_cost_per_token_priority": 8.25e-05, + "output_cost_per_token_priority": 6.6e-05, "search_context_cost_per_query": { "search_context_size_high": 0.01, "search_context_size_low": 0.01, @@ -6942,13 +6973,16 @@ "supports_minimal_reasoning_effort": false }, "azure/eu/gpt-5.6-sol": { + "cache_creation_input_token_cost": 6.875e-06, + "cache_creation_input_token_cost_above_272k_tokens": 1.375e-05, + "cache_creation_input_token_cost_priority": 1.375e-05, "cache_read_input_token_cost": 5.5e-07, "cache_read_input_token_cost_above_272k_tokens": 1.1e-06, - "cache_read_input_token_cost_priority": 1.375e-06, + "cache_read_input_token_cost_priority": 1.1e-06, "deprecation_date": "2028-01-11", "input_cost_per_token": 5.5e-06, "input_cost_per_token_above_272k_tokens": 1.1e-05, - "input_cost_per_token_priority": 1.375e-05, + "input_cost_per_token_priority": 1.1e-05, "litellm_provider": "azure", "max_input_tokens": 1050000, "max_output_tokens": 128000, @@ -6956,7 +6990,7 @@ "mode": "chat", "output_cost_per_token": 3.3e-05, "output_cost_per_token_above_272k_tokens": 4.95e-05, - "output_cost_per_token_priority": 8.25e-05, + "output_cost_per_token_priority": 6.6e-05, "search_context_cost_per_query": { "search_context_size_high": 0.01, "search_context_size_low": 0.01, @@ -6990,6 +7024,9 @@ "supports_minimal_reasoning_effort": false }, "azure/eu/gpt-5.6-terra": { + "cache_creation_input_token_cost": 2.75e-06, + "cache_creation_input_token_cost_above_272k_tokens": 5.5e-06, + "cache_creation_input_token_cost_priority": 6.875e-06, "cache_read_input_token_cost": 2.2e-07, "cache_read_input_token_cost_above_272k_tokens": 4.4e-07, "cache_read_input_token_cost_priority": 5.5e-07, @@ -7038,6 +7075,9 @@ "supports_minimal_reasoning_effort": false }, "azure/eu/gpt-5.6-luna": { + "cache_creation_input_token_cost": 2.75e-07, + "cache_creation_input_token_cost_above_272k_tokens": 5.5e-07, + "cache_creation_input_token_cost_priority": 6.875e-07, "cache_read_input_token_cost": 2.2e-08, "cache_read_input_token_cost_above_272k_tokens": 4.4e-08, "cache_read_input_token_cost_priority": 5.5e-08, diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index b9c8824aa675..d15a624eedff 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -6501,6 +6501,10 @@ "supports_web_search": true }, "azure/gpt-5.6": { + "cache_creation_input_token_cost": 6.25e-06, + "cache_creation_input_token_cost_above_272k_tokens": 1.25e-05, + "cache_creation_input_token_cost_priority": 1.25e-05, + "cache_creation_input_token_cost_above_272k_tokens_priority": 2.5e-05, "cache_read_input_token_cost": 5e-07, "cache_read_input_token_cost_above_272k_tokens": 1e-06, "cache_read_input_token_cost_priority": 1e-06, @@ -6551,6 +6555,10 @@ "supports_minimal_reasoning_effort": false }, "azure/gpt-5.6-sol": { + "cache_creation_input_token_cost": 6.25e-06, + "cache_creation_input_token_cost_above_272k_tokens": 1.25e-05, + "cache_creation_input_token_cost_priority": 1.25e-05, + "cache_creation_input_token_cost_above_272k_tokens_priority": 2.5e-05, "cache_read_input_token_cost": 5e-07, "cache_read_input_token_cost_above_272k_tokens": 1e-06, "cache_read_input_token_cost_priority": 1e-06, @@ -6602,6 +6610,10 @@ "supports_minimal_reasoning_effort": false }, "azure/gpt-5.6-terra": { + "cache_creation_input_token_cost": 2.5e-06, + "cache_creation_input_token_cost_above_272k_tokens": 5e-06, + "cache_creation_input_token_cost_priority": 5e-06, + "cache_creation_input_token_cost_above_272k_tokens_priority": 1e-05, "cache_read_input_token_cost": 2e-07, "cache_read_input_token_cost_above_272k_tokens": 4e-07, "cache_read_input_token_cost_priority": 4e-07, @@ -6653,6 +6665,10 @@ "supports_minimal_reasoning_effort": false }, "azure/gpt-5.6-luna": { + "cache_creation_input_token_cost": 2.5e-07, + "cache_creation_input_token_cost_above_272k_tokens": 5e-07, + "cache_creation_input_token_cost_priority": 5e-07, + "cache_creation_input_token_cost_above_272k_tokens_priority": 1e-06, "cache_read_input_token_cost": 2e-08, "cache_read_input_token_cost_above_272k_tokens": 4e-08, "cache_read_input_token_cost_priority": 4e-08, @@ -6704,12 +6720,15 @@ "supports_minimal_reasoning_effort": false }, "azure/us/gpt-5.6": { + "cache_creation_input_token_cost": 6.875e-06, + "cache_creation_input_token_cost_above_272k_tokens": 1.375e-05, + "cache_creation_input_token_cost_priority": 1.375e-05, "cache_read_input_token_cost": 5.5e-07, "cache_read_input_token_cost_above_272k_tokens": 1.1e-06, - "cache_read_input_token_cost_priority": 1.375e-06, + "cache_read_input_token_cost_priority": 1.1e-06, "input_cost_per_token": 5.5e-06, "input_cost_per_token_above_272k_tokens": 1.1e-05, - "input_cost_per_token_priority": 1.375e-05, + "input_cost_per_token_priority": 1.1e-05, "litellm_provider": "azure", "max_input_tokens": 1050000, "max_output_tokens": 128000, @@ -6717,7 +6736,7 @@ "mode": "chat", "output_cost_per_token": 3.3e-05, "output_cost_per_token_above_272k_tokens": 4.95e-05, - "output_cost_per_token_priority": 8.25e-05, + "output_cost_per_token_priority": 6.6e-05, "search_context_cost_per_query": { "search_context_size_high": 0.01, "search_context_size_low": 0.01, @@ -6751,13 +6770,16 @@ "supports_minimal_reasoning_effort": false }, "azure/us/gpt-5.6-sol": { + "cache_creation_input_token_cost": 6.875e-06, + "cache_creation_input_token_cost_above_272k_tokens": 1.375e-05, + "cache_creation_input_token_cost_priority": 1.375e-05, "cache_read_input_token_cost": 5.5e-07, "cache_read_input_token_cost_above_272k_tokens": 1.1e-06, - "cache_read_input_token_cost_priority": 1.375e-06, + "cache_read_input_token_cost_priority": 1.1e-06, "deprecation_date": "2028-01-11", "input_cost_per_token": 5.5e-06, "input_cost_per_token_above_272k_tokens": 1.1e-05, - "input_cost_per_token_priority": 1.375e-05, + "input_cost_per_token_priority": 1.1e-05, "litellm_provider": "azure", "max_input_tokens": 1050000, "max_output_tokens": 128000, @@ -6765,7 +6787,7 @@ "mode": "chat", "output_cost_per_token": 3.3e-05, "output_cost_per_token_above_272k_tokens": 4.95e-05, - "output_cost_per_token_priority": 8.25e-05, + "output_cost_per_token_priority": 6.6e-05, "search_context_cost_per_query": { "search_context_size_high": 0.01, "search_context_size_low": 0.01, @@ -6799,6 +6821,9 @@ "supports_minimal_reasoning_effort": false }, "azure/us/gpt-5.6-terra": { + "cache_creation_input_token_cost": 2.75e-06, + "cache_creation_input_token_cost_above_272k_tokens": 5.5e-06, + "cache_creation_input_token_cost_priority": 6.875e-06, "cache_read_input_token_cost": 2.2e-07, "cache_read_input_token_cost_above_272k_tokens": 4.4e-07, "cache_read_input_token_cost_priority": 5.5e-07, @@ -6847,6 +6872,9 @@ "supports_minimal_reasoning_effort": false }, "azure/us/gpt-5.6-luna": { + "cache_creation_input_token_cost": 2.75e-07, + "cache_creation_input_token_cost_above_272k_tokens": 5.5e-07, + "cache_creation_input_token_cost_priority": 6.875e-07, "cache_read_input_token_cost": 2.2e-08, "cache_read_input_token_cost_above_272k_tokens": 4.4e-08, "cache_read_input_token_cost_priority": 5.5e-08, @@ -6895,12 +6923,15 @@ "supports_minimal_reasoning_effort": false }, "azure/eu/gpt-5.6": { + "cache_creation_input_token_cost": 6.875e-06, + "cache_creation_input_token_cost_above_272k_tokens": 1.375e-05, + "cache_creation_input_token_cost_priority": 1.375e-05, "cache_read_input_token_cost": 5.5e-07, "cache_read_input_token_cost_above_272k_tokens": 1.1e-06, - "cache_read_input_token_cost_priority": 1.375e-06, + "cache_read_input_token_cost_priority": 1.1e-06, "input_cost_per_token": 5.5e-06, "input_cost_per_token_above_272k_tokens": 1.1e-05, - "input_cost_per_token_priority": 1.375e-05, + "input_cost_per_token_priority": 1.1e-05, "litellm_provider": "azure", "max_input_tokens": 1050000, "max_output_tokens": 128000, @@ -6908,7 +6939,7 @@ "mode": "chat", "output_cost_per_token": 3.3e-05, "output_cost_per_token_above_272k_tokens": 4.95e-05, - "output_cost_per_token_priority": 8.25e-05, + "output_cost_per_token_priority": 6.6e-05, "search_context_cost_per_query": { "search_context_size_high": 0.01, "search_context_size_low": 0.01, @@ -6942,13 +6973,16 @@ "supports_minimal_reasoning_effort": false }, "azure/eu/gpt-5.6-sol": { + "cache_creation_input_token_cost": 6.875e-06, + "cache_creation_input_token_cost_above_272k_tokens": 1.375e-05, + "cache_creation_input_token_cost_priority": 1.375e-05, "cache_read_input_token_cost": 5.5e-07, "cache_read_input_token_cost_above_272k_tokens": 1.1e-06, - "cache_read_input_token_cost_priority": 1.375e-06, + "cache_read_input_token_cost_priority": 1.1e-06, "deprecation_date": "2028-01-11", "input_cost_per_token": 5.5e-06, "input_cost_per_token_above_272k_tokens": 1.1e-05, - "input_cost_per_token_priority": 1.375e-05, + "input_cost_per_token_priority": 1.1e-05, "litellm_provider": "azure", "max_input_tokens": 1050000, "max_output_tokens": 128000, @@ -6956,7 +6990,7 @@ "mode": "chat", "output_cost_per_token": 3.3e-05, "output_cost_per_token_above_272k_tokens": 4.95e-05, - "output_cost_per_token_priority": 8.25e-05, + "output_cost_per_token_priority": 6.6e-05, "search_context_cost_per_query": { "search_context_size_high": 0.01, "search_context_size_low": 0.01, @@ -6990,6 +7024,9 @@ "supports_minimal_reasoning_effort": false }, "azure/eu/gpt-5.6-terra": { + "cache_creation_input_token_cost": 2.75e-06, + "cache_creation_input_token_cost_above_272k_tokens": 5.5e-06, + "cache_creation_input_token_cost_priority": 6.875e-06, "cache_read_input_token_cost": 2.2e-07, "cache_read_input_token_cost_above_272k_tokens": 4.4e-07, "cache_read_input_token_cost_priority": 5.5e-07, @@ -7038,6 +7075,9 @@ "supports_minimal_reasoning_effort": false }, "azure/eu/gpt-5.6-luna": { + "cache_creation_input_token_cost": 2.75e-07, + "cache_creation_input_token_cost_above_272k_tokens": 5.5e-07, + "cache_creation_input_token_cost_priority": 6.875e-07, "cache_read_input_token_cost": 2.2e-08, "cache_read_input_token_cost_above_272k_tokens": 4.4e-08, "cache_read_input_token_cost_priority": 5.5e-08, diff --git a/model_prices_and_context_window.schema.json b/model_prices_and_context_window.schema.json index 0991650d3077..987014f017c0 100644 --- a/model_prices_and_context_window.schema.json +++ b/model_prices_and_context_window.schema.json @@ -104,6 +104,11 @@ "minimum": 0, "description": "Flex service-tier rate for the same-named base field." }, + "cache_creation_input_token_cost_above_272k_tokens_priority": { + "type": "number", + "minimum": 0, + "description": "Priority service-tier rate for the same-named base field." + }, "cache_creation_input_token_cost_flex": { "type": "number", "minimum": 0, 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.py index 06be96fefdf6..4b5dcbb0b397 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 @@ -1071,8 +1071,11 @@ def test_generic_cost_per_token_gpt56_terra_cache_costs_by_tier_and_context( def test_generic_cost_per_token_azure_gpt56( model, input_cost, output_cost, cache_read_cost ): - """Azure gpt-5.6 (global + us/eu regional): pricing mirrors the openai - family for global deployments and carries the standard 10% regional uplift. + """Azure gpt-5.6 (global + us/eu regional). + + Sol matches Azure's published global/data-zone list. Terra and luna track + the 2026-07-30 OpenAI cut that the Foundry blog and Azure Support say + applied on Azure from 2026-08-01 ($2/$12 and $0.20/$1.20 global). """ os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True" litellm.model_cost = litellm.get_model_cost_map(url="") @@ -3470,6 +3473,129 @@ def test_tier_request_without_tier_pricing_keeps_the_standard_reasoning_rate(): assert completion_cost == pytest.approx(400 * 4e-06 + 600 * 6e-06, rel=1e-9) +@pytest.mark.parametrize( + "model,write_cost,write_cost_priority,write_cost_above_272k,write_cost_above_272k_priority", + [ + ("azure/gpt-5.6", 6.25e-06, 1.25e-05, 1.25e-05, 2.5e-05), + ("azure/gpt-5.6-sol", 6.25e-06, 1.25e-05, 1.25e-05, 2.5e-05), + ("azure/gpt-5.6-terra", 2.5e-06, 5e-06, 5e-06, 1e-05), + ("azure/gpt-5.6-luna", 2.5e-07, 5e-07, 5e-07, 1e-06), + ("azure/us/gpt-5.6", 6.875e-06, 1.375e-05, 1.375e-05, None), + ("azure/us/gpt-5.6-sol", 6.875e-06, 1.375e-05, 1.375e-05, None), + ("azure/us/gpt-5.6-terra", 2.75e-06, 6.875e-06, 5.5e-06, None), + ("azure/us/gpt-5.6-luna", 2.75e-07, 6.875e-07, 5.5e-07, None), + ("azure/eu/gpt-5.6", 6.875e-06, 1.375e-05, 1.375e-05, None), + ("azure/eu/gpt-5.6-sol", 6.875e-06, 1.375e-05, 1.375e-05, None), + ("azure/eu/gpt-5.6-terra", 2.75e-06, 6.875e-06, 5.5e-06, None), + ("azure/eu/gpt-5.6-luna", 2.75e-07, 6.875e-07, 5.5e-07, None), + ], +) +def test_generic_cost_per_token_azure_gpt_5_6_cache_write_tokens( + model: str, + write_cost: float, + write_cost_priority: float, + write_cost_above_272k: float, + write_cost_above_272k_priority, + _local_model_cost_map, +): + """ + Azure Foundry bills GPT-5.6 prompt-cache writes at 1.25x the matching input + cell. Data-zone sol/gpt-5.6 priority writes are Azure's $13.75/1M cell, not + 1.25x of our stale $13.75 priority input. Luna and terra writes track the + 2026-07-30 cut on the Foundry blog ($0.25 and $2.50 global). Long+priority + writes on the four global entries are inferred (Azure publishes no + long+priority cell). + """ + info = litellm.get_model_info(model=model, custom_llm_provider="azure") + assert info["cache_creation_input_token_cost"] == pytest.approx(write_cost) + assert info["cache_creation_input_token_cost_priority"] == pytest.approx(write_cost_priority) + short_usage = Usage( + prompt_tokens=1000, + completion_tokens=10, + total_tokens=1010, + prompt_tokens_details=PromptTokensDetailsWrapper(cached_tokens=0, cache_write_tokens=800), + ) + + prompt_cost, _ = generic_cost_per_token(model=model, usage=short_usage, custom_llm_provider="azure") + assert prompt_cost == pytest.approx(200 * info["input_cost_per_token"] + 800 * write_cost) + + priority_cost, _ = generic_cost_per_token( + model=model, usage=short_usage, custom_llm_provider="azure", service_tier="priority" + ) + assert priority_cost == pytest.approx(200 * info["input_cost_per_token_priority"] + 800 * write_cost_priority) + + long_usage = Usage( + prompt_tokens=300000, + completion_tokens=10, + total_tokens=300010, + prompt_tokens_details=PromptTokensDetailsWrapper(cached_tokens=0, cache_write_tokens=800), + ) + long_cost, _ = generic_cost_per_token(model=model, usage=long_usage, custom_llm_provider="azure") + assert long_cost == pytest.approx( + (300000 - 800) * info["input_cost_per_token_above_272k_tokens"] + 800 * write_cost_above_272k + ) + + long_priority_cost, _ = generic_cost_per_token( + model=model, usage=long_usage, custom_llm_provider="azure", service_tier="priority" + ) + if write_cost_above_272k_priority is None: + assert long_priority_cost == pytest.approx( + (300000 - 800) * info["input_cost_per_token_above_272k_tokens"] + 800 * write_cost_above_272k + ) + return + assert long_priority_cost == pytest.approx( + (300000 - 800) * info["input_cost_per_token_above_272k_tokens_priority"] + + 800 * write_cost_above_272k_priority + ) + + +@pytest.mark.parametrize( + "model", + ["azure/us/gpt-5.6", "azure/us/gpt-5.6-sol", "azure/eu/gpt-5.6", "azure/eu/gpt-5.6-sol"], +) +def test_azure_data_zone_gpt56_priority_matches_azure_list(model, _local_model_cost_map): + """Azure data-zone gpt-5.6/-sol priority is $11 prompt / $13.75 write per 1M. + + The map previously stored $13.75 as the priority input (2.5x of $5.50 instead + of Azure's 2x) and derived writes as 1.25x of that, producing $17.1875. + """ + info = litellm.get_model_info(model=model, custom_llm_provider="azure") + assert info["input_cost_per_token_priority"] == pytest.approx(1.1e-05) + assert info["cache_read_input_token_cost_priority"] == pytest.approx(1.1e-06) + assert info["output_cost_per_token_priority"] == pytest.approx(6.6e-05) + assert info["cache_creation_input_token_cost_priority"] == pytest.approx(1.375e-05) + + +def test_generic_cost_per_token_openai_gpt_5_6_cache_write_service_tiers(_local_model_cost_map): + """ + OpenAI gpt-5.6 publishes flex and priority rates for prompt-cache writes + (cache_creation_input_token_cost_flex / _priority). Cache-write tokens on + flex/priority requests must be billed at those tier rates rather than the + standard cache-write rate. + """ + model = "gpt-5.6" + usage = Usage( + prompt_tokens=1000, + completion_tokens=10, + total_tokens=1010, + prompt_tokens_details=PromptTokensDetailsWrapper(cached_tokens=0, cache_write_tokens=800), + ) + info = litellm.get_model_info(model=model, custom_llm_provider="openai") + + flex_cost, _ = generic_cost_per_token( + model=model, usage=usage, custom_llm_provider="openai", service_tier="flex" + ) + assert flex_cost == pytest.approx( + 200 * info["input_cost_per_token_flex"] + 800 * info["cache_creation_input_token_cost_flex"] + ) + + priority_cost, _ = generic_cost_per_token( + model=model, usage=usage, custom_llm_provider="openai", service_tier="priority" + ) + assert priority_cost == pytest.approx( + 200 * info["input_cost_per_token_priority"] + 800 * info["cache_creation_input_token_cost_priority"] + ) + assert priority_cost > flex_cost GEMINI_37_FLASH_LAUNCH_PRICING = [ ("gemini-3.7-flash", 7.5e-07, 3.75e-06, 7.5e-08), ("gemini/gemini-3.7-flash", 7.5e-07, 3.75e-06, 7.5e-08), diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.py index cb58038e0816..808d78944aef 100644 --- a/tests/test_litellm/test_utils.py +++ b/tests/test_litellm/test_utils.py @@ -784,6 +784,9 @@ def test_aaamodel_prices_and_context_window_json_is_valid(): "cache_creation_input_token_cost_above_272k_tokens_flex": { "type": "number" }, + "cache_creation_input_token_cost_above_272k_tokens_priority": { + "type": "number" + }, "cache_creation_input_token_cost_flex": {"type": "number"}, "cache_creation_input_token_cost_priority": {"type": "number"}, "cache_read_input_token_cost": {"type": "number"},