Share via


Knowledge Retrieval - Retrieve

KnowledgeAgent retrieves relevant data from backing stores.

POST {endpoint}/agents('{agentName}')/retrieve?api-version=2025-08-01-preview

URI Parameters

Name In Required Type Description
agentName
path True

string

The name of the agent.

endpoint
path True

string (url)

The endpoint URL of the search service.

api-version
query True

string

Client Api Version.

Request Header

Name Required Type Description
x-ms-client-request-id

string (uuid)

The tracking ID sent with the request to help with debugging.

x-ms-query-source-authorization

string

Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents.

Request Body

Name Required Type Description
messages True

KnowledgeAgentMessage[]

The natural language message style object.

knowledgeSourceParams KnowledgeSourceParams[]:

SearchIndexKnowledgeSourceParams[]

Responses

Name Type Description
200 OK

KnowledgeAgentRetrievalResponse

The retrieval response is successfully returned.

Other Status Codes

ErrorResponse

Error response.

Examples

KnowledgeAgentRetrieve

Sample request

POST https://previewexampleservice.search.windows.net/agents('agent-preview-test')/retrieve?api-version=2025-08-01-preview



{
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "text": "hello world",
          "type": "text"
        }
      ]
    }
  ],
  "knowledgeSourceParams": [
    {
      "filterAddOn": "foo eq bar",
      "knowledgeSourceName": "ks-preview-test",
      "kind": "searchIndex"
    }
  ]
}

Sample response

{
  "response": [
    {
      "content": [
        {
          "type": "text",
          "text": "[{...}]"
        }
      ]
    }
  ],
  "activity": [
    {
      "type": "modelQueryPlanning",
      "id": 0,
      "inputTokens": 11,
      "outputTokens": 22,
      "elapsedMs": 10
    },
    {
      "type": "searchIndex",
      "id": 1,
      "knowledgeSourceName": "ks-preview-test",
      "queryTime": "2025-01-01T00:08:45.045Z",
      "count": 2,
      "elapsedMs": 1234,
      "searchIndexArguments": {
        "search": "hello world",
        "filter": "foo eq bar"
      }
    },
    {
      "type": "searchIndex",
      "id": 2,
      "knowledgeSourceName": "ks-preview-test",
      "queryTime": "2025-01-01T00:08:45.045Z",
      "count": 2,
      "elapsedMs": 1234,
      "searchIndexArguments": {
        "search": "hello world two",
        "filter": "foo eq bar"
      }
    },
    {
      "type": "semanticReranker",
      "id": 3,
      "inputTokens": 74,
      "elapsedMs": 0
    }
  ],
  "references": [
    {
      "type": "searchIndex",
      "id": "83dd7d40",
      "activitySource": 1,
      "sourceData": {
        "id": "myDocKey1",
        "title": "high_doc",
        "content": "hello world"
      },
      "rerankerScore": 3.5,
      "docKey": "myDocKey1"
    },
    {
      "type": "searchIndex",
      "id": "83dd7d41",
      "activitySource": 1,
      "sourceData": {
        "id": "myDocKey2",
        "title": "low_doc",
        "content": "goodbye world"
      },
      "rerankerScore": 2.7,
      "docKey": "myDocKey2"
    }
  ]
}

Definitions

Name Description
ErrorAdditionalInfo

The resource management error additional info.

ErrorDetail

The error detail.

ErrorResponse

Error response

Image
KnowledgeAgentAzureBlobReference

Represents an Azure Blob Storage document reference.

KnowledgeAgentMessage

The natural language message style object.

KnowledgeAgentMessageContentType

The type of message content.

KnowledgeAgentMessageImageContent

Text message type.

KnowledgeAgentMessageTextContent

Text message type.

KnowledgeAgentModelAnswerSynthesisActivityRecord

Represents an LLM answer synthesis activity record.

KnowledgeAgentModelQueryPlanningActivityRecord

Represents an LLM query planning activity record.

KnowledgeAgentRetrievalRequest

The input contract for the retrieval request.

KnowledgeAgentRetrievalResponse

The output contract for the retrieval response.

KnowledgeAgentSearchIndexReference

Represents an Azure Search document reference.

KnowledgeAgentSemanticRerankerActivityRecord

Represents a semantic ranker activity record.

KnowledgeSourceKind

The kind of the knowledge source.

SearchIndexKnowledgeSourceParams

Specifies runtime parameters for a search index knowledge source

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info

object

The additional info.

type

string

The additional info type.

ErrorDetail

The error detail.

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorDetail[]

The error details.

message

string

The error message.

target

string

The error target.

ErrorResponse

Error response

Name Type Description
error

ErrorDetail

The error object.

Image

Name Type Description
url

string (uri)

The url of the image.

KnowledgeAgentAzureBlobReference

Represents an Azure Blob Storage document reference.

Name Type Description
activitySource

integer (int32)

The source activity ID for the reference.

blobUrl

string

The blob URL for the reference.

id

string

The ID of the reference.

rerankerScore

number (float)

The reranker score for the document reference.

sourceData

object

type string:

azureBlob

The type of the reference.

KnowledgeAgentMessage

The natural language message style object.

Name Type Description
content KnowledgeAgentMessageContent[]:

Specifies the type of the message content.

role

string

The role of the tool response.

KnowledgeAgentMessageContentType

The type of message content.

Value Description
text

Text message content kind.

image

Image message content kind.

KnowledgeAgentMessageImageContent

Text message type.

Name Type Description
image

Image

type string:

image

The type of the message

KnowledgeAgentMessageTextContent

Text message type.

Name Type Description
text

string

type string:

text

The type of the message

KnowledgeAgentModelAnswerSynthesisActivityRecord

Represents an LLM answer synthesis activity record.

Name Type Description
elapsedMs

integer (int32)

The elapsed time in milliseconds for the retrieval activity.

id

integer (int32)

The ID of the activity record.

inputTokens

integer (int32)

The number of input tokens for the LLM answer synthesis activity.

outputTokens

integer (int32)

The number of output tokens for the LLM answer synthesis activity.

type string:

modelAnswerSynthesis

The type of the activity record.

KnowledgeAgentModelQueryPlanningActivityRecord

Represents an LLM query planning activity record.

Name Type Description
elapsedMs

integer (int32)

The elapsed time in milliseconds for the retrieval activity.

id

integer (int32)

The ID of the activity record.

inputTokens

integer (int32)

The number of input tokens for the LLM query planning activity.

outputTokens

integer (int32)

The number of output tokens for the LLM query planning activity.

type string:

modelQueryPlanning

The type of the activity record.

KnowledgeAgentRetrievalRequest

The input contract for the retrieval request.

Name Type Description
knowledgeSourceParams KnowledgeSourceParams[]:

SearchIndexKnowledgeSourceParams[]

messages

KnowledgeAgentMessage[]

The natural language message style object.

KnowledgeAgentRetrievalResponse

The output contract for the retrieval response.

Name Type Description
activity KnowledgeAgentActivityRecord[]:

The activity records for tracking progress and billing implications.

references KnowledgeAgentReference[]:

The references for the retrieval data used in the response.

response

KnowledgeAgentMessage[]

The natural language message style object.

KnowledgeAgentSearchIndexReference

Represents an Azure Search document reference.

Name Type Description
activitySource

integer (int32)

The source activity ID for the reference.

docKey

string

The document key for the reference.

id

string

The ID of the reference.

rerankerScore

number (float)

The reranker score for the document reference.

sourceData

object

type string:

searchIndex

The type of the reference.

KnowledgeAgentSemanticRerankerActivityRecord

Represents a semantic ranker activity record.

Name Type Description
elapsedMs

integer (int32)

The elapsed time in milliseconds for the retrieval activity.

id

integer (int32)

The ID of the activity record.

inputTokens

integer (int32)

The number of input tokens for the semantic ranker activity.

type string:

semanticReranker

The type of the activity record.

KnowledgeSourceKind

The kind of the knowledge source.

Value Description
searchIndex

A knowledge source that reads data from a Search Index.

azureBlob

A knowledge source that read and ingest data from Azure Blob Storage to a Search Index.

SearchIndexKnowledgeSourceParams

Specifies runtime parameters for a search index knowledge source

Name Type Description
filterAddOn

string

A filter condition applied to the index (e.g., 'State eq VA').

kind string:

searchIndex

The type of the knowledge source.

knowledgeSourceName

string

The name of the index the params apply to.