microsoft/autogen · error · ValueError

openai_endpoint must be provided for azure_openai embedding

Error message

openai_endpoint must be provided for azure_openai embedding provider

What it means

Raised by the Azure tool config validator (model_validator in _config.py) when an Azure AI Search / indexing config declares embedding_provider='azure_openai' together with an embedding_model, but leaves openai_endpoint empty. The Azure OpenAI embedding client needs an explicit HTTPS endpoint to build the connection, so the config is rejected before any network call is made. It is a fail-fast configuration error, not a runtime service error.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/tools/azure/_config.py:184

            raise ValueError("top must be a positive integer")
        return v

    @model_validator(mode="after")
    def validate_interdependent_fields(self) -> "AzureAISearchConfig":
        """Validate interdependent fields after all fields have been parsed."""
        if self.query_type == "semantic" and not self.semantic_config_name:
            raise ValueError("semantic_config_name must be provided when query_type is 'semantic'")

        if self.query_type == "vector" and not self.vector_fields:
            raise ValueError("vector_fields must be provided for vector search")

        if (
            self.embedding_provider
            and self.embedding_provider.lower() == "azure_openai"
            and self.embedding_model
            and not self.openai_endpoint
        ):
            raise ValueError("openai_endpoint must be provided for azure_openai embedding provider")

        return self

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Add openai_endpoint='https://<your-resource>.openai.azure.com/' to the same config object.
  2. Verify the endpoint string is the full Azure OpenAI resource URL, not just the resource name.
  3. If you do not want Azure OpenAI embeddings, set embedding_provider to the managed/Azure Search option and clear embedding_model so the azure_openai branch no longer applies.
  4. Check for trailing-whitespace or empty-string values: the guard only tests truthiness, so an empty string also triggers it.

Example fix

# before
cfg = AzureSearchConfig(
    embedding_provider="azure_openai",
    embedding_model="text-embedding-ada-002",
)

# after
cfg = AzureSearchConfig(
    embedding_provider="azure_openai",
    embedding_model="text-embedding-ada-002",
    openai_endpoint="https://my-resource.openai.azure.com/",
)
Defensive patterns

Strategy: validation

Validate before calling

required = (
    cfg.embedding_provider
    and cfg.embedding_provider.lower() == "azure_openai"
    and cfg.embedding_model
)
if required and not cfg.openai_endpoint:
    raise ValueError("set openai_endpoint before building the azure tool")

Type guard

def azure_embedding_config_is_complete(cfg: AzureConfig) -> bool:
    if cfg.embedding_provider and cfg.embedding_provider.lower() == "azure_openai" and cfg.embedding_model:
        return bool(cfg.openai_endpoint)
    return True

Try / catch

try:
    cfg = AzureConfig(**raw)
except ValueError as e:
    # fail fast with a user-facing config error
    raise ConfigError(str(e)) from e

Prevention

When it happens

Trigger: Building a search/index tool config with embedding_provider='azure_openai' and embedding_model set (e.g. 'text-embedding-ada-002') but omitting openai_endpoint. The validator fires on model validation (config creation / .model_validate), before tool construction completes.

Common situations: Copying an example config that only shows provider+model and skipping the endpoint; assuming the endpoint is read from an AZURE_OPENAI_ENDPOINT env var automatically; typos like 'openai_endpint' leaving the real field empty; switching provider from 'azure_search' managed embeddings to azure_openai without adding the endpoint field.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/1e91545ac5e2cea1. Report an issue: GitHub.