Dify Knowledge Base Search
Dify dataset retrieve API for knowledge base chunk search/testing.
by tiangong-ai · MIT
The skill
Dify dataset retrieve API for knowledge base chunk search/testing. Use when integrating or debugging Dify knowledge base retrieval requests, retrieval_model options, or response shaping.
Dify Knowledge Base Search
Prepare required inputs
- Provide
dataas JSON containingqueryand optionalretrieval_model.top_k. - Read these env vars:
DIFY_API_BASE_URL: base API URL and include/v1(example:https://api.dify.ai/v1).DIFY_DATASET_ID: target dataset ID.DIFY_API_KEY: send asAuthorization: Bearer <DIFY_API_KEY>.
Send request
- Endpoint:
${DIFY_API_BASE_URL}/datasets/${DIFY_DATASET_ID}/retrieve - Headers:
Content-Type: application/jsonAuthorization: Bearer <DIFY_API_KEY>
- Use
assets/example-request.jsonas the payload template.
curl -sS --location --request POST "$DIFY_API_BASE_URL/datasets/$DIFY_DATASET_ID/retrieve" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DIFY_API_KEY" \
--data @assets/example-request.json
Interpret response
- Request shape:
{ "query": string, "retrieval_model"?: { "top_k": number } } - Success shape: 200 with
{ query, records: [...] } - If
recordsis empty, increaseretrieval_model.top_kmoderately and retry.
Troubleshoot quickly
- If auth fails, verify
DIFY_API_KEYandAuthorizationheader format. - If route fails, verify
DIFY_API_BASE_URLincludes/v1. - If results are low quality, refine
queryand tunetop_k.
References
references/env.mdreferences/request-response.mdreferences/testing.md
Assets
assets/example-request.json
Use this skill
Connect your agent to the Skill Store MCP server and ask for it by ref: tiangong-ai/dify-knowledge-base-search-36486936808.
Details
- Publisher
- tiangong-ai
- Category
- Software Development › APIs & backend
- License
- MIT
- Updated
- 2026-09-14
References
More from tiangong-ai
- Academic Paper Download Fetch and atomically save structurally and identity-verified academic-paper PDFs from legal open-…
- Ai Tech Fulltext Fetch Fetch and persist article full text for RSS entries already stored in SQLite by ai-tech-rss-fetch.
- Ai Tech Rss Fetch Subscribe to AI and tech RSS feeds and persist normalized metadata into SQLite using mature Pytho…
- Ai Tech Summary Retrieve time-windowed RSS evidence from SQLite and let the agent produce final summaries using R…