BerriAI/litellm · error · VertexAIError

Invalid vertex_project format: {project_id!r}

Error message

Invalid vertex_project format: {project_id!r}

What it means

Speech-to-Text _validate_project_id guard: the resolved project_id is not a valid GCP project identifier (e.g. contains illegal characters or wrong shape), so it is rejected before being placed in the v2 projects/.../recognizers URL.

Source

Thrown at litellm/llms/vertex_ai/audio_transcription/transformation.py:124

        location: Final = self._validate_location(self.safe_get_vertex_ai_location(litellm_params))
        project_id: Final = self._validate_project_id(
            self.safe_get_vertex_ai_project(litellm_params) or self._resolve_project_id_from_credentials(litellm_params)
        )
        host: Final = "speech.googleapis.com" if location == "global" else f"{location}-speech.googleapis.com"
        base_url: Final = (api_base or f"https://{host}").rstrip("/")
        return f"{base_url}/v2/projects/{project_id}/locations/{location}/recognizers/_:recognize"

    @staticmethod
    def _validate_location(location: str | None) -> str:
        try:
            return validate_vertex_location(location or DEFAULT_SPEECH_TO_TEXT_LOCATION)
        except ValueError as e:
            raise VertexAIError(status_code=400, message=str(e)) from e

    @staticmethod
    def _validate_project_id(project_id: str) -> str:
        if not project_id or ".." in project_id or any(c in project_id for c in _URL_UNSAFE_PROJECT_CHARS):
            raise VertexAIError(status_code=400, message=f"Invalid vertex_project format: {project_id!r}")
        return project_id

    def _resolve_project_id_from_credentials(self, litellm_params: dict) -> str:
        _, project_id = self._ensure_access_token(
            credentials=self.safe_get_vertex_ai_credentials(litellm_params),
            project_id=None,
            custom_llm_provider="vertex_ai",
        )
        return project_id

    def transform_audio_transcription_request(
        self,
        model: str,
        audio_file: FileTypes,
        optional_params: dict,
        litellm_params: dict,
    ) -> AudioTranscriptionRequestData:
        processed_audio: Final = process_audio_file(audio_file)

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Provide a valid GCP project id for vertex_project.
  2. Check for typos or invalid characters in the project id.

Example fix

vertex_project="my-gcp-project"
Defensive patterns

Strategy: validation

When it happens

Trigger: Triggered when the vertex_project value for audio transcription has an invalid format.

Common situations: See trigger scenarios.


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