microsoft/semantic-kernel · error · ServiceInitializationError

Failed to validate Vertex AI settings: {e}

Error message

Failed to validate Vertex AI settings: {e}

What it means

Raised by VertexAITextEmbedding.__init__ when VertexAISettings construction raises a ValidationError. The embedding service wraps the pydantic failure (embedding_model_id/project_id/region) into a ServiceInitializationError at construction time.

Source

Thrown at python/semantic_kernel/connectors/ai/google/vertex_ai/services/vertex_ai_text_embedding.py:68

        Args:
            project_id (str): The Google Cloud project ID.
            region (str): The Google Cloud region.
            embedding_model_id (str): The Gemini model ID.
            service_id (str): The Vertex AI service ID.
            env_file_path (str): The path to the environment file.
            env_file_encoding (str): The encoding of the environment file.
        """
        try:
            vertex_ai_settings = VertexAISettings(
                project_id=project_id,
                region=region,
                embedding_model_id=embedding_model_id,
                env_file_path=env_file_path,
                env_file_encoding=env_file_encoding,
            )
        except ValidationError as e:
            raise ServiceInitializationError(f"Failed to validate Vertex AI settings: {e}") from e
        if not vertex_ai_settings.embedding_model_id:
            raise ServiceInitializationError("The Vertex AI embedding model ID is required.")

        super().__init__(
            ai_model_id=vertex_ai_settings.embedding_model_id,
            service_id=service_id or vertex_ai_settings.embedding_model_id,
            service_settings=vertex_ai_settings,
        )

    @override
    async def generate_embeddings(
        self,
        texts: list[str],
        settings: "PromptExecutionSettings | None" = None,
        **kwargs: Any,
    ) -> ndarray:
        raw_embeddings = await self.generate_raw_embeddings(texts, settings, **kwargs)
        return array(raw_embeddings)

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Read the {e} detail to identify the failing field(s).
  2. Supply project_id and region explicitly or via env / .env.
  3. Confirm env_file_path and encoding are correct.

Example fix

# before
svc = VertexAITextEmbedding()
# after
svc = VertexAITextEmbedding(project_id='my-project', region='us-central1', embedding_model_id='textembedding-gecko@003')
Defensive patterns

Strategy: validation

Validate before calling

from semantic_kernel.connectors.ai.google.vertex_ai.vertex_ai_settings import VertexAISettings
try:
    s = VertexAISettings(embedding_model_id=passed)
except Exception as e:
    print('config invalid:', e)

Try / catch

try:
    svc = VertexAITextEmbedding(project_id=..., region=..., embedding_model_id=...)
except ServiceInitializationError as e:
    raise

Prevention

When it happens

Trigger: Instantiating VertexAITextEmbedding with missing/malformed configuration (project_id, region, embedding_model_id, or env file issues).

Common situations: No VERTEX_AI_PROJECT/region env var. Bad .env path. Embedding-specific settings not configured.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/24e4ba0675730453. Report an issue: GitHub.