/datasets/{dataset_id}/retrieveRetrieve relevant chunks from a knowledge base
Retrieves the chunks most relevant to a query from a knowledge base for production or test retrieval. Supply query and retrieval_model to configure the search method, result limit, and optional reranking or score filtering.
- IdempotentThe SDK sends
Idempotency-Key, so a retried request is only applied once.
Retrieval query and settings. query and the search_method, reranking_enable, top_k, and score_threshold_enabled fields within retrieval_model are required.
6 documented failures
completion_request_errorCompletion request failed.
completion_request_error
dataset_not_initializedThe dataset is still being initialized or indexing. Please wait a moment.
dataset_not_initialized
invalid_paramInvalid parameter value.
invalid_param
model_currently_not_supportDify Hosted OpenAI trial currently not support the GPT-4 model.
model_currently_not_support
provider_not_initializeNo valid model provider credentials found. Please go to Settings -> Model Provider to complete your provider credentials.
provider_not_initialize
provider_quota_exceededYour quota for Dify Hosted Model Provider has been exhausted. Please go to Settings -> Model Provider to complete your own provider credentials.
provider_quota_exceeded
One documented failure
forbiddenDataset api access is not enabled.
forbidden (api access)
One documented failure
not_foundDataset not found.
not_found
One documented failure
internal_server_errorAn internal error occurred.
internal_server_error
A 400 is returned when a request parameter is invalid or retrieval fails because the knowledge base, provider, quota, or selected model is unavailable. A 403 is returned when API access is disabled, the request rate limit is reached, or the API key is not scoped to the knowledge base; a 404 is returned when no knowledge base matches the dataset_id path parameter, and a 500 indicates an internal retrieval error. The dataset_id path parameter must be a UUID; query is required and limited to 250 characters, and retrieval_model must include search_method, reranking_enable, top_k, and score_threshold_enabled; search_method must be keyword_search, semantic_search, full_text_search, or hybrid_search, and reranking_mode is required when reranking_enable is true.