microsoft/semantic-kernel · error · ServiceInitializationError

The Vertex AI Gemini model ID is required.

Error message

The Vertex AI Gemini model ID is required.

What it means

Raised by VertexAITextCompletion.__init__ after settings validate but gemini_model_id is empty/None. The text-completion service needs a concrete Gemini model to target and refuses to initialize without one.

Source

Thrown at python/semantic_kernel/connectors/ai/google/vertex_ai/services/vertex_ai_text_completion.py:77

            project_id (str): The Google Cloud project ID.
            region (str): The Google Cloud region.
            gemini_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,
                gemini_model_id=gemini_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.gemini_model_id:
            raise ServiceInitializationError("The Vertex AI Gemini model ID is required.")

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

    # region Overriding base class methods

    # Override from AIServiceClientBase
    @override
    def get_prompt_execution_settings_class(self) -> type["PromptExecutionSettings"]:
        return VertexAITextPromptExecutionSettings

    @override
    @trace_text_completion(VertexAIBase.MODEL_PROVIDER_NAME)
    async def _inner_get_text_contents(
        self,

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Pass gemini_model_id explicitly to VertexAITextCompletion.
  2. Set the model id via environment variable / .env.
  3. Verify the model name is non-empty and valid for Vertex AI text completion.

Example fix

# before
svc = VertexAITextCompletion(project_id='p', region='us-central1')
# after
svc = VertexAITextCompletion(project_id='p', region='us-central1', gemini_model_id='gemini-1.5-pro')
Defensive patterns

Strategy: validation

Validate before calling

model_id = os.environ.get('VERTEX_AI_GEMINI_MODEL_ID') or passed_model_id
assert model_id, 'Vertex AI Gemini model ID is required for text completion'

Prevention

When it happens

Trigger: Constructing VertexAITextCompletion without gemini_model_id and no matching env var. Passing an empty model id string.

Common situations: Forgetting to set VERTEX_AI_GEMINI_MODEL_ID. Assuming a default. Reusing config code that omits the model argument.

Related errors


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