microsoft/semantic-kernel · error · AgentInitializationException
Please provide an Azure OpenAI endpoint
Error message
Please provide an Azure OpenAI endpoint
What it means
After auth is resolved, the factory checks that azure_openai_settings.endpoint is set. An empty/None endpoint makes it impossible to build the AsyncAzureOpenAI client, so AgentInitializationException("Please provide an Azure OpenAI endpoint") is raised.
Source
Thrown at python/semantic_kernel/agents/open_ai/azure_assistant_agent.py:124
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.chat_deployment_name:
raise AgentInitializationException("Please provide an Azure OpenAI 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.chat_deployment_name
@staticmethod
def create_client(View on GitHub (pinned to c028a0c7dc)
Solutions
- Set AZURE_OPENAI_ENDPOINT (e.g. https://<resource>.openai.azure.com/) in env or .env, or pass endpoint= explicitly.
- Confirm env_file_path loads the file containing AZURE_OPENAI_ENDPOINT.
- Use the Azure endpoint form (not a base_url) when targeting Azure OpenAI.
Example fix
// before
AzureOpenAIAssistantAgent(..., deployment_name=dep, api_key=k) # no endpoint
# -> Please provide an Azure OpenAI endpoint
// after
AzureOpenAIAssistantAgent(
..., deployment_name=dep, api_key=k,
endpoint="https://myresource.openai.azure.com/",
) Defensive patterns
Strategy: validation
Validate before calling
def has_endpoint(settings) -> bool:
return bool(settings.endpoint) Type guard
def has_azure_endpoint(settings) -> bool:
return getattr(settings, 'endpoint', None) not in (None, "") Prevention
- Set AZURE_OPENAI_ENDPOINT to the https://<resource>.openai.azure.com/ form.
- Confirm env_file_path loads the file containing the endpoint.
- Use the Azure endpoint, not a base_url.
When it happens
Trigger: Instantiating the Azure assistant without AZURE_OPENAI_ENDPOINT in the environment/args and without an endpoint= argument, or with base_url configured instead of endpoint (Azure requires the deployment endpoint).
Common situations: Missing AZURE_OPENAI_ENDPOINT env var; using base_url-style config (non-Azure) by mistake; endpoint var typo or in a different .env than env_file_path points to.
Related errors
- Failed to create Azure OpenAI settings: {exc}
- Please provide an Azure OpenAI deployment name
- Please provide either an api_key, ad_token, ad_token_provide
- Please provide an Azure OpenAI endpoint
- Failed to create Anthropic settings.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/9bcff421431a7e67.
Report an issue: GitHub.