microsoft/semantic-kernel · error · NotImplementedError
Model type {self.ai_model_type} is not supported
Error message
Model type {self.ai_model_type} is not supported What it means
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.
Source
Thrown at python/semantic_kernel/connectors/ai/nvidia/services/nvidia_handler.py:47
"""Internal class for calls to Nvidia API's."""
MODEL_PROVIDER_NAME: ClassVar[str] = "nvidia"
client: AsyncOpenAI
ai_model_type: NvidiaModelTypes = NvidiaModelTypes.CHAT
completion_tokens: int = 0
total_tokens: int = 0
prompt_tokens: int = 0
async def _send_request(self, settings: PromptExecutionSettings) -> RESPONSE_TYPE:
"""Send a request to the Nvidia API."""
if self.ai_model_type == NvidiaModelTypes.EMBEDDING:
assert isinstance(settings, NvidiaEmbeddingPromptExecutionSettings) # nosec
return await self._send_embedding_request(settings)
if self.ai_model_type == NvidiaModelTypes.CHAT:
assert isinstance(settings, NvidiaChatPromptExecutionSettings) # nosec
return await self._send_chat_completion_request(settings)
raise NotImplementedError(f"Model type {self.ai_model_type} is not supported")
async def _send_embedding_request(self, settings: NvidiaEmbeddingPromptExecutionSettings) -> list[Any]:
"""Send a request to the OpenAI embeddings endpoint."""
try:
# unsupported parameters are internally excluded from main dict and added to extra_body
response = await self.client.embeddings.create(**settings.prepare_settings_dict())
self.store_usage(response)
return [x.embedding for x in response.data]
except Exception as ex:
raise ServiceResponseException(
f"{type(self)} service failed to generate embeddings",
ex,
) from ex
async def _send_chat_completion_request(
self, settings: NvidiaChatPromptExecutionSettings
) -> ChatCompletion | AsyncStream[Any]:View on GitHub (pinned to c028a0c7dc)
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.
Example fix
# before handler = MyHandler(...) handler.ai_model_type = 'vision' # not supported # after from semantic_kernel.connectors.ai.nvidia.services.nvidia_model_types import NvidiaModelTypes handler.ai_model_type = NvidiaModelTypes.CHAT
Defensive patterns
Strategy: type-guard
Validate before calling
from semantic_kernel.connectors.ai.nvidia.services.nvidia_model_types import NvidiaModelTypes
assert handler.ai_model_type in (NvidiaModelTypes.CHAT, NvidiaModelTypes.EMBEDDING), \
f'unsupported ai_model_type: {handler.ai_model_type}' Type guard
from semantic_kernel.connectors.ai.nvidia.services.nvidia_model_types import NvidiaModelTypes
def is_supported_nvidia_type(t) -> bool:
return t in (NvidiaModelTypes.CHAT, NvidiaModelTypes.EMBEDDING) Try / catch
try:
resp = await handler._send_request(settings)
except NotImplementedError as e:
raise ValueError(f'Configure ai_model_type to CHAT or EMBEDDING: {e}') from e Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Custom NvidiaHandler subclass that invents a model type string; passing a raw string instead of the NvidiaModelTypes enum; code that monkeypatches ai_model_type.
Related errors
- Unsupported service name: {service_name}
- Unsupported service: {service}. Supported services are: {',
- Failed to create NVIDIA settings.
- The NVIDIA API key is required.
- Failed to create NVIDIA settings.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/2c1c57c7d4615b1e.
Report an issue: GitHub.