microsoft/semantic-kernel · error · ServiceInitializationError
Failed to create NVIDIA settings.
Error message
Failed to create NVIDIA settings.
What it means
Raised as ServiceInitializationError when constructing the pydantic `NvidiaSettings` for the NVIDIA text embedding service raises a `ValidationError`. Config-only failure, not network. Note: this connector is marked @experimental and does NOT hard-require an api_key (it only warns), so the most common trigger is an invalid base_url or bad env_file_path, not a missing key.
Source
Thrown at python/semantic_kernel/connectors/ai/nvidia/services/nvidia_text_embedding.py:69
(Env var NVIDIA_API_KEY)
base_url: HttpsUrl | None - base_url: The url of the NVIDIA endpoint. The base_url consists of the endpoint,
and more information refer https://docs.api.nvidia.com/nim/reference/
use endpoint if you only want to supply the endpoint.
(Env var NVIDIA_BASE_URL)
client (Optional[AsyncOpenAI]): An existing client to use. (Optional)
env_file_path (str | None): Use the environment settings file as
a fallback to environment variables. (Optional)
service_id (str): Service ID for the model. (optional)
"""
try:
nvidia_settings = NvidiaSettings(
api_key=api_key,
base_url=base_url,
embedding_model_id=ai_model_id,
env_file_path=env_file_path,
)
except ValidationError as ex:
raise ServiceInitializationError("Failed to create NVIDIA settings.", ex) from ex
if not nvidia_settings.embedding_model_id:
nvidia_settings.embedding_model_id = "nvidia/nv-embedqa-e5-v5"
logger.warning(f"Default embedding model set as: {nvidia_settings.embedding_model_id}")
if not nvidia_settings.api_key:
logger.warning("API_KEY is missing, inference may fail.")
if not client:
client = AsyncOpenAI(
api_key=nvidia_settings.api_key.get_secret_value() if nvidia_settings.api_key else None,
base_url=nvidia_settings.base_url,
)
super().__init__(
ai_model_id=nvidia_settings.embedding_model_id,
api_key=nvidia_settings.api_key.get_secret_value() if nvidia_settings.api_key else None,
ai_model_type=NvidiaModelTypes.EMBEDDING,
service_id=service_id or nvidia_settings.embedding_model_id,
env_file_path=env_file_path,
client=client,
)View on GitHub (pinned to c028a0c7dc)
Solutions
- Inspect the chained `ex` ValidationError for the failing field.
- Pass a valid base_url (full https:// URL) and/or env_file_path that exists.
- Set NVIDIA_API_KEY/NVIDIA_BASE_URL/NVIDIA_EMBEDDING_MODEL_ID correctly in env/.env.
- If you only need defaults, omit ai_model_id so the built-in default applies after validation.
Example fix
# before
svc = NvidiaTextEmbedding() # -> ServiceInitializationError
# after
svc = NvidiaTextEmbedding(
api_key=os.environ['NVIDIA_API_KEY'],
base_url='https://integrate.api.nvidia.com/v1',
) Defensive patterns
Strategy: validation
Validate before calling
from semantic_kernel.connectors.ai.nvidia import NvidiaSettings
from pydantic import ValidationError
try:
NvidiaSettings(api_key=os.environ.get('NVIDIA_API_KEY'),
base_url=os.environ.get('NVIDIA_BASE_URL', 'https://integrate.api.nvidia.com/v1'),
embedding_model_id=os.environ.get('NVIDIA_EMBEDDING_MODEL_ID'))
except ValidationError as e:
raise SystemExit(f'Fix NVIDIA settings first: {e}') Type guard
from semantic_kernel.exceptions import ServiceInitializationError
def is_nvidia_embed_settings_error(e: BaseException) -> bool:
return isinstance(e, ServiceInitializationError) and 'Failed to create NVIDIA settings' in str(e) Try / catch
from semantic_kernel.exceptions import ServiceInitializationError
try:
svc = NvidiaTextEmbedding()
except ServiceInitializationError as e:
raise SystemExit(f'NVIDIA embedding misconfigured: {e.__cause__ or e}') from e Prevention
- Pass a valid base_url (https) to NvidiaTextEmbedding or set NVIDIA_BASE_URL.
- Validate NvidiaSettings up front to get clear field errors.
- Remember this connector only warns on a missing api_key - set it anyway.
When it happens
Trigger: Constructing `NvidiaTextEmbedding(...)` where merged config fails pydantic NvidiaSettings validation: malformed NVIDIA_BASE_URL (not a valid HttpUrl), unreadable env_file_path, or embedding_model_id set to an invalid type. The default 'nvidia/nv-embedqa-e5-v5' applies only AFTER settings build, so a validation failure short-circuits it.
Common situations: NVIDIA_BASE_URL missing scheme, env_file_path pointing at a non-existent file, a pydantic version difference, or a non-string passed for ai_model_id.
Related errors
- Failed to validate Mistral AI settings: {e}
- Failed to create NVIDIA settings.
- Failed to validate Google AI settings: {e}
- Failed to create Ollama settings.
- Failed to create Ollama settings.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/856e2ddb64e11be3.
Report an issue: GitHub.