BerriAI/litellm · error · Exception

Request failed with status code {response.status_code}, {res

Error message

Request failed with status code {response.status_code}, {response.text}

What it means

Raised in the sync Vertex AI text-to-speech path when the POST returns non-200; status and body are embedded. Fires on invalid voice/audio config, auth, or quota errors from the speech endpoint.

Source

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

                "complete_input_dict": request,
                "api_base": url,
                "headers": headers,
            },
        )

        ########## End of logging ############
        ####### Send the request ###################
        if _is_async is True:
            return self.async_audio_speech(logging_obj=logging_obj, url=url, headers=headers, request=request)
        sync_handler: Final = _get_httpx_client()

        response = sync_handler.post(
            url=url,
            headers=headers,
            json=request,
        )
        if response.status_code != 200:
            raise Exception(f"Request failed with status code {response.status_code}, {response.text}")
        ############ Process the response ############
        _json_response: Final = response.json()

        response_content: Final = _json_response["audioContent"]

        # Decode base64 to get binary content
        binary_data: Final = base64.b64decode(response_content)

        # Create an httpx.Response object
        response = httpx.Response(
            status_code=200,
            content=binary_data,
        )

        # Initialize the HttpxBinaryResponseContent instance
        http_binary_response: Final = HttpxBinaryResponseContent(response)
        return http_binary_response

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check the status code and response body in the error for the upstream cause (auth, quota, invalid voice/params).
  2. Verify vertex credentials, project/location, and the TTS request parameters (voice, language_code, model) are valid.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/llms/vertex_ai/text_to_speech/text_to_speech_handler.py:151 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/709f8c218307cdb3. Report an issue: GitHub.