メインコンテンツへスキップ
POST
/
datasets
/
{dataset_id}
/
pipeline
/
run
curl --request POST \
  --url https://{api_base_url}/datasets/{dataset_id}/pipeline/run \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "inputs": {},
  "datasource_type": "local_file",
  "datasource_info_list": [
    {
      "reference": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "quarterly-report.pdf"
    }
  ],
  "start_node_id": "1719288585006",
  "is_published": true,
  "response_mode": "blocking"
}
'
"<string>"
{
"status": 400,
"code": "invalid_param",
"message": "Pipeline not found"
}
{
"status": 403,
"code": "forbidden",
"message": "Dataset api access is not enabled."
}
{
"status": 404,
"code": "not_found",
"message": "Dataset not found."
}
{
"status": 500,
"code": "pipeline_run_error",
"message": "Pipeline execution failed: connection timeout"
}

承認

Authorization
string
header
必須

すべてのリクエストは API キーで認証します:Authorization: Bearer {API_KEY}。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API キーを使用します(Dify API クイックスタート)。

キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーが欠落または無効なリクエストは HTTP 401unauthorized)で失敗します。

パスパラメータ

dataset_id
string<uuid>
必須

ナレッジベース ID です。ナレッジベースリストを取得 から取得します。

ボディ

application/json
inputs
object
必須

パイプライン入力変数のキーと値のペア。ワークフローで定義されたパイプライン変数に対応します。入力変数がない場合は {} を渡してください。

datasource_type
enum<string>
必須

データソースのタイプ。datasource_info_list の各項目に必要なフィールドを決定します。

利用可能なオプション:
local_file,
online_document,
website_crawl,
online_drive
datasource_info_list
(Local File · object | Online Document · object | Website Crawl · object | Online Drive · object)[]
必須

処理対象のデータソースオブジェクトのリストです。項目の構造は datasource_type によって異なります。

start_node_id
string
必須

実行を開始するノードの ID です。データソースプラグインリストを取得 から取得します。

is_published
boolean
必須

現在のドラフトではなくパイプラインの公開バージョンを実行するかどうかを指定します。未公開の変更をテストするにはドラフトを実行します。

response_mode
enum<string>
必須

パイプライン実行のレスポンスモードです。streaming は Server-Sent Events ストリームを返し、blocking は完了まで待機して完全な結果を返します。

利用可能なオプション:
streaming,
blocking

レスポンス

パイプライン実行結果。フォーマットは response_mode に依存します:ストリーミングは text/event-stream を返し、ブロッキングは完全な JSON 結果を返します。

Server-Sent Events ストリームです。response_modestreaming の場合に返されます。ワイヤーフォーマットについては ストリーミングレスポンスの処理 を参照してください。

主なイベント:

  • workflow_started:実行開始
  • node_started / node_finished:ノードごとの進捗(node_idnode_typestatusinputsoutputs を含む)
  • workflow_finished:最終結果(statusoutputstotal_tokenselapsed_time を含む)
  • ping:キープアライブ