{"record":{"id":"2c1c57c7d4615b1e","repo":"microsoft/semantic-kernel","slug":"model-type-self-ai-model-type-is-not-supported","errorCode":null,"errorMessage":"Model type {self.ai_model_type} is not supported","messagePattern":"Model type (.+?) is not supported","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/nvidia/services/nvidia_handler.py","lineNumber":47,"sourceCode":"    \"\"\"Internal class for calls to Nvidia API's.\"\"\"\n\n    MODEL_PROVIDER_NAME: ClassVar[str] = \"nvidia\"\n    client: AsyncOpenAI\n    ai_model_type: NvidiaModelTypes = NvidiaModelTypes.CHAT\n    completion_tokens: int = 0\n    total_tokens: int = 0\n    prompt_tokens: int = 0\n\n    async def _send_request(self, settings: PromptExecutionSettings) -> RESPONSE_TYPE:\n        \"\"\"Send a request to the Nvidia API.\"\"\"\n        if self.ai_model_type == NvidiaModelTypes.EMBEDDING:\n            assert isinstance(settings, NvidiaEmbeddingPromptExecutionSettings)  # nosec\n            return await self._send_embedding_request(settings)\n        if self.ai_model_type == NvidiaModelTypes.CHAT:\n            assert isinstance(settings, NvidiaChatPromptExecutionSettings)  # nosec\n            return await self._send_chat_completion_request(settings)\n\n        raise NotImplementedError(f\"Model type {self.ai_model_type} is not supported\")\n\n    async def _send_embedding_request(self, settings: NvidiaEmbeddingPromptExecutionSettings) -> list[Any]:\n        \"\"\"Send a request to the OpenAI embeddings endpoint.\"\"\"\n        try:\n            # unsupported parameters are internally excluded from main dict and added to extra_body\n            response = await self.client.embeddings.create(**settings.prepare_settings_dict())\n\n            self.store_usage(response)\n            return [x.embedding for x in response.data]\n        except Exception as ex:\n            raise ServiceResponseException(\n                f\"{type(self)} service failed to generate embeddings\",\n                ex,\n            ) from ex\n\n    async def _send_chat_completion_request(\n        self, settings: NvidiaChatPromptExecutionSettings\n    ) -> ChatCompletion | AsyncStream[Any]:","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/nvidia/services/nvidia_handler.py#L29-L65","documentation":"Raised as NotImplementedError in `NvidiaHandler._send_request` when `self.ai_model_type` matches neither NvidiaModelTypes.EMBEDDING nor NvidiaModelTypes.CHAT. This is a programming/contract error, not a runtime network issue: the handler is configured with an unsupported model type, so it cannot dispatch the request.","triggerScenarios":"Subclassing NvidiaHandler (or otherwise constructing it) and setting ai_model_type to a value outside {CHAT, EMBEDDING}, then calling invoke/generate_embeddings which routes through _send_request. Also if a future NvidiaModelTypes member is added but _send_request isn't updated.","commonSituations":"Custom NvidiaHandler subclass that invents a model type string; passing a raw string instead of the NvidiaModelTypes enum; code that monkeypatches ai_model_type.","solutions":["Use one of the supported NvidiaModelTypes (CHAT or EMBEDDING) for ai_model_type.","If you need a new type, extend _send_request with a dispatch branch instead of relying on the default.","Prefer the high-level NvidiaChatCompletion / NvidiaTextEmbedding classes (they set ai_model_type correctly) over constructing NvidiaHandler directly."],"exampleFix":"# before\nhandler = MyHandler(...)\nhandler.ai_model_type = 'vision'   # not supported\n\n# after\nfrom semantic_kernel.connectors.ai.nvidia.services.nvidia_model_types import NvidiaModelTypes\nhandler.ai_model_type = NvidiaModelTypes.CHAT","handlingStrategy":"type-guard","validationCode":"from semantic_kernel.connectors.ai.nvidia.services.nvidia_model_types import NvidiaModelTypes\nassert handler.ai_model_type in (NvidiaModelTypes.CHAT, NvidiaModelTypes.EMBEDDING), \\\n    f'unsupported ai_model_type: {handler.ai_model_type}'","typeGuard":"from semantic_kernel.connectors.ai.nvidia.services.nvidia_model_types import NvidiaModelTypes\n\ndef is_supported_nvidia_type(t) -> bool:\n    return t in (NvidiaModelTypes.CHAT, NvidiaModelTypes.EMBEDDING)","tryCatchPattern":"try:\n    resp = await handler._send_request(settings)\nexcept NotImplementedError as e:\n    raise ValueError(f'Configure ai_model_type to CHAT or EMBEDDING: {e}') from e","preventionTips":["Use the high-level NvidiaChatCompletion / NvidiaTextEmbedding classes which set ai_model_type correctly.","Never assign a raw string to ai_model_type; use the NvidiaModelTypes enum.","If subclassing NvidiaHandler, extend _send_request for any new type."],"tags":["nvidia","model-type","not-implemented","configuration","enum"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}