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): day-0 pricing for gemini-3.8-flash
mateo-berri6b83b16559e5
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex a3cfb300ea6..cc828e126ad 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -23514,6 +23514,63 @@"web_search_billing_unit": "per_query","google_maps_grounding_cost_per_query": 0.014},+ "vertex_ai/gemini-3.8-flash": {+ "prompt_cache_min_tokens": 4096,+ "cache_read_input_token_cost": 7.5e-08,+ "cache_read_input_token_cost_flex": 3.75e-08,+ "input_cost_per_token": 7.5e-07,+ "input_cost_per_token_batches": 3.75e-07,+ "input_cost_per_token_flex": 3.75e-07,+ "litellm_provider": "vertex_ai",+ "max_input_tokens": 1048576,+ "max_output_tokens": 65536,+ "max_tokens": 65536,+ "mode": "chat",+ "output_cost_per_reasoning_token": 3.75e-06,+ "output_cost_per_token": 3.75e-06,+ "output_cost_per_token_batches": 1.875e-06,+ "output_cost_per_token_flex": 1.875e-06,+ "regional_endpoint_uplift_multiplier": 1.1,+ "source": "https://cloud.google.com/vertex-ai/generative-ai/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_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,+ "input_cost_per_token_priority": 1.35e-06,+ "output_cost_per_token_priority": 6.75e-06,+ "cache_read_input_token_cost_priority": 1.35e-07,+ "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",+ "google_maps_grounding_cost_per_query": 0.014+ },"vertex_ai/gemini-3.1-pro-preview": {"prompt_cache_min_tokens": 4096,"cache_read_input_token_cost": 2e-07,@@ -25351,6 +25408,65 @@"web_search_billing_unit": "per_query","google_maps_grounding_cost_per_query": 0.014},+ "gemini/gemini-3.8-flash": {+ "prompt_cache_min_tokens": 4096,+ "cache_read_input_token_cost": 7.5e-08,+ "cache_read_input_token_cost_flex": 3.75e-08,+ "input_cost_per_token": 7.5e-07,+ "input_cost_per_token_batches": 3.75e-07,+ "input_cost_per_token_flex": 3.75e-07,+ "litellm_provider": "gemini",+ "max_input_tokens": 1048576,+ "max_output_tokens": 65536,+ "max_tokens": 65536,+ "mode": "chat",+ "output_cost_per_reasoning_token": 3.75e-06,+ "output_cost_per_token": 3.75e-06,+ "output_cost_per_token_batches": 1.875e-06,+ "output_cost_per_token_flex": 1.875e-06,+ "rpm": 2000,+ "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_output": false,+ "supports_audio_input": 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": 800000,+ "input_cost_per_token_priority": 1.35e-06,+ "output_cost_per_token_priority": 6.75e-06,+ "cache_read_input_token_cost_priority": 1.35e-07,+ "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",+ "google_maps_grounding_cost_per_query": 0.014+ },"gemini/gemini-omni-flash-preview": {"input_cost_per_audio_token": 1.5e-06,"input_cost_per_token": 1.5e-06,@@ -25759,6 +25875,63 @@"web_search_billing_unit": "per_query","google_maps_grounding_cost_per_query": 0.014},+ "gemini-3.8-flash": {+ "prompt_cache_min_tokens": 4096,+ "cache_read_input_token_cost": 7.5e-08,+ "cache_read_input_token_cost_flex": 3.75e-08,+ "input_cost_per_token": 7.5e-07,+ "input_cost_per_token_batches": 3.75e-07,+ "input_cost_per_token_flex": 3.75e-07,+ "litellm_provider": "vertex_ai-language-models",+ "max_input_tokens": 1048576,+ "max_output_tokens": 65536,+ "max_tokens": 65536,+ "mode": "chat",+ "output_cost_per_reasoning_token": 3.75e-06,+ "output_cost_per_token": 3.75e-06,+ "output_cost_per_token_batches": 1.875e-06,+ "output_cost_per_token_flex": 1.875e-06,+ "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_output": false,+ "supports_audio_input": 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,+ "input_cost_per_token_priority": 1.35e-06,+ "output_cost_per_token_priority": 6.75e-06,+ "cache_read_input_token_cost_priority": 1.35e-07,+ "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",+ "google_maps_grounding_cost_per_query": 0.014+ },"gemini/gemini-2.5-pro-preview-tts": {"cache_read_input_token_cost": 1.25e-07,"input_cost_per_audio_token": 7e-07,diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.jsonindex a3cfb300ea6..cc828e126ad 100644--- a/model_prices_and_context_window.json+++ b/model_prices_and_context_window.json@@ -23514,6 +23514,63 @@"web_search_billing_unit": "per_query","google_maps_grounding_cost_per_query": 0.014},+ "vertex_ai/gemini-3.8-flash": {+ "prompt_cache_min_tokens": 4096,+ "cache_read_input_token_cost": 7.5e-08,+ "cache_read_input_token_cost_flex": 3.75e-08,+ "input_cost_per_token": 7.5e-07,+ "input_cost_per_token_batches": 3.75e-07,+ "input_cost_per_token_flex": 3.75e-07,+ "litellm_provider": "vertex_ai",+ "max_input_tokens": 1048576,+ "max_output_tokens": 65536,+ "max_tokens": 65536,+ "mode": "chat",+ "output_cost_per_reasoning_token": 3.75e-06,+ "output_cost_per_token": 3.75e-06,+ "output_cost_per_token_batches": 1.875e-06,+ "output_cost_per_token_flex": 1.875e-06,+ "regional_endpoint_uplift_multiplier": 1.1,+ "source": "https://cloud.google.com/vertex-ai/generative-ai/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_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,+ "input_cost_per_token_priority": 1.35e-06,+ "output_cost_per_token_priority": 6.75e-06,+ "cache_read_input_token_cost_priority": 1.35e-07,+ "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",+ "google_maps_grounding_cost_per_query": 0.014+ },"vertex_ai/gemini-3.1-pro-preview": {"prompt_cache_min_tokens": 4096,"cache_read_input_token_cost": 2e-07,@@ -25351,6 +25408,65 @@"web_search_billing_unit": "per_query","google_maps_grounding_cost_per_query": 0.014},+ "gemini/gemini-3.8-flash": {+ "prompt_cache_min_tokens": 4096,+ "cache_read_input_token_cost": 7.5e-08,+ "cache_read_input_token_cost_flex": 3.75e-08,+ "input_cost_per_token": 7.5e-07,+ "input_cost_per_token_batches": 3.75e-07,+ "input_cost_per_token_flex": 3.75e-07,+ "litellm_provider": "gemini",+ "max_input_tokens": 1048576,+ "max_output_tokens": 65536,+ "max_tokens": 65536,+ "mode": "chat",+ "output_cost_per_reasoning_token": 3.75e-06,+ "output_cost_per_token": 3.75e-06,+ "output_cost_per_token_batches": 1.875e-06,+ "output_cost_per_token_flex": 1.875e-06,+ "rpm": 2000,+ "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_output": false,+ "supports_audio_input": 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": 800000,+ "input_cost_per_token_priority": 1.35e-06,+ "output_cost_per_token_priority": 6.75e-06,+ "cache_read_input_token_cost_priority": 1.35e-07,+ "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",+ "google_maps_grounding_cost_per_query": 0.014+ },"gemini/gemini-omni-flash-preview": {"input_cost_per_audio_token": 1.5e-06,"input_cost_per_token": 1.5e-06,@@ -25759,6 +25875,63 @@"web_search_billing_unit": "per_query","google_maps_grounding_cost_per_query": 0.014},+ "gemini-3.8-flash": {+ "prompt_cache_min_tokens": 4096,+ "cache_read_input_token_cost": 7.5e-08,+ "cache_read_input_token_cost_flex": 3.75e-08,+ "input_cost_per_token": 7.5e-07,+ "input_cost_per_token_batches": 3.75e-07,+ "input_cost_per_token_flex": 3.75e-07,+ "litellm_provider": "vertex_ai-language-models",+ "max_input_tokens": 1048576,+ "max_output_tokens": 65536,+ "max_tokens": 65536,+ "mode": "chat",+ "output_cost_per_reasoning_token": 3.75e-06,+ "output_cost_per_token": 3.75e-06,+ "output_cost_per_token_batches": 1.875e-06,+ "output_cost_per_token_flex": 1.875e-06,+ "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_output": false,+ "supports_audio_input": 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,+ "input_cost_per_token_priority": 1.35e-06,+ "output_cost_per_token_priority": 6.75e-06,+ "cache_read_input_token_cost_priority": 1.35e-07,+ "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",+ "google_maps_grounding_cost_per_query": 0.014+ },"gemini/gemini-2.5-pro-preview-tts": {"cache_read_input_token_cost": 1.25e-07,"input_cost_per_audio_token": 7e-07,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 0e1c832ebf5..0ccb05c67a3 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@@ -4200,6 +4200,51 @@ def test_generic_cost_per_token_gemini_37_flash(_local_model_cost_map):assert completion_cost == pytest.approx(0.001875)+GEMINI_38_FLASH_LAUNCH_PRICING = [+ ("gemini-3.8-flash", 7.5e-07, 3.75e-06, 7.5e-08),+ ("gemini/gemini-3.8-flash", 7.5e-07, 3.75e-06, 7.5e-08),+ ("vertex_ai/gemini-3.8-flash", 7.5e-07, 3.75e-06, 7.5e-08),+]++[email protected]("model,input_cost,output_cost,cache_read_cost", GEMINI_38_FLASH_LAUNCH_PRICING)+def test_gemini_38_flash_launch_pricing(model, input_cost, output_cost, cache_read_cost, _local_model_cost_map):+ model_cost_map = litellm.model_cost[model]+ assert model_cost_map["input_cost_per_token"] == input_cost+ assert model_cost_map["output_cost_per_token"] == output_cost+ assert model_cost_map["output_cost_per_reasoning_token"] == output_cost+ assert model_cost_map["cache_read_input_token_cost"] == cache_read_cost+ assert model_cost_map["mode"] == "chat"+ assert model_cost_map["supports_reasoning"] is True+ assert model_cost_map["supports_function_calling"] is True+ assert model_cost_map["max_input_tokens"] == 1048576+++def test_gemini_38_flash_matches_37_flash_promotional_pricing(_local_model_cost_map):+ for prefix in ("", "gemini/", "vertex_ai/"):+ assert litellm.model_cost[f"{prefix}gemini-3.8-flash"] == litellm.model_cost[f"{prefix}gemini-3.7-flash"]+++def test_generic_cost_per_token_gemini_38_flash(_local_model_cost_map):+ usage = Usage(+ prompt_tokens=1000,+ completion_tokens=500,+ total_tokens=1500,+ completion_tokens_details=CompletionTokensDetailsWrapper(+ reasoning_tokens=200,+ text_tokens=300,+ ),+ prompt_tokens_details=PromptTokensDetailsWrapper(text_tokens=1000),+ )+ prompt_cost, completion_cost = generic_cost_per_token(+ model="gemini-3.8-flash",+ usage=usage,+ custom_llm_provider="gemini",+ )+ assert prompt_cost == pytest.approx(0.00075)+ assert completion_cost == pytest.approx(0.001875)++def test_grok_46_launch_pricing(_local_model_cost_map):model_cost_map = litellm.model_cost["xai/grok-4.6"]assert model_cost_map["input_cost_per_token"] == 2e-06diff --git a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_ai_gemini_transformation.py b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_ai_gemini_transformation.pyindex 8c1de12e7d9..4679b978f78 100644--- a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_ai_gemini_transformation.py+++ b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_ai_gemini_transformation.py@@ -1096,10 +1096,13 @@ def test_natively_signed_parallel_turn_never_carries_a_placeholder(model):"gemini-3.5-flash","gemini-3.6-flash","gemini-3.7-flash",+ "gemini-3.8-flash","vertex_ai/gemini-3.5-flash","vertex_ai/gemini-3.7-flash",+ "vertex_ai/gemini-3.8-flash","gemini/gemini-3.5-flash","gemini/gemini-3.7-flash",+ "gemini/gemini-3.8-flash",],)def test_placeholder_scoped_to_first_call_across_gemini_3_variants(model):diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.pyindex 521e91daded..0790b41c349 100644--- a/tests/test_litellm/test_utils.py+++ b/tests/test_litellm/test_utils.py@@ -4655,6 +4655,7 @@ GEMINI_4096_CACHE_MIN_MODELS: Final = tuple("gemini-3.5-flash","gemini-3.6-flash","gemini-3.7-flash",+ "gemini-3.8-flash","gemini-3.1-pro-preview","gemini-3.1-pro-preview-customtools",)