Knowledge Bases

Retrieve Chunks from a Knowledge Base / Test Retrieval

Changed on

Searches a knowledge base and returns the chunks most relevant to the query, for both production retrieval and test retrieval.

post/datasets/{dataset_id}/retrieve

Request

  • Base URL
    https://api.dify.ai/v1
  • URL
    https://api.dify.ai/v1/datasets/{dataset_id}/retrieve
  • Auth
    HTTP bearer

Path parameters

dataset_idstring uuid required

Knowledge base ID, from List Knowledge Bases. For a scoped key, copy the ID from the Dify URL.

Request body

attachment_idsstring[] nullable

List of attachment IDs to include in the retrieval context.

querystring required

Search query text.

Response

Retrieval results.

Changes