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
fix linting error
Ishaan Jaffera07ed76f54fb
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex 660fac49140..3e1c4df8e3c 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -22283,6 +22283,50 @@"supports_vision": true,"tool_use_system_prompt_tokens": 159},+ "vertex_ai/mistralai/codestral-2@001": {+ "input_cost_per_token": 3e-07,+ "litellm_provider": "vertex_ai-mistral_models",+ "max_input_tokens": 128000,+ "max_output_tokens": 128000,+ "max_tokens": 128000,+ "mode": "chat",+ "output_cost_per_token": 9e-07,+ "supports_function_calling": true,+ "supports_tool_choice": true+ },+ "vertex_ai/codestral-2": {+ "input_cost_per_token": 3e-07,+ "litellm_provider": "vertex_ai-mistral_models",+ "max_input_tokens": 128000,+ "max_output_tokens": 128000,+ "max_tokens": 128000,+ "mode": "chat",+ "output_cost_per_token": 9e-07,+ "supports_function_calling": true,+ "supports_tool_choice": true+ },+ "vertex_ai/codestral-2@001": {+ "input_cost_per_token": 3e-07,+ "litellm_provider": "vertex_ai-mistral_models",+ "max_input_tokens": 128000,+ "max_output_tokens": 128000,+ "max_tokens": 128000,+ "mode": "chat",+ "output_cost_per_token": 9e-07,+ "supports_function_calling": true,+ "supports_tool_choice": true+ },+ "vertex_ai/mistralai/codestral-2": {+ "input_cost_per_token": 3e-07,+ "litellm_provider": "vertex_ai-mistral_models",+ "max_input_tokens": 128000,+ "max_output_tokens": 128000,+ "max_tokens": 128000,+ "mode": "chat",+ "output_cost_per_token": 9e-07,+ "supports_function_calling": true,+ "supports_tool_choice": true+ },"vertex_ai/codestral-2501": {"input_cost_per_token": 2e-07,"litellm_provider": "vertex_ai-mistral_models",@@ -22612,6 +22656,50 @@"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#partner-models","supports_tool_choice": true},+ "vertex_ai/mistral-medium-3": {+ "input_cost_per_token": 4e-07,+ "litellm_provider": "vertex_ai-mistral_models",+ "max_input_tokens": 128000,+ "max_output_tokens": 8191,+ "max_tokens": 8191,+ "mode": "chat",+ "output_cost_per_token": 2e-06,+ "supports_function_calling": true,+ "supports_tool_choice": true+ },+ "vertex_ai/mistral-medium-3@001": {+ "input_cost_per_token": 4e-07,+ "litellm_provider": "vertex_ai-mistral_models",+ "max_input_tokens": 128000,+ "max_output_tokens": 8191,+ "max_tokens": 8191,+ "mode": "chat",+ "output_cost_per_token": 2e-06,+ "supports_function_calling": true,+ "supports_tool_choice": true+ },+ "vertex_ai/mistralai/mistral-medium-3": {+ "input_cost_per_token": 4e-07,+ "litellm_provider": "vertex_ai-mistral_models",+ "max_input_tokens": 128000,+ "max_output_tokens": 8191,+ "max_tokens": 8191,+ "mode": "chat",+ "output_cost_per_token": 2e-06,+ "supports_function_calling": true,+ "supports_tool_choice": true+ },+ "vertex_ai/mistralai/mistral-medium-3@001": {+ "input_cost_per_token": 4e-07,+ "litellm_provider": "vertex_ai-mistral_models",+ "max_input_tokens": 128000,+ "max_output_tokens": 8191,+ "max_tokens": 8191,+ "mode": "chat",+ "output_cost_per_token": 2e-06,+ "supports_function_calling": true,+ "supports_tool_choice": true+ },"vertex_ai/mistral-large-2411": {"input_cost_per_token": 2e-06,"litellm_provider": "vertex_ai-mistral_models",@@ -23833,12 +23921,21 @@"supports_vision": true,"supports_web_search": true},- "sora-2": {- "input_cost_per_second": 0.0,+ "openai/sora-2": {"litellm_provider": "openai","mode": "video_generation",- "output_cost_per_second": 0.0,- "supports_video_generation": true+ "output_cost_per_video_per_second": 0.10,+ "source": "https://platform.openai.com/docs/api-reference/videos",+ "supported_modalities": [+ "text"+ ],+ "supported_output_modalities": [+ "video"+ ],+ "supported_resolutions": [+ "720x1280",+ "1280x720"+ ]},"azure/sora-2": {"litellm_provider": "azure",diff --git a/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py b/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.pyindex a6dc1d57886..33028903cb2 100644--- a/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py+++ b/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py@@ -23,7 +23,6 @@ import litellmfrom litellm._logging import verbose_proxy_loggerfrom litellm.caching import DualCachefrom litellm.integrations.custom_guardrail import CustomGuardrail-from litellm.types.llms.openai import ChatCompletionUserMessagefrom litellm.llms.bedrock.base_aws_llm import BaseAWSLLMfrom litellm.llms.custom_httpx.http_handler import (get_async_httpx_client,@@ -32,7 +31,7 @@ from litellm.llms.custom_httpx.http_handler import (from litellm.proxy._types import UserAPIKeyAuthfrom litellm.secret_managers.main import get_secret_strfrom litellm.types.guardrails import GuardrailEventHooks, PiiEntityType-from litellm.types.llms.openai import AllMessageValues+from litellm.types.llms.openai import AllMessageValues, ChatCompletionUserMessagefrom litellm.types.proxy.guardrails.guardrail_hooks.bedrock_guardrails import (BedrockContentItem,BedrockGuardrailOutput,@@ -1103,7 +1102,7 @@ class BedrockGuardrail(CustomGuardrail, BaseAWSLLM):verbose_proxy_logger.debug("Bedrock Guardrail: Applying guardrail")- mock_messages = [ChatCompletionUserMessage(role="user", content=text)]+ mock_messages: List[AllMessageValues] = [ChatCompletionUserMessage(role="user", content=text)]bedrock_response = await self.make_bedrock_api_request(source="INPUT",messages=mock_messages,@@ -1115,18 +1114,23 @@ class BedrockGuardrail(CustomGuardrail, BaseAWSLLM):# Apply any masking that was applied by the guardrailmasked_text = text- if bedrock_response.get("output") and bedrock_response["output"]:+ output_list = bedrock_response.get("output")+ if output_list:# If the guardrail returned modified content, use that- for output_item in bedrock_response["output"]:- if output_item.get("text"):- masked_text = str(output_item["text"])- break- elif bedrock_response.get("content") and bedrock_response["content"]:- # Fallback to content field if output is not available- for content_item in bedrock_response["content"]:- if content_item.get("text") and content_item["text"].get("text"):- masked_text = str(content_item["text"]["text"])+ for output_item in output_list:+ text_content = output_item.get("text")+ if text_content:+ masked_text = str(text_content)break+ else:+ outputs_list = bedrock_response.get("outputs")+ if outputs_list:+ # Fallback to outputs field if output is not available+ for output_item in outputs_list:+ text_content = output_item.get("text")+ if text_content:+ masked_text = str(text_content)+ breakverbose_proxy_logger.debug("Bedrock Guardrail: Successfully applied guardrail"