{"record":{"id":"8b11a507286a3a89","repo":"microsoft/autogen","slug":"openai-endpoint-is-required-when-embedding-provide","errorCode":null,"errorMessage":"openai_endpoint is required when embedding_provider is 'azure_openai'","messagePattern":"openai_endpoint is required when embedding_provider is 'azure_openai'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py","lineNumber":979,"sourceCode":"                # Vector search with OpenAI embeddings\n                openai_tool = AzureAISearchTool.create_vector_search(\n                    name=\"openai-vector-search\",\n                    endpoint=\"https://your-search.search.windows.net\",\n                    index_name=\"<your-index>\",\n                    credential=AzureKeyCredential(\"<your-key>\"),\n                    vector_fields=[\"content_vector\"],\n                    embedding_provider=\"openai\",  # Use OpenAI for embeddings\n                    embedding_model=\"text-embedding-ada-002\",  # Embedding model to use\n                    openai_api_key=\"<your-openai-key>\",  # Your OpenAI API key\n                    select_fields=[\"content\", \"title\", \"url\"],  # Fields to return in results\n                    top=5,\n                )\n\n                # Use the tool with an Agent\n                # assistant = Agent(\"assistant\", tools=[azure_openai_tool])\n        \"\"\"\n        if embedding_provider == \"azure_openai\" and not openai_endpoint:\n            raise ValueError(\"openai_endpoint is required when embedding_provider is 'azure_openai'\")\n\n        config_dict = {\n            \"name\": name,\n            \"endpoint\": endpoint,\n            \"index_name\": index_name,\n            \"credential\": credential,\n            \"description\": description,\n            \"api_version\": api_version or DEFAULT_API_VERSION,\n            \"query_type\": \"vector\",\n            \"select_fields\": select_fields,\n            \"vector_fields\": vector_fields,\n            \"top\": top,\n            \"filter\": filter,\n            \"enable_caching\": enable_caching,\n            \"cache_ttl_seconds\": cache_ttl_seconds,\n            \"embedding_provider\": embedding_provider,\n            \"embedding_model\": embedding_model,\n            \"openai_api_key\": openai_api_key,","sourceCodeStart":961,"sourceCodeEnd":997,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/azure/_ai_search.py#L961-L997","documentation":"In the vector search factory, embeddings can be delegated to Azure OpenAI (embedding_provider='azure_openai'). That provider needs a deployment endpoint, so the factory raises ValueError when openai_endpoint is missing. This mirrors the config model rule (error 938) at construction time.","triggerScenarios":"Creating a vector search tool with embedding_provider='azure_openai' but without openai_endpoint (or with None/''), typically while still providing openai_api_key and embedding_model.","commonSituations":"Copying the 'openai' (public OpenAI) example and just changing embedding_provider to 'azure_openai'; env var for the Azure OpenAI endpoint unset; confusion between the search endpoint and the Azure OpenAI endpoint.","solutions":["Pass openai_endpoint='https://<resource>.openai.azure.com' (the Azure OpenAI resource, not the search service).","Also supply openai_api_key (or token credential) and embedding_model matching a deployed embeddings model; consider openai_api_version if the deployment needs it.","If you meant public OpenAI, use embedding_provider='openai' with openai_api_key only."],"exampleFix":"# before\ntool = await AzureAISearchTool.create_vector_search_tool(..., embedding_provider='azure_openai', embedding_model='text-embedding-ada-002', openai_api_key=k)\n# after\ntool = await AzureAISearchTool.create_vector_search_tool(..., embedding_provider='azure_openai', embedding_model='text-embedding-ada-002', openai_endpoint='https://myres.openai.azure.com', openai_api_key=k)","handlingStrategy":"validation","validationCode":"def azure_openai_embedding_ready(embedding_provider: str, openai_endpoint) -> bool:\n    if embedding_provider == 'azure_openai':\n        return isinstance(openai_endpoint, str) and openai_endpoint.startswith('https://')\n    return True","typeGuard":"def embedding_provider_configured(provider: str, endpoint) -> bool:\n    return provider != 'azure_openai' or bool(endpoint)","tryCatchPattern":null,"preventionTips":["Set AZURE_OPENAI_ENDPOINT and derive openai_endpoint from it in one helper.","Do not confuse the search endpoint with the Azure OpenAI endpoint — validate both start with https:// and differ.","If using public OpenAI, choose embedding_provider='openai'."],"tags":["azure","azure-openai","embeddings","configuration","validation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}