BerriAI/litellm · error · ImportError

vertexai.rag module not found. Vertex AI RAG requires google

Error message

vertexai.rag module not found. Vertex AI RAG requires google-cloud-aiplatform>=1.60.0. Install with: pip install 'google-cloud-aiplatform>=1.60.0'

What it means

ImportError raised when `from vertexai import rag` fails inside _import_file_to_corpus_via_sdk. The REST endpoint for importRagFiles is not publicly available, so Vertex RAG ingestion uses the Python SDK, which requires google-cloud-aiplatform>=1.60.0; without it the import step cannot run.

Source

Thrown at litellm/llms/vertex_ai/rag_engine/ingestion.py:175

                os.environ["GCS_BUCKET_NAME"] = original_bucket
            elif "GCS_BUCKET_NAME" in os.environ:
                del os.environ["GCS_BUCKET_NAME"]

    async def _import_file_to_corpus_via_sdk(
        self,
        gcs_uri: str,
    ) -> None:
        """
        Import file into RAG corpus using the Vertex AI SDK.

        The REST API endpoint for importRagFiles is not publicly available,
        so we use the Python SDK.
        """
        try:
            from vertexai import init as vertexai_init
            from vertexai import rag
        except ImportError:
            raise ImportError(
                "vertexai.rag module not found. Vertex AI RAG requires "
                "google-cloud-aiplatform>=1.60.0. Install with: "
                "pip install 'google-cloud-aiplatform>=1.60.0'"
            )

        # Initialize Vertex AI
        vertexai_init(project=self.vertex_project, location=self.vertex_location)

        # Get chunking config from ingest_options (unified interface)
        transformation_config: Final = self._build_transformation_config()

        corpus_name: Final = self._get_corpus_name()
        verbose_logger.debug("Importing %s into corpus %s", gcs_uri, self.corpus_id)

        if self.wait_for_import:
            # Synchronous import - wait for completion
            response: Final = rag.import_files(
                corpus_name=corpus_name,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. pip install 'google-cloud-aiplatform>=1.60.0'
  2. Verify the import works: python -c 'from vertexai import rag'
  3. If another package pins an older aiplatform, upgrade that pin or isolate in a separate venv
  4. Rebuild the deployment image so the dependency ships with it

Example fix

# before: ImportError from litellm Vertex RAG ingestion

# after
pip install 'google-cloud-aiplatform>=1.60.0'
python -c 'from vertexai import rag; print("ok")'
Defensive patterns

Strategy: validation

Validate before calling

def vertex_rag_available() -> bool:
    try:
        from vertexai import rag  # noqa: F401
        return True
    except ImportError:
        return False

assert vertex_rag_available(), "pip install 'google-cloud-aiplatform>=1.60.0'"

Try / catch

try:
    corpus_id, gcs_uri = await run_vertex_rag_ingestion(...)
except ImportError as e:
    raise SystemExit(f'Missing SDK dependency: {e}')

Prevention

When it happens

Trigger: Running Vertex RAG file ingestion in an environment where google-cloud-aiplatform is missing or older than 1.60.0; dependency resolution downgrading aiplatform below the required version.

Common situations: Slim Docker images that skip optional deps; aiplatform pinned to an older version by another library; stale virtualenvs after upgrading litellm.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


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