{"record":{"id":"856e2ddb64e11be3","repo":"microsoft/semantic-kernel","slug":"failed-to-create-nvidia-settings-856e2d","errorCode":null,"errorMessage":"Failed to create NVIDIA settings.","messagePattern":"Failed to create NVIDIA settings\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/nvidia/services/nvidia_text_embedding.py","lineNumber":69,"sourceCode":"                (Env var NVIDIA_API_KEY)\n            base_url: HttpsUrl | None - base_url: The url of the NVIDIA endpoint. The base_url consists of the endpoint,\n                and more information refer https://docs.api.nvidia.com/nim/reference/\n                use endpoint if you only want to supply the endpoint.\n                (Env var NVIDIA_BASE_URL)\n            client (Optional[AsyncOpenAI]): An existing client to use. (Optional)\n            env_file_path (str | None): Use the environment settings file as\n                a fallback to environment variables. (Optional)\n            service_id (str): Service ID for the model. (optional)\n        \"\"\"\n        try:\n            nvidia_settings = NvidiaSettings(\n                api_key=api_key,\n                base_url=base_url,\n                embedding_model_id=ai_model_id,\n                env_file_path=env_file_path,\n            )\n        except ValidationError as ex:\n            raise ServiceInitializationError(\"Failed to create NVIDIA settings.\", ex) from ex\n        if not nvidia_settings.embedding_model_id:\n            nvidia_settings.embedding_model_id = \"nvidia/nv-embedqa-e5-v5\"\n            logger.warning(f\"Default embedding model set as: {nvidia_settings.embedding_model_id}\")\n        if not nvidia_settings.api_key:\n            logger.warning(\"API_KEY is missing, inference may fail.\")\n        if not client:\n            client = AsyncOpenAI(\n                api_key=nvidia_settings.api_key.get_secret_value() if nvidia_settings.api_key else None,\n                base_url=nvidia_settings.base_url,\n            )\n        super().__init__(\n            ai_model_id=nvidia_settings.embedding_model_id,\n            api_key=nvidia_settings.api_key.get_secret_value() if nvidia_settings.api_key else None,\n            ai_model_type=NvidiaModelTypes.EMBEDDING,\n            service_id=service_id or nvidia_settings.embedding_model_id,\n            env_file_path=env_file_path,\n            client=client,\n        )","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/nvidia/services/nvidia_text_embedding.py#L51-L87","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nsvc = NvidiaTextEmbedding()  # -> ServiceInitializationError\n\n# after\nsvc = NvidiaTextEmbedding(\n    api_key=os.environ['NVIDIA_API_KEY'],\n    base_url='https://integrate.api.nvidia.com/v1',\n)","handlingStrategy":"validation","validationCode":"from semantic_kernel.connectors.ai.nvidia import NvidiaSettings\nfrom pydantic import ValidationError\ntry:\n    NvidiaSettings(api_key=os.environ.get('NVIDIA_API_KEY'),\n                   base_url=os.environ.get('NVIDIA_BASE_URL', 'https://integrate.api.nvidia.com/v1'),\n                   embedding_model_id=os.environ.get('NVIDIA_EMBEDDING_MODEL_ID'))\nexcept ValidationError as e:\n    raise SystemExit(f'Fix NVIDIA settings first: {e}')","typeGuard":"from semantic_kernel.exceptions import ServiceInitializationError\n\ndef is_nvidia_embed_settings_error(e: BaseException) -> bool:\n    return isinstance(e, ServiceInitializationError) and 'Failed to create NVIDIA settings' in str(e)","tryCatchPattern":"from semantic_kernel.exceptions import ServiceInitializationError\ntry:\n    svc = NvidiaTextEmbedding()\nexcept ServiceInitializationError as e:\n    raise SystemExit(f'NVIDIA embedding misconfigured: {e.__cause__ or e}') from e","preventionTips":["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."],"tags":["nvidia","embeddings","settings","configuration","pydantic","experimental","service-initialization-error"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}