{"record":{"id":"546eab9ecc346b1d","repo":"microsoft/semantic-kernel","slug":"the-vertex-ai-gemini-model-id-is-required","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_chat_completion.py","lineNumber":105,"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 VertexAIChatPromptExecutionSettings\n\n    @override\n    @trace_chat_completion(VertexAIBase.MODEL_PROVIDER_NAME)\n    async def _inner_get_chat_message_contents(\n        self,","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/google/vertex_ai/services/vertex_ai_chat_completion.py#L87-L123","documentation":"Raised by VertexAIChatCompletion.__init__ after settings parse successfully but gemini_model_id resolves to a falsy value. Even though VertexAISettings validated, no model id was supplied explicitly or via env, so the service cannot pick a target model and refuses to initialize.","triggerScenarios":"Constructing VertexAIChatCompletion without gemini_model_id and without a corresponding env var (e.g. VERTEX_AI_GEMINI_MODEL_ID). Passing an empty string for the model id.","commonSituations":"Forgetting to set the model id env var. Assuming a default model is chosen. Copying sample code that omits the model argument while the .env doesn't define it.","solutions":["Pass gemini_model_id explicitly to the VertexAIChatCompletion constructor (e.g. 'gemini-1.5-pro').","Set the VERTEX_AI_GEMINI_MODEL_ID (or configured alias) environment variable / .env entry.","Confirm the model id string is non-empty and matches a valid Vertex AI Gemini model name."],"exampleFix":"# before\nsvc = VertexAIChatCompletion(project_id='p', region='us-central1')\n# after\nsvc = VertexAIChatCompletion(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'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass gemini_model_id explicitly or via a verified env var.","Fail fast in your bootstrap code if the model id is empty.","Keep model ids in a single config source."],"tags":["vertex-ai","configuration","model-id","initialization"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}