{"record":{"id":"0210384830f370c8","repo":"microsoft/semantic-kernel","slug":"the-credential-parameter-is-required-for-authent","errorCode":null,"errorMessage":"The 'credential' parameter is required for authentication.","messagePattern":"The 'credential' parameter is required for authentication\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/azure_ai_inference/services/azure_ai_inference_base.py","lineNumber":104,"sourceCode":"                    endpoint=endpoint,\n                    api_version=api_version,\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 Azure AI Inference settings: {e}\") from e\n\n            endpoint = str(azure_ai_inference_settings.endpoint)\n            if azure_ai_inference_settings.api_key is not None:\n                client = AzureAIInferenceClientType.get_client_class(client_type)(\n                    endpoint=endpoint,\n                    credential=AzureKeyCredential(azure_ai_inference_settings.api_key.get_secret_value()),\n                    user_agent=SEMANTIC_KERNEL_USER_AGENT,\n                    api_version=azure_ai_inference_settings.api_version,\n                )\n            else:\n                if credential is None:\n                    raise ServiceInitializationError(\"The 'credential' parameter is required for authentication.\")\n\n                client = AzureAIInferenceClientType.get_client_class(client_type)(\n                    endpoint=endpoint,\n                    credential=credential,\n                    user_agent=SEMANTIC_KERNEL_USER_AGENT,\n                    api_version=azure_ai_inference_settings.api_version,\n                )\n\n        args: dict[str, Any] = {\n            \"client\": client,\n            \"managed_client\": managed_client,\n            **kwargs,\n        }\n\n        if instruction_role:\n            args[\"instruction_role\"] = instruction_role\n\n        super().__init__(**args)","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/azure_ai_inference/services/azure_ai_inference_base.py#L86-L122","documentation":"Raised during Azure AI Inference service construction when no api_key is available (settings.api_key is None) and the caller also did not pass a 'credential' object. The connector supports two auth paths: API key (from settings) or an Azure SDK TokenCredential (e.g. DefaultAzureCredential). If neither is supplied, authentication is impossible and initialization fails.","triggerScenarios":"Intending to use managed identity / AAD auth (no api_key in env) but forgetting to pass credential=... to the service constructor. Or clearing AZURE_AI_INFERENCE_API_KEY while relying on a credential that was never provided.","commonSituations":"Switching from key-based to AAD auth in production and omitting credential; local dev where DefaultAzureCredential was assumed to be default but must be passed explicitly; misconfigured deployment that strips the key but adds no identity.","solutions":["Pass an Azure credential, e.g. credential=DefaultAzureCredential() (or ManagedIdentityCredential, AzureCliCredential, etc.).","Or provide AZURE_AI_INFERENCE_API_KEY (or api_key= arg) to use key auth.","Ensure the chosen credential's identity has been granted access to the Azure AI / model deployment."],"exampleFix":"# before\nservice = AzureAIInferenceChatCompletion(model_id=\"gpt-4o\")  # no key, no credential\n\n# after\nfrom azure.identity import DefaultAzureCredential\nservice = AzureAIInferenceChatCompletion(model_id=\"gpt-4o\", credential=DefaultAzureCredential())","handlingStrategy":"validation","validationCode":"import os\nfrom azure.identity import DefaultAzureCredential\n\napi_key = os.getenv(\"AZURE_AI_INFERENCE_API_KEY\")\ncredential = DefaultAzureCredential() if not api_key else None\nservice = AzureAIInferenceChatCompletion(\n    model_id=model_id,\n    api_key=api_key,\n    credential=credential,\n)","typeGuard":"def has_auth(api_key, credential) -> bool:\n    return api_key is not None or credential is not None","tryCatchPattern":"from semantic_kernel.exceptions import ServiceInitializationError\ntry:\n    service = AzureAIInferenceChatCompletion(model_id=model_id)\nexcept ServiceInitializationError as e:\n    if \"credential\" in str(e):\n        from azure.identity import DefaultAzureCredential\n        service = AzureAIInferenceChatCompletion(model_id=model_id, credential=DefaultAzureCredential())","preventionTips":["Decide auth mode upfront: key (api_key) or AAD (credential).","When dropping the API key, always pass a credential.","Grant the identity access to the model deployment."],"tags":["azure-ai-inference","authentication","credentials","service-init","python"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}