3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Difyチャットメッセージを送信するためのAPIリクエスト。

パラメータ 詳細
inputs Difyのアプリ側で定義した入力パラメータ(Key/Valueペア)
query ユーザーの入力/質問内容
response_mode 応答を返すモード。
Streaming : ストリーミング モード (推奨) は、SSE ( Server-Sent Events )を通じてタイプライターのような出力になる。
blocking : ブロッキングモード、実行完了後に結果を返します。
conversation_id 会話のID。以前のチャット記録に続けて会話するには、前のメッセージのIDを渡す
user ユーザーID(Dify側のログに記録される)
files ファイルをアップロード(なくても良い)
POST_Request
curl -X POST 'https://api.dify.ai/v1/chat-messages' \ 
--header 'Authorization: Bearer {api_key}' \ 
--header 'Content-Type: application/json' \ 
--data-raw '{ 
    "inputs": {}, 
    "query": "iPhone 13 Pro Maxの仕様は?", 
    "response_mode": "streaming", 
    "conversation_id": "", 
    "user": "abc-123", 
    "files": [ 
      { 
        "type": "image", 
        "transfer_method": "remote_url", 
        "url": "https://cloud.dify.ai/logo/logo-site.png" 
      } 
    ] 
}'
file_upload
curl -X POST 'https://api.dify.ai/v1/files/upload' \ 
--header 'Authorization: Bearer {api_key}' \ 
--form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif] \ 
--form 'user=abc-123'

メモ

・POSTで使用するURLはhttps://api.dify.ai/v1/chat-messagesを使う。
Pythonなどでは以下の形式を使うパターンもありましたが、上手くいかず...
WorkflowのIDを使う方法もありそう?
https://api.dify.ai/v1/
https://api.dify.ai/v1/completion-messages
https://api.dify.ai/v1/workflows/run

参考リンク集

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?