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
update validate_vertex_input
Ishaan Jaff58506dbade63
diff --git a/litellm/llms/text_to_speech/vertex_ai.py b/litellm/llms/text_to_speech/vertex_ai.pyindex 0b6b9deb8b1..39c5ddfd432 100644--- a/litellm/llms/text_to_speech/vertex_ai.py+++ b/litellm/llms/text_to_speech/vertex_ai.py@@ -88,10 +88,12 @@ class VertexTextToSpeechAPI(VertexLLM):####### Build the request ################# API Ref: https://cloud.google.com/text-to-speech/docs/reference/rest/v1/text/synthesizekwargs = kwargs or {}- vertex_input = VertexInput(text=input, ssml=kwargs.get("ssml", None))- validate_vertex_input(vertex_input)- # required paramoptional_params = optional_params or {}++ vertex_input = VertexInput(text=input)+ validate_vertex_input(vertex_input, kwargs, optional_params)++ # required paramif voice is not None:vertex_voice = VertexVoice(**voice)elif "voice" in kwargs:@@ -207,10 +209,32 @@ class VertexTextToSpeechAPI(VertexLLM):return http_binary_response-def validate_vertex_input(input_data: VertexInput) -> None:- if input_data.get("text", None) is None:- input_data.pop("text")- if "text" not in input_data and "ssml" not in input_data:+def validate_vertex_input(+ input_data: VertexInput, kwargs: dict, optional_params: dict+) -> None:+ # Remove None values+ if input_data.get("text") is None:+ input_data.pop("text", None)+ if input_data.get("ssml") is None:+ input_data.pop("ssml", None)++ # Check if use_ssml is set+ use_ssml = kwargs.get("use_ssml", optional_params.get("use_ssml", False))++ if use_ssml:+ if "text" in input_data:+ input_data["ssml"] = input_data.pop("text")+ elif "ssml" not in input_data:+ raise ValueError("SSML input is required when use_ssml is True.")+ else:+ # LiteLLM will auto-detect if text is in ssml format+ # check if "text" is an ssml - in this case we should pass it as ssml instead of text+ if input_data:+ _text = input_data.get("text", None) or ""+ if "<speak>" in _text:+ input_data["ssml"] = input_data.pop("text")++ if not input_data:raise ValueError("Either 'text' or 'ssml' must be provided.")if "text" in input_data and "ssml" in input_data:raise ValueError("Only one of 'text' or 'ssml' should be provided, not both.")