{"record":{"id":"0f1efba6915733bf","repo":"microsoft/semantic-kernel","slug":"the-vertex-ai-gemini-model-id-is-required-0f1efb","errorCode":null,"errorMessage":"The Vertex AI Gemini model ID is required.","messagePattern":"The Vertex AI Gemini model ID is required\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/google/vertex_ai/services/vertex_ai_text_completion.py","lineNumber":77,"sourceCode":"            project_id (str): The Google Cloud project ID.\n            region (str): The Google Cloud region.\n            gemini_model_id (str): The Gemini model ID.\n            service_id (str): The Vertex AI service ID.\n            env_file_path (str): The path to the environment file.\n            env_file_encoding (str): The encoding of the environment file.\n        \"\"\"\n        try:\n            vertex_ai_settings = VertexAISettings(\n                project_id=project_id,\n                region=region,\n                gemini_model_id=gemini_model_id,\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n            )\n        except ValidationError as e:\n            raise ServiceInitializationError(f\"Failed to validate Vertex AI settings: {e}\") from e\n        if not vertex_ai_settings.gemini_model_id:\n            raise ServiceInitializationError(\"The Vertex AI Gemini model ID is required.\")\n\n        super().__init__(\n            ai_model_id=vertex_ai_settings.gemini_model_id,\n            service_id=service_id or vertex_ai_settings.gemini_model_id,\n            service_settings=vertex_ai_settings,\n        )\n\n    # region Overriding base class methods\n\n    # Override from AIServiceClientBase\n    @override\n    def get_prompt_execution_settings_class(self) -> type[\"PromptExecutionSettings\"]:\n        return VertexAITextPromptExecutionSettings\n\n    @override\n    @trace_text_completion(VertexAIBase.MODEL_PROVIDER_NAME)\n    async def _inner_get_text_contents(\n        self,","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/google/vertex_ai/services/vertex_ai_text_completion.py#L59-L95","documentation":"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.","triggerScenarios":"Constructing VertexAITextCompletion without gemini_model_id and no matching env var. Passing an empty model id string.","commonSituations":"Forgetting to set VERTEX_AI_GEMINI_MODEL_ID. Assuming a default. Reusing config code that omits the model argument.","solutions":["Pass gemini_model_id explicitly to VertexAITextCompletion.","Set the model id via environment variable / .env.","Verify the model name is non-empty and valid for Vertex AI text completion."],"exampleFix":"# before\nsvc = VertexAITextCompletion(project_id='p', region='us-central1')\n# after\nsvc = VertexAITextCompletion(project_id='p', region='us-central1', gemini_model_id='gemini-1.5-pro')","handlingStrategy":"validation","validationCode":"model_id = os.environ.get('VERTEX_AI_GEMINI_MODEL_ID') or passed_model_id\nassert model_id, 'Vertex AI Gemini model ID is required for text completion'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass gemini_model_id explicitly for the text-completion service.","Centralize model ids in config and assert they are non-empty.","Don't assume a default model is selected."],"tags":["vertex-ai","configuration","model-id","initialization","text-completion"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}