BerriAI/litellm · error · ValueError

Only one of 'text' or 'ssml' should be provided, not both.

Error message

Only one of 'text' or 'ssml' should be provided, not both.

What it means

Duplicate of the TTS mutual-exclusion guard in transformation.py: both 'text' and 'ssml' were provided for a non-SSML-flagged call. The handler auto-detects '<speak>' markup but will not guess between two explicit inputs, so it refuses the request.

Source

Thrown at litellm/llms/vertex_ai/text_to_speech/transformation.py:334

        use_ssml: Final = 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.")

        return input_data

    def transform_text_to_speech_request(
        self,
        model: str,
        input: str,
        voice: str | None,
        optional_params: dict,
        litellm_params: dict,
        headers: dict,
    ) -> TextToSpeechRequestData:
        """
        Transform OpenAI TTS request to Vertex AI TTS format

        This method handles:
        1. Authentication with Vertex AI
        2. Building the request body

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Send only one of 'text' or 'ssml' in the input payload; drop the other field.
  2. Choose 'ssml' (with use_ssml=True) for markup content, otherwise 'text'.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/vertex_ai/text_to_speech/transformation.py:334 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/316c0f94eb217507. Report an issue: GitHub.