Skip to content

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]

fix linting

Ishaan Jaff755a0514f636
diff --git a/litellm/llms/text_to_speech/vertex_ai.py b/litellm/llms/text_to_speech/vertex_ai.py
index 01ab6edc05b..139f3bbc2b9 100644
--- a/litellm/llms/text_to_speech/vertex_ai.py
+++ b/litellm/llms/text_to_speech/vertex_ai.py
@@ -54,7 +54,7 @@ class VertexTextToSpeechAPI(VertexLLM):
timeout: Union[float, httpx.Timeout],
model: str,
input: str,
- voice: str,
+ voice: Optional[str] = None,
_is_async: Optional[bool] = False,
optional_params: Optional[dict] = None,
**kwargs,
diff --git a/litellm/main.py b/litellm/main.py
index 4323c24a6b1..f9ad007d6ca 100644
--- a/litellm/main.py
+++ b/litellm/main.py
@@ -4699,7 +4699,7 @@ async def aspeech(*args, **kwargs) -> HttpxBinaryResponseContent:
def speech(
model: str,
input: str,
- voice: str,
+ voice: Optional[str] = None,
api_key: Optional[str] = None,
api_base: Optional[str] = None,
api_version: Optional[str] = None,
@@ -4735,6 +4735,12 @@ def speech(
logging_obj = kwargs.get("litellm_logging_obj", None)
response: Optional[HttpxBinaryResponseContent] = None
if custom_llm_provider == "openai":
+ if voice is None:
+ raise litellm.BadRequestError(
+ message="'voice' is required for OpenAI TTS",
+ model=model,
+ llm_provider=custom_llm_provider,
+ )
api_base = (
api_base # for deepinfra/perplexity/anyscale/groq/friendliai we check in get_llm_provider and pass in the api base from there
or litellm.api_base
@@ -4781,6 +4787,12 @@ def speech(
)
elif custom_llm_provider == "azure":
# azure configs
+ if voice is None:
+ raise litellm.BadRequestError(
+ message="'voice' is required for Azure TTS",
+ model=model,
+ llm_provider=custom_llm_provider,
+ )
api_base = api_base or litellm.api_base or get_secret("AZURE_API_BASE") # type: ignore
api_version = (