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
feat(gemini): add gemini-3.1-flash-lite model cost map (#28320)
Sameer Kankute99a63d5180f7
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex 6d7c3eeb0b8..9ba337da0a5 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -1448,6 +1448,35 @@"supports_native_structured_output": true,"supports_minimal_reasoning_effort": true},+ "jp.anthropic.claude-sonnet-4-6": {+ "cache_creation_input_token_cost": 4.125e-06,+ "cache_read_input_token_cost": 3.3e-07,+ "input_cost_per_token": 3.3e-06,+ "litellm_provider": "bedrock_converse",+ "max_input_tokens": 1000000,+ "max_output_tokens": 64000,+ "max_tokens": 64000,+ "mode": "chat",+ "output_cost_per_token": 1.65e-05,+ "search_context_cost_per_query": {+ "search_context_size_high": 0.01,+ "search_context_size_low": 0.01,+ "search_context_size_medium": 0.01+ },+ "supports_assistant_prefill": true,+ "supports_computer_use": true,+ "supports_function_calling": true,+ "supports_pdf_input": true,+ "supports_prompt_caching": true,+ "supports_reasoning": true,+ "supports_response_schema": true,+ "supports_max_reasoning_effort": true,+ "supports_tool_choice": true,+ "supports_vision": true,+ "tool_use_system_prompt_tokens": 346,+ "supports_native_structured_output": true,+ "supports_minimal_reasoning_effort": true+ },"anthropic.claude-sonnet-4-20250514-v1:0": {"cache_creation_input_token_cost": 3.75e-06,"cache_read_input_token_cost": 3e-07,@@ -9602,6 +9631,7 @@"search_context_size_low": 0.01,"search_context_size_medium": 0.01},+ "supports_adaptive_thinking": true,"supports_assistant_prefill": true,"supports_computer_use": true,"supports_function_calling": true,@@ -9795,6 +9825,7 @@"search_context_size_low": 0.01,"search_context_size_medium": 0.01},+ "supports_adaptive_thinking": true,"supports_assistant_prefill": false,"supports_computer_use": true,"supports_function_calling": true,@@ -9828,6 +9859,7 @@"search_context_size_low": 0.01,"search_context_size_medium": 0.01},+ "supports_adaptive_thinking": true,"supports_assistant_prefill": false,"supports_computer_use": true,"supports_function_calling": true,@@ -9861,6 +9893,7 @@"search_context_size_low": 0.01,"search_context_size_medium": 0.01},+ "supports_adaptive_thinking": true,"supports_assistant_prefill": false,"supports_computer_use": true,"supports_function_calling": true,@@ -9895,6 +9928,7 @@"search_context_size_low": 0.01,"search_context_size_medium": 0.01},+ "supports_adaptive_thinking": true,"supports_assistant_prefill": false,"supports_computer_use": true,"supports_function_calling": true,@@ -14883,7 +14917,65 @@"mode": "chat","output_cost_per_reasoning_token": 1.5e-06,"output_cost_per_token": 1.5e-06,- "source": "https://ai.google.dev/gemini-api/docs/models",+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#gemini-models",+ "supported_endpoints": [+ "/v1/chat/completions",+ "/v1/completions",+ "/v1/batch"+ ],+ "supported_modalities": [+ "text",+ "image",+ "audio",+ "video"+ ],+ "supported_output_modalities": [+ "text"+ ],+ "supports_audio_input": true,+ "supports_audio_output": false,+ "supports_code_execution": true,+ "supports_file_search": true,+ "supports_function_calling": true,+ "supports_parallel_function_calling": true,+ "supports_pdf_input": true,+ "supports_prompt_caching": true,+ "supports_reasoning": true,+ "supports_response_schema": true,+ "supports_system_messages": true,+ "supports_tool_choice": true,+ "supports_url_context": true,+ "supports_video_input": true,+ "supports_vision": true,+ "supports_web_search": true,+ "supports_native_streaming": true,+ "search_context_cost_per_query": {+ "search_context_size_low": 0.014,+ "search_context_size_medium": 0.014,+ "search_context_size_high": 0.014+ },+ "web_search_billing_unit": "per_query",+ "supports_service_tier": true+ },+ "gemini-3.1-flash-lite": {+ "cache_read_input_token_cost": 4.5e-08,+ "cache_read_input_token_cost_per_audio_token": 9e-08,+ "input_cost_per_audio_token": 9e-07,+ "input_cost_per_token": 4.5e-07,+ "litellm_provider": "vertex_ai-language-models",+ "max_audio_length_hours": 8.4,+ "max_audio_per_prompt": 1,+ "max_images_per_prompt": 3000,+ "max_input_tokens": 1048576,+ "max_output_tokens": 65536,+ "max_pdf_size_mb": 30,+ "max_tokens": 65536,+ "max_video_length": 1,+ "max_videos_per_prompt": 10,+ "mode": "chat",+ "output_cost_per_reasoning_token": 2.7e-06,+ "output_cost_per_token": 2.7e-06,+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#gemini-models","supported_endpoints": ["/v1/chat/completions","/v1/completions",@@ -16987,6 +17079,66 @@"web_search_billing_unit": "per_query","supports_service_tier": true},+ "gemini/gemini-3.1-flash-lite": {+ "cache_read_input_token_cost": 4.5e-08,+ "cache_read_input_token_cost_per_audio_token": 9e-08,+ "input_cost_per_audio_token": 9e-07,+ "input_cost_per_token": 4.5e-07,+ "litellm_provider": "gemini",+ "max_audio_length_hours": 8.4,+ "max_audio_per_prompt": 1,+ "max_images_per_prompt": 3000,+ "max_input_tokens": 1048576,+ "max_output_tokens": 65536,+ "max_pdf_size_mb": 30,+ "max_tokens": 65536,+ "max_video_length": 1,+ "max_videos_per_prompt": 10,+ "mode": "chat",+ "output_cost_per_reasoning_token": 2.7e-06,+ "output_cost_per_token": 2.7e-06,+ "rpm": 15,+ "source": "https://ai.google.dev/gemini-api/docs/pricing",+ "supported_endpoints": [+ "/v1/chat/completions",+ "/v1/completions",+ "/v1/batch"+ ],+ "supported_modalities": [+ "text",+ "image",+ "audio",+ "video"+ ],+ "supported_output_modalities": [+ "text"+ ],+ "supports_audio_input": true,+ "supports_audio_output": false,+ "supports_code_execution": true,+ "supports_file_search": true,+ "supports_function_calling": true,+ "supports_parallel_function_calling": true,+ "supports_pdf_input": true,+ "supports_prompt_caching": true,+ "supports_reasoning": true,+ "supports_response_schema": true,+ "supports_system_messages": true,+ "supports_tool_choice": true,+ "supports_url_context": true,+ "supports_video_input": true,+ "supports_vision": true,+ "supports_web_search": true,+ "supports_native_streaming": true,+ "tpm": 250000,+ "search_context_cost_per_query": {+ "search_context_size_low": 0.014,+ "search_context_size_medium": 0.014,+ "search_context_size_high": 0.014+ },+ "web_search_billing_unit": "per_query",+ "supports_service_tier": true+ },"gemini/gemini-3-flash-preview": {"cache_read_input_token_cost": 5e-08,"input_cost_per_audio_token": 1e-06,@@ -24285,6 +24437,21 @@"supports_tool_choice": true,"supports_vision": true},+ "mistral/ministral-8b-2512": {+ "input_cost_per_token": 1.5e-07,+ "litellm_provider": "mistral",+ "max_input_tokens": 262144,+ "max_output_tokens": 262144,+ "max_tokens": 262144,+ "mode": "chat",+ "output_cost_per_token": 1.5e-07,+ "source": "https://mistral.ai/pricing",+ "supports_assistant_prefill": true,+ "supports_function_calling": true,+ "supports_response_schema": true,+ "supports_tool_choice": true,+ "supports_vision": true+ },"mistral/mistral-tiny": {"input_cost_per_token": 2.5e-07,"litellm_provider": "mistral",@@ -33605,6 +33772,64 @@},"web_search_billing_unit": "per_query"},+ "vertex_ai/gemini-3.1-flash-lite": {+ "cache_read_input_token_cost": 4.5e-08,+ "cache_read_input_token_cost_per_audio_token": 9e-08,+ "input_cost_per_audio_token": 9e-07,+ "input_cost_per_token": 4.5e-07,+ "litellm_provider": "vertex_ai-language-models",+ "max_audio_length_hours": 8.4,+ "max_audio_per_prompt": 1,+ "max_images_per_prompt": 3000,+ "max_input_tokens": 1048576,+ "max_output_tokens": 65536,+ "max_pdf_size_mb": 30,+ "max_tokens": 65536,+ "max_video_length": 1,+ "max_videos_per_prompt": 10,+ "mode": "chat",+ "output_cost_per_reasoning_token": 2.7e-06,+ "output_cost_per_token": 2.7e-06,+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#gemini-models",+ "supported_endpoints": [+ "/v1/chat/completions",+ "/v1/completions",+ "/v1/batch"+ ],+ "supported_modalities": [+ "text",+ "image",+ "audio",+ "video"+ ],+ "supported_output_modalities": [+ "text"+ ],+ "supports_audio_input": true,+ "supports_audio_output": false,+ "supports_code_execution": true,+ "supports_file_search": true,+ "supports_function_calling": true,+ "supports_parallel_function_calling": true,+ "supports_pdf_input": true,+ "supports_prompt_caching": true,+ "supports_reasoning": true,+ "supports_response_schema": true,+ "supports_system_messages": true,+ "supports_tool_choice": true,+ "supports_url_context": true,+ "supports_video_input": true,+ "supports_vision": true,+ "supports_web_search": true,+ "supports_native_streaming": true,+ "search_context_cost_per_query": {+ "search_context_size_low": 0.014,+ "search_context_size_medium": 0.014,+ "search_context_size_high": 0.014+ },+ "web_search_billing_unit": "per_query",+ "supports_service_tier": true+ },"vertex_ai/deep-research-pro-preview-12-2025": {"input_cost_per_image": 0.0011,"input_cost_per_token": 2e-06,diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.jsonindex e7a03bb0984..27d6a59740f 100644--- a/model_prices_and_context_window.json+++ b/model_prices_and_context_window.json@@ -14957,6 +14957,64 @@"web_search_billing_unit": "per_query","supports_service_tier": true},+ "gemini-3.1-flash-lite": {+ "cache_read_input_token_cost": 4.5e-08,+ "cache_read_input_token_cost_per_audio_token": 9e-08,+ "input_cost_per_audio_token": 9e-07,+ "input_cost_per_token": 4.5e-07,+ "litellm_provider": "vertex_ai-language-models",+ "max_audio_length_hours": 8.4,+ "max_audio_per_prompt": 1,+ "max_images_per_prompt": 3000,+ "max_input_tokens": 1048576,+ "max_output_tokens": 65536,+ "max_pdf_size_mb": 30,+ "max_tokens": 65536,+ "max_video_length": 1,+ "max_videos_per_prompt": 10,+ "mode": "chat",+ "output_cost_per_reasoning_token": 2.7e-06,+ "output_cost_per_token": 2.7e-06,+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#gemini-models",+ "supported_endpoints": [+ "/v1/chat/completions",+ "/v1/completions",+ "/v1/batch"+ ],+ "supported_modalities": [+ "text",+ "image",+ "audio",+ "video"+ ],+ "supported_output_modalities": [+ "text"+ ],+ "supports_audio_input": true,+ "supports_audio_output": false,+ "supports_code_execution": true,+ "supports_file_search": true,+ "supports_function_calling": true,+ "supports_parallel_function_calling": true,+ "supports_pdf_input": true,+ "supports_prompt_caching": true,+ "supports_reasoning": true,+ "supports_response_schema": true,+ "supports_system_messages": true,+ "supports_tool_choice": true,+ "supports_url_context": true,+ "supports_video_input": true,+ "supports_vision": true,+ "supports_web_search": true,+ "supports_native_streaming": true,+ "search_context_cost_per_query": {+ "search_context_size_low": 0.014,+ "search_context_size_medium": 0.014,+ "search_context_size_high": 0.014+ },+ "web_search_billing_unit": "per_query",+ "supports_service_tier": true+ },"deep-research-pro-preview-12-2025": {"input_cost_per_image": 0.0011,"input_cost_per_token": 2e-06,@@ -17021,6 +17079,66 @@"web_search_billing_unit": "per_query","supports_service_tier": true},+ "gemini/gemini-3.1-flash-lite": {+ "cache_read_input_token_cost": 4.5e-08,+ "cache_read_input_token_cost_per_audio_token": 9e-08,+ "input_cost_per_audio_token": 9e-07,+ "input_cost_per_token": 4.5e-07,+ "litellm_provider": "gemini",+ "max_audio_length_hours": 8.4,+ "max_audio_per_prompt": 1,+ "max_images_per_prompt": 3000,+ "max_input_tokens": 1048576,+ "max_output_tokens": 65536,+ "max_pdf_size_mb": 30,+ "max_tokens": 65536,+ "max_video_length": 1,+ "max_videos_per_prompt": 10,+ "mode": "chat",+ "output_cost_per_reasoning_token": 2.7e-06,+ "output_cost_per_token": 2.7e-06,+ "rpm": 15,+ "source": "https://ai.google.dev/gemini-api/docs/pricing",+ "supported_endpoints": [+ "/v1/chat/completions",+ "/v1/completions",+ "/v1/batch"+ ],+ "supported_modalities": [+ "text",+ "image",+ "audio",+ "video"+ ],+ "supported_output_modalities": [+ "text"+ ],+ "supports_audio_input": true,+ "supports_audio_output": false,+ "supports_code_execution": true,+ "supports_file_search": true,+ "supports_function_calling": true,+ "supports_parallel_function_calling": true,+ "supports_pdf_input": true,+ "supports_prompt_caching": true,+ "supports_reasoning": true,+ "supports_response_schema": true,+ "supports_system_messages": true,+ "supports_tool_choice": true,+ "supports_url_context": true,+ "supports_video_input": true,+ "supports_vision": true,+ "supports_web_search": true,+ "supports_native_streaming": true,+ "tpm": 250000,+ "search_context_cost_per_query": {+ "search_context_size_low": 0.014,+ "search_context_size_medium": 0.014,+ "search_context_size_high": 0.014+ },+ "web_search_billing_unit": "per_query",+ "supports_service_tier": true+ },"gemini/gemini-3-flash-preview": {"cache_read_input_token_cost": 5e-08,"input_cost_per_audio_token": 1e-06,@@ -24319,6 +24437,21 @@"supports_tool_choice": true,"supports_vision": true},+ "mistral/ministral-8b-2512": {+ "input_cost_per_token": 1.5e-07,+ "litellm_provider": "mistral",+ "max_input_tokens": 262144,+ "max_output_tokens": 262144,+ "max_tokens": 262144,+ "mode": "chat",+ "output_cost_per_token": 1.5e-07,+ "source": "https://mistral.ai/pricing",+ "supports_assistant_prefill": true,+ "supports_function_calling": true,+ "supports_response_schema": true,+ "supports_tool_choice": true,+ "supports_vision": true+ },"mistral/mistral-tiny": {"input_cost_per_token": 2.5e-07,"litellm_provider": "mistral",@@ -33639,6 +33772,64 @@},"web_search_billing_unit": "per_query"},+ "vertex_ai/gemini-3.1-flash-lite": {+ "cache_read_input_token_cost": 4.5e-08,+ "cache_read_input_token_cost_per_audio_token": 9e-08,+ "input_cost_per_audio_token": 9e-07,+ "input_cost_per_token": 4.5e-07,+ "litellm_provider": "vertex_ai-language-models",+ "max_audio_length_hours": 8.4,+ "max_audio_per_prompt": 1,+ "max_images_per_prompt": 3000,+ "max_input_tokens": 1048576,+ "max_output_tokens": 65536,+ "max_pdf_size_mb": 30,+ "max_tokens": 65536,+ "max_video_length": 1,+ "max_videos_per_prompt": 10,+ "mode": "chat",+ "output_cost_per_reasoning_token": 2.7e-06,+ "output_cost_per_token": 2.7e-06,+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#gemini-models",+ "supported_endpoints": [+ "/v1/chat/completions",+ "/v1/completions",+ "/v1/batch"+ ],+ "supported_modalities": [+ "text",+ "image",+ "audio",+ "video"+ ],+ "supported_output_modalities": [+ "text"+ ],+ "supports_audio_input": true,+ "supports_audio_output": false,+ "supports_code_execution": true,+ "supports_file_search": true,+ "supports_function_calling": true,+ "supports_parallel_function_calling": true,+ "supports_pdf_input": true,+ "supports_prompt_caching": true,+ "supports_reasoning": true,+ "supports_response_schema": true,+ "supports_system_messages": true,+ "supports_tool_choice": true,+ "supports_url_context": true,+ "supports_video_input": true,+ "supports_vision": true,+ "supports_web_search": true,+ "supports_native_streaming": true,+ "search_context_cost_per_query": {+ "search_context_size_low": 0.014,+ "search_context_size_medium": 0.014,+ "search_context_size_high": 0.014+ },+ "web_search_billing_unit": "per_query",+ "supports_service_tier": true+ },"vertex_ai/deep-research-pro-preview-12-2025": {"input_cost_per_image": 0.0011,"input_cost_per_token": 2e-06,diff --git a/tests/local_testing/conftest.py b/tests/local_testing/conftest.pyindex 6a746041f15..06637b844b1 100644--- a/tests/local_testing/conftest.py+++ b/tests/local_testing/conftest.py@@ -22,6 +22,20 @@ sys.path.insert() # Adds the parent directory to the system pathimport litellm+# ``litellm.model_cost`` is loaded at import time from the URL pinned to+# ``main`` (``LITELLM_MODEL_COST_MAP_URL``). The in-tree backup ships with+# this branch and can include pricing entries that main has not yet picked+# up (e.g. an upstream provider rotates a model id and the test cassette+# records the new name). Backfill any entries that are missing from the+# remote-fetched map so cost-calculator lookups in tests succeed against+# the cassette state the branch is being tested with.+from litellm.litellm_core_utils.get_model_cost_map import GetModelCostMap++_local_cost_map = GetModelCostMap.load_local_model_cost_map()+for _k, _v in _local_cost_map.items():+ litellm.model_cost.setdefault(_k, _v)+del _local_cost_map+from tests._vcr_conftest_common import ( # noqa: E402,F401VerboseReporterState,_pin_multipart_boundary,diff --git a/tests/test_litellm/test_cost_calculator.py b/tests/test_litellm/test_cost_calculator.pyindex 1be4abbec6e..18ab8a2a07a 100644--- a/tests/test_litellm/test_cost_calculator.py+++ b/tests/test_litellm/test_cost_calculator.py@@ -2059,6 +2059,25 @@ def test_openrouter_gemini_3_1_flash_lite_preview_pricing():assert model_info["max_output_tokens"] == 65536+def test_gemini_3_1_flash_lite_pricing():+ os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"+ litellm.model_cost = litellm.get_model_cost_map(url="")++ for model_name in (+ "gemini-3.1-flash-lite",+ "gemini/gemini-3.1-flash-lite",+ "vertex_ai/gemini-3.1-flash-lite",+ ):+ model_info = litellm.model_cost.get(model_name)+ assert model_info is not None, f"Missing model pricing entry: {model_name}"+ assert model_info["input_cost_per_token"] == 4.5e-07+ assert model_info["input_cost_per_audio_token"] == 9e-07+ assert model_info["output_cost_per_token"] == 2.7e-06+ assert model_info["output_cost_per_reasoning_token"] == 2.7e-06+ assert model_info["cache_read_input_token_cost"] == 4.5e-08+ assert model_info["max_input_tokens"] == 1048576++def test_custom_pricing_applies_cache_read_input_cost():"""Bug 1 reproduction: custom_cost_per_token with cache_read_input_token_cost