Use answer synthesis for citation-backed responses in Azure AI Search

Note

This feature is currently in public preview. This preview is provided without a service-level agreement and isn't recommended for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Azure Previews.

By default, a knowledge base in Azure AI Search performs data extraction, which returns raw grounding chunks from your knowledge sources. Data extraction is useful for retrieving specific information but lacks the context and reasoning necessary for complex queries.

You can instead enable answer synthesis, which uses the LLM specified in your knowledge base to answer queries in natural language. Each answer includes citations to the retrieved sources and follows any instructions you provide, such as using bulleted lists.

You can enable answer synthesis in two ways:

  • On the knowledge base (becomes the default for all queries)
  • On individual retrieval requests (overrides the default)

Important

  • The minimal retrieval reasoning effort disables LLM processing, so it's incompatible with answer synthesis in both knowledge base definitions and retrieval requests. For more information, see Set the retrieval reasoning effort.

  • Answer synthesis incurs Standard Pay-in-Advance Offer charges from Azure OpenAI, which is based on the number of input and output tokens. Charges appear under the LLM assigned to the knowledge base. For more information, see Availability and pricing of agentic retrieval.

Prerequisites

Note

Although you can use the Azure portal to configure answer synthesis, the portal uses the 2025-08-01-preview, which uses the previous "knowledge agent" terminology and doesn't support all 2025-11-01-preview features. For help with breaking changes, see Migrate your agentic retrieval code.

Enable answer synthesis on a knowledge base

This section explains how to enable answer synthesis on an existing knowledge base. Although you can use this configuration for new knowledge bases, knowledge base creation is beyond the scope of this article.

To enable answer synthesis on a knowledge base:

  1. Use the 2025-11-01-preview of Knowledge Base - Create or Update (REST API) to formulate the request.

  2. In the body of the request, set outputMode to answerSynthesis.

  3. (Optional) Use answerInstructions to customize the answer output. Our example instructs the knowledge base to Use concise bulleted lists.

@search-url = <YOUR SEARCH SERVICE URL>
@api-key = <YOUR API KEY>
@knowledge-base-name = <YOUR KNOWLEDGE BASE NAME>

### Enable answer synthesis on a knowledge base
PUT {{search-url}}/knowledgebases/{{knowledge-base-name}}?api-version=2025-11-01-preview  HTTP/1.1
Content-Type: application/json
api-key: {{api-key}}

{
    "name": "{{knowledge-base-name}}",
    "knowledgeSources": [ ... // OMITTED FOR BREVITY ],
    "models": [ ... // OMITTED FOR BREVITY ],
    "outputMode": "answerSynthesis",
    "answerInstructions": "Use concise bulleted lists"
}

Note

This example assumes that you're using key-based authentication for local proof-of-concept testing. We recommend role-based access control for production workloads. For more information, see Connect to Azure AI Search using roles.

Enable answer synthesis on a retrieval request

For per-query control over the response format, you can enable answer synthesis at query time. This approach overrides the default output mode specified in the knowledge base.

To enable answer synthesis on a retrieval request:

  1. Use the 2025-11-01-preview of Knowledge Retrieval - Retrieve (REST API) to formulate the request.

  2. In the body of the request, set outputMode to answerSynthesis.

@search-url = <YOUR SEARCH SERVICE URL>
@api-key = <YOUR API KEY>
@knowledge-base-name = <YOUR KNOWLEDGE BASE NAME>

### Enable answer synthesis on a retrieval request
POST {{search-url}}/knowledgebases/{{knowledge-base-name}}/retrieve?api-version=2025-11-01-preview  HTTP/1.1
Content-Type: application/json
api-key: {{api-key}}

{
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "What is healthcare?"
                }
            ]
        }
    ],
    "outputMode": "answerSynthesis"
}

Note

This example assumes that you're using key-based authentication for local proof-of-concept testing. We recommend role-based access control for production workloads. For more information, see Connect to Azure AI Search using roles.

Get a synthesized answer

When answer synthesis is enabled, Knowledge Retrieval - Retrieve (REST API) returns a natural-language answer based on the instructions you optionally specified in the knowledge base. Citations to your knowledge sources are formatted as [ref_id:<number>].

For example, if your instructions are Use concise bulleted lists and your query is What is healthcare?, the response might look like this:

{
  "response": [
    {
      "content": [
        {
          "type": "text",
          "text": "- Healthcare encompasses various services provided to patients and the general population ... // TRIMMED FOR BREVITY"
        }
      ]
    }
  ]
}

The full text output is as follows:

"- Healthcare encompasses various services provided to patients and the general population, including primary health services, hospital care, dental care, mental health services, and alternative health services [ref_id:1].\n- It involves the delivery of safe, effective, patient-centered care through different modalities, such as in-person encounters, shared medical appointments, and group education sessions [ref_id:0].\n- Behavioral health is a significant aspect of healthcare, focusing on the connection between behavior and overall health, including mental health and substance use [ref_id:2].\n- The healthcare system aims to ensure quality of care, access to providers, and accountability for positive outcomes while managing costs effectively [ref_id:2].\n- The global health system is evolving to address complex health needs, emphasizing the importance of cross-sectoral collaboration and addressing social determinants of health [ref_id:4]."

Depending on your knowledge base's configuration, the response might include other information, such as activity logs and reference arrays. For more information, see Create a knowledge base.