BerriAI/litellm · error · ValueError

Either 'text' or 'ssml' must be provided.

Error message

Either 'text' or 'ssml' must be provided.

What it means

Raised by validate_vertex_input when the input dict passed to the Vertex TTS handler is empty after None-stripping: neither 'text' nor 'ssml' survived, so there is no content to synthesize. It is the non-SSML path counterpart to the SSML error — use_ssml is False (or unset), LiteLLM would auto-detect SSML-formatted text, but there is simply no payload to send to the API.

Source

Thrown at litellm/llms/vertex_ai/text_to_speech/text_to_speech_handler.py:232

    # Check if use_ssml is set
    use_ssml: Final = 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: Final = 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.")

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Provide exactly one of 'text' or 'ssml' in the speech synthesis request.
  2. For plain text pass input={'text': ...}; for markup pass input={'ssml': ...} with use_ssml=True.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/vertex_ai/text_to_speech/text_to_speech_handler.py:232 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/6f28f2e59ad8d4e6. Report an issue: GitHub.