microsoft/semantic-kernel · critical · AgentInitializationException

Please provide an Azure OpenAI endpoint

Error message

Please provide an Azure OpenAI endpoint

What it means

Raised by AzureResponsesAgent's client builder when AzureOpenAISettings.endpoint is unset. The AsyncAzureOpenAI client requires an azure_endpoint to route requests, so an empty endpoint blocks client creation entirely.

Source

Thrown at python/semantic_kernel/agents/open_ai/azure_responses_agent.py:131

            and credential
        ):
            ad_token = get_entra_auth_token(credential, azure_openai_settings.token_endpoint)

        # If we still have no credentials, we can't proceed
        if not azure_openai_settings.api_key and not ad_token and not ad_token_provider and not credential:
            raise AgentInitializationException(
                "Please provide either an api_key, ad_token, ad_token_provider or credential for authentication."
            )

        merged_headers = dict(copy(default_headers)) if default_headers else {}
        if default_headers:
            merged_headers.update(default_headers)
        if APP_INFO:
            merged_headers.update(APP_INFO)
            merged_headers = prepend_semantic_kernel_to_user_agent(merged_headers)

        if not azure_openai_settings.endpoint:
            raise AgentInitializationException("Please provide an Azure OpenAI endpoint")

        if not azure_openai_settings.responses_deployment_name:
            raise AgentInitializationException("Please provide an Azure OpenAI Responses deployment name")

        client = AsyncAzureOpenAI(
            azure_endpoint=str(azure_openai_settings.endpoint),
            api_version=azure_openai_settings.api_version,
            api_key=azure_openai_settings.api_key.get_secret_value() if azure_openai_settings.api_key else None,
            azure_ad_token=ad_token,
            azure_ad_token_provider=ad_token_provider,
            default_headers=merged_headers,
            **kwargs,
        )

        return client, azure_openai_settings.responses_deployment_name

    @staticmethod
    def create_client(

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Set AZURE_OPENAI_ENDPOINT to your resource URL (https://<resource>.openai.azure.com/).
  2. Pass endpoint= explicitly to the AzureResponsesAgent constructor.
  3. Verify the .env file is loaded (check env_file_path and that os.environ has the value).
  4. Ensure the value is an HTTPS URL.

Example fix

# before
AzureResponsesAgent(deployment_name="resp-deploy", api_key="...")  # no endpoint
# after
AzureResponsesAgent(
    endpoint="https://myresource.openai.azure.com/",
    deployment_name="resp-deploy",
    api_key="...",
)
Defensive patterns

Strategy: validation

Validate before calling

from semantic_kernel.connectors.ai.open_ai.settings import AzureOpenAISettings

settings = AzureOpenAISettings()
if not settings.endpoint:
    raise SystemExit("AZURE_OPENAI_ENDPOINT is not set (e.g. https://<resource>.openai.azure.com/).")
if not str(settings.endpoint).startswith("https://"):
    raise SystemExit("AZURE_OPENAI_ENDPOINT must be an HTTPS URL.")

Prevention

When it happens

Trigger: Constructing AzureResponsesAgent without AZURE_OPENAI_ENDPOINT and without passing endpoint (and no usable base_url that substitutes for it in this path). The check `if not azure_openai_settings.endpoint` triggers.

Common situations: Missing AZURE_OPENAI_ENDPOINT in the environment; wrong env_file_path so the .env is not loaded; using base_url-only configuration in a code path that still demands endpoint.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/57df5d1668aafc90. Report an issue: GitHub.