APIM not supported for knowledge base LLM in Agentic Retrieval

Sharma, Jyoti 0 Reputation points
2026-07-23T09:05:54.6533333+00:00

Hi Team,

We have implemented Agentic Retrieval in our solution, For POC we used AzureOpenAI API's directly to configure Knowledge Base LLM and our implementation was working perfectly fine. Our organization has this policy that all requests to AzureOpenAI API's should route through APIM only so we can't use AzureOpenAI API or foundry resource directly while creating the knowledge base, we will have to go through APIM only.
so we created the managed identity of our Azure AI Search and provided the access to identity on APIM with API Management Service Reader Role.

We were able to create knowledge base successfully but when we are invoking the knowledge base, we are getting 401 error.
This is how we are creating the knowledgebase, here the endpoint is APIM endpoint.User's image

We found in one of the documentations that APIM is not supported for knowledgebase LLM, but we don't have any other alternative, we need answer synthesis with at least low reasoning effort, so LLM is necessary.

Can you please let us know if you have any solution for this?

Azure AI Search
Azure AI Search

An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.


1 answer

Sort by: Most helpful
  1. Deepanshu katara 18,230 Reputation points MVP Volunteer Moderator
    2026-07-23T10:34:20.4666667+00:00

    Hello, Welcome to MS Q&A

    Based on my interpretation , Azure AI Search Knowledge Bases (Agentic Retrieval) currently expect the LLM to be a Microsoft Foundry/Azure OpenAI resource, accessed using the Search service's Managed Identity with the Cognitive Services User role. There is no documented support for configuring an APIM endpoint as the Knowledge Base LLM endpoint. Although APIM is supported for client applications calling Azure OpenAI, this support does not extend to the internal LLM calls made by Knowledge Bases for Answer Synthesis. Therefore, routing Knowledge Base LLM traffic through APIM is not a supported architecture today, which is likely the reason for the 401 error.

    Microsoft Learn references:

    Any other solution what I can suggest

    Option 1: Build a custom RAG pipeline

    Instead of using the built-in Knowledge Base Answer Synthesis:

    • Azure AI Search for retrieval
    • Azure OpenAI via APIM for generation
    • Optional orchestration with Azure AI Foundry Agent Service or Semantic Kernel

    This provides the most flexibility and fully complies with the APIM requirement.


    Option 2: Request Microsoft support

    Since this appears to be a product limitation, ask Microsoft whether:

    • APIM support for Knowledge Base LLM endpoints is on the roadmap.
    • There is a private preview or undocumented supported configuration for APIM.

    Pls check and let us know if any further ques

    Thanks
    Deepanshu

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.