リサーチタスク一覧を取得
呼び出し元の API キーについて、ナレッジベースが保持するリサーチタスクを新しい順に一覧表示します。
別のキーで作成されたタスクや、Dify から作成されたタスクは表示されません。
段階や日付によるフィルターはありません。実行中のタスクを追跡するには、リサーチタスクを作成 の各レスポンスの id を保存しておいてください。
計画、作成、ポーリング、結果の読み取りの流れについては、リサーチタスクの実行 を参照してください。
curl --request GET \
--url https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/research-tasks \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/research-tasks"
headers = {
"Authorization": "Bearer <token>",
}
response = requests.request("GET", url, headers=headers)
print(response.text)const response = await fetch('https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/research-tasks', {
method: 'GET',
headers: {
'Authorization': 'Bearer <token>'
}
});
const data = await response.json();
console.log(data);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/research-tasks',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <token>',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;package main
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/research-tasks"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/research-tasks"))
.header("Authorization", "Bearer <token>")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());require 'uri'
require 'net/http'
url = URI('https://api.dify.ai/v1/knowledge-fs/spaces/{knowledge_base_id}/research-tasks')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = url.scheme == 'https'
request = Net::HTTP::Get.new(url)
request['Authorization'] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"budget_usd": 1.5,
"completed_at": 1788681642000,
"cost": {
"budgetUsd": 1.5,
"entries": [
{
"costUsd": 0.0011,
"provider": "openai",
"recordedAt": 1788681603000,
"step": "research.plan",
"usage": {
"completionTokens": 58,
"estimated": false,
"promptTokens": 310,
"researchModelCallId": "attempt:1:call-1",
"reserved": false,
"status": "succeeded",
"totalTokens": 368
}
},
{
"costUsd": 0.0124,
"provider": "openai",
"recordedAt": 1788681641000,
"step": "query.answer",
"usage": {
"completionTokens": 412,
"estimated": false,
"promptTokens": 3180,
"researchModelCallId": "attempt:1:call-2",
"reserved": false,
"status": "succeeded",
"totalTokens": 3592
}
}
],
"totalUsd": 0.0135
},
"created_at": 1788681600000,
"error": null,
"failure": null,
"id": "e4d1b7a2-3c5f-4d8e-9a0b-1c2d3e4f5a6b",
"knowledge_space_id": "b2f1d3a4-5e6c-4a7b-8c9d-0e1f2a3b4c5d",
"limits": {
"max_retrieval_steps": 8,
"max_scanned_resources": 800,
"max_tool_calls": 12,
"timeout_ms": 120000
},
"metadata": {
"client_request_id": "client-20260907-0001",
"ticket": "SUP-1042"
},
"mode": "research",
"query": "What changed in the 2025 refund policy, and which regions are affected?",
"stage": "completed",
"top_k": 10,
"updated_at": 1788681642000
},
{
"budget_usd": null,
"completed_at": 1788678090000,
"cost": {
"entries": [
{
"costUsd": 0.0009,
"provider": "openai",
"recordedAt": 1788678003000,
"step": "graph.plan",
"usage": {
"completionTokens": 44,
"estimated": false,
"promptTokens": 260,
"researchModelCallId": "attempt:1:call-3",
"reserved": false,
"status": "succeeded",
"totalTokens": 304
}
}
],
"totalUsd": 0.0009
},
"created_at": 1788678000000,
"error": "RESEARCH_TASK_EXECUTION_ATTEMPTS_EXHAUSTED",
"failure": {
"action": "retry",
"category": "dependency",
"code": "RESEARCH_TASK_EXECUTION_ATTEMPTS_EXHAUSTED",
"message": "A service required by Agent Knowledge Base is temporarily unavailable.",
"parameters": null,
"retryPolicy": "manual",
"stage": "research",
"traceId": "0a9b8c7d-6e5f-4a4b-9c3d-2e1f0a9b8c7d"
},
"id": "0a9b8c7d-6e5f-4a4b-9c3d-2e1f0a9b8c7d",
"knowledge_space_id": "b2f1d3a4-5e6c-4a7b-8c9d-0e1f2a3b4c5d",
"limits": null,
"metadata": {},
"mode": "deep",
"query": "Which suppliers are named in the 2024 audit findings?",
"stage": "failed",
"top_k": 10,
"updated_at": 1788678090000
}
],
"next_cursor": null
}{
"code": "knowledge_fs_invalid_request",
"message": "Agent Knowledge Base request is invalid.",
"status": 400,
"violations": [
{
"field": [
"limit"
],
"type": "less_than_equal"
}
]
}{
"code": "knowledge_fs_invalid_credential",
"message": "Invalid Agent Knowledge Base service credential.",
"status": 401
}{
"code": "unauthorized",
"message": "Access token is invalid",
"status": 401
}{
"code": "forbidden",
"message": "Sorry, you have reached the knowledge base request rate limit of your subscription.",
"status": 403
}{
"code": "knowledge_fs_access_denied",
"message": "Agent Knowledge Base operation is not allowed.",
"status": 403
}{
"code": "knowledge_fs_resource_not_found",
"failure": {
"category": "not_found",
"code": "KNOWLEDGE_FS_NOT_FOUND",
"message": "The requested Agent Knowledge Base resource was not found.",
"retryPolicy": "never",
"traceId": "8f3a2c14-9d6b-4c07-b5a1-2e7d0c93f5b2"
},
"message": "The requested Agent Knowledge Base resource was not found.",
"status": 404
}{
"code": "not_found",
"message": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
"status": 404
}{
"code": "knowledge_fs_upstream_unavailable",
"failure": {
"action": "contact_admin",
"category": "internal",
"code": "KNOWLEDGE_FS_INTERNAL_ERROR",
"message": "Agent Knowledge Base could not complete the operation. Try again, or contact an administrator with the error reference.",
"retryPolicy": "manual",
"traceId": "5e2a9c17-3b4d-4f60-8a1b-2c3d4e5f6a7b"
},
"message": "Agent Knowledge Base could not complete the operation. Try again, or contact an administrator with the error reference.",
"status": 502
}{
"code": "knowledge_fs_upstream_unavailable",
"message": "Agent Knowledge Base is unavailable.",
"status": 502
}{
"code": "knowledge_fs_operation_unavailable",
"message": "Agent Knowledge Base operation is not available.",
"status": 503
}{
"code": "knowledge_fs_operation_unavailable",
"failure": {
"action": "retry",
"category": "dependency",
"code": "KNOWLEDGE_FS_UNAVAILABLE",
"message": "A service required by Agent Knowledge Base is temporarily unavailable.",
"retryPolicy": "manual",
"traceId": "5e2a9c17-3b4d-4f60-8a1b-2c3d4e5f6a7b"
},
"message": "A service required by Agent Knowledge Base is temporarily unavailable.",
"status": 503
}Authorization
すべてのリクエストは API キーで認証します:Authorization: Bearer {API_KEY}。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API キーを使用します(Dify API クイックスタート)。
キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーが欠落または無効なリクエストは HTTP 401(unauthorized)で失敗します。
Path parameters
…/knowledge-fs/spaces/<knowledge base ID>)です。アドレスバーでは /datasets/new/ の後のセグメントです。Query parameters
Responses
Show child attributesHide child attributes
null です。completed、failed、canceled のいずれかに達した日時(エポックミリ秒)です。タスクの実行中は null です。Show child attributesHide child attributes
budgetUsd を超え、それを理由にタスクがキャンセルされた場合は true です。それ以外の場合は含まれません。budgetUsd です。予算が設定されていない場合は含まれません。Show child attributesHide child attributes
pageindex.layer、pageindex.semantic、pageindex.whole-tree、research.judge、research.plan、graph.plan、query.answer、query.image-expand のいずれかです。promptTokens、completionTokens、totalTokens、estimated、reserved、status(reserved、succeeded、failed のいずれか)、researchModelCallId を含みます。実行中の呼び出しの予約もエントリとして記録され、totalUsd に計上されます。entries[].costUsd の合計(USD)です。最初のモデル呼び出しが記録されるまでは 0 です。失敗コードで、failure.code と同じ値です。stage が failed の場合にのみ設定され、それ以外の場合は、キャンセルされたタスクも含めて null です。
失敗したリサーチタスクでは、failure.code は RESEARCH_TASK_CAPABILITY_REVOKED、RESEARCH_TASK_DISPATCH_DEAD、RESEARCH_TASK_EXECUTION_ATTEMPTS_EXHAUSTED、RESEARCH_TASK_FAILED、RESEARCH_TASK_PERMISSION_SNAPSHOT_INVALID、RESEARCH_TASK_RUNTIME_SNAPSHOT_INVALID のいずれかです。
エラー詳細です。stage が failed の場合にのみ設定され、それ以外の場合は null です。ここでは、値のないメンバーは null になります。traceId はタスク ID です。
action が retry の場合は、リサーチタスクを作成 で新しいタスクを作成してください。
Show child attributesHide child attributes
configure_model、configure_parser、configure_source、contact_admin、reupload、retry のいずれかです。該当しない場合は null です。authorization、canceled、configuration、conflict、dependency、internal、not_found、rate_limit、timeout、validation のいずれかです。error と一致します。attempt、currentRowVersion、documentCount、expectedRowVersion、fileSizeBytes、limit、maxFileSizeBytes、maxItems、modelType、providerKind、retryAfterSeconds、status のいずれかです。値がない場合は null です。automatic(サービスが自動で再試行)、manual(呼び出し側で再試行)、after_configuration(先に Dify でナレッジベースの設定を修正)、never(リクエストを変更)のいずれかです。research です。research_task_id として使用します。limits が含まれていなかった場合は null です。送信されなかったメンバーは null になります。リサーチタスクを作成 に再度送信する前に、キーをキャメルケースに戻してください。metadata オブジェクトです。__knowledgeFs で始まるキーは除かれます。fast、deep、research のいずれかです。ライフサイクル上でのタスクの現在位置です。タスクは 1 段階ずつ進みます:
queued:受け付け済みで、ワーカーを待っています。planning:検索計画を決定しています。retrieving:ナレッジベースを検索しています。検索のチェックポイントが書き込まれることがあります。analyzing:検索されたチャンクを読み、評価しています。generating:回答を作成しています。最終結果はこの段階で書き込まれます。completed:完了しました。結果は リサーチタスクの結果一覧を取得 で取得します。failed:エラーで停止しました。errorとfailureを参照してください。canceled:リサーチタスクをキャンセル または予算によって停止しました。paused:タスクは一時停止中です。失敗の詳細をデプロイ環境の運用担当者に確認するか、タスクをキャンセルしてください。
completed、failed、canceled は最終状態です。
topK、または省略時はナレッジベースの トップ K の値です。null です。cursor として送り返してください。