template_advanced_chat.en.mdx 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158
  1. import { CodeGroup } from '../code.tsx'
  2. import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from '../md.tsx'
  3. # Advanced Chat App API
  4. Chat applications support session persistence, allowing previous chat history to be used as context for responses. This can be applicable for chatbot, customer service AI, etc.
  5. <div>
  6. ### Base URL
  7. <CodeGroup title="Code" targetCode={props.appDetail.api_base_url}>
  8. ```javascript
  9. ```
  10. </CodeGroup>
  11. ### Authentication
  12. The Service API uses `API-Key` authentication.
  13. <i>**Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.**</i>
  14. For all API requests, include your API Key in the `Authorization`HTTP Header, as shown below:
  15. <CodeGroup title="Code">
  16. ```javascript
  17. Authorization: Bearer {API_KEY}
  18. ```
  19. </CodeGroup>
  20. </div>
  21. ---
  22. <Heading
  23. url='/chat-messages'
  24. method='POST'
  25. title='Send Chat Message'
  26. name='#Send-Chat-Message'
  27. />
  28. <Row>
  29. <Col>
  30. Send a request to the chat application.
  31. ### Request Body
  32. <Properties>
  33. <Property name='query' type='string' key='query'>
  34. User Input/Question content
  35. </Property>
  36. <Property name='inputs' type='object' key='inputs'>
  37. Allows the entry of various variable values defined by the App.
  38. The `inputs` parameter contains multiple key/value pairs, with each key corresponding to a specific variable and each value being the specific value for that variable.
  39. If the variable is of file type, specify an object that has the keys described in `files` below.
  40. Default `{}`
  41. </Property>
  42. <Property name='response_mode' type='string' key='response_mode'>
  43. The mode of response return, supporting:
  44. - `streaming` Streaming mode (recommended), implements a typewriter-like output through SSE ([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)).
  45. - `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)
  46. Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.
  47. </Property>
  48. <Property name='user' type='string' key='user'>
  49. User identifier, used to define the identity of the end-user for retrieval and statistics.
  50. Should be uniquely defined by the developer within the application.
  51. </Property>
  52. <Property name='conversation_id' type='string' key='conversation_id'>
  53. Conversation ID, to continue the conversation based on previous chat records, it is necessary to pass the previous message's conversation_id.
  54. </Property>
  55. <Property name='files' type='array[object]' key='files'>
  56. File list, suitable for inputting files combined with text understanding and answering questions, available only when the model supports Vision capability.
  57. - `type` (string) Supported type:
  58. - `document` ('TXT', 'MD', 'MARKDOWN', 'PDF', 'HTML', 'XLSX', 'XLS', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB')
  59. - `image` ('JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG')
  60. - `audio` ('MP3', 'M4A', 'WAV', 'WEBM', 'AMR')
  61. - `video` ('MP4', 'MOV', 'MPEG', 'MPGA')
  62. - `transfer_method` (string) Transfer method, `remote_url` for image URL / `local_file` for file upload
  63. - `url` (string) Image URL (when the transfer method is `remote_url`)
  64. - `upload_file_id` (string) Uploaded file ID, which must be obtained by uploading through the File Upload API in advance (when the transfer method is `local_file`)
  65. </Property>
  66. <Property name='auto_generate_name' type='bool' key='auto_generate_name'>
  67. Auto-generate title, default is `true`.
  68. If set to `false`, can achieve async title generation by calling the conversation rename API and setting `auto_generate` to `true`.
  69. </Property>
  70. </Properties>
  71. ### Response
  72. When response_mode is blocking, return a CompletionResponse object.
  73. When response_mode is streaming, return a ChunkCompletionResponse stream.
  74. ### ChatCompletionResponse
  75. Returns the complete App result, `Content-Type` is `application/json`.
  76. - `message_id` (string) Unique message ID
  77. - `conversation_id` (string) Conversation ID
  78. - `mode` (string) App mode, fixed as `chat`
  79. - `answer` (string) Complete response content
  80. - `metadata` (object) Metadata
  81. - `usage` (Usage) Model usage information
  82. - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List
  83. - `created_at` (int) Message creation timestamp, e.g., 1705395332
  84. ### ChunkChatCompletionResponse
  85. Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.
  86. Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:
  87. <CodeGroup>
  88. ```streaming {{ title: 'Response' }}
  89. data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n
  90. ```
  91. </CodeGroup>
  92. The structure of the streaming chunks varies depending on the `event`:
  93. - `event: message` LLM returns text chunk event, i.e., the complete text is output in a chunked fashion.
  94. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  95. - `message_id` (string) Unique message ID
  96. - `conversation_id` (string) Conversation ID
  97. - `answer` (string) LLM returned text chunk content
  98. - `created_at` (int) Creation timestamp, e.g., 1705395332
  99. - `event: message_file` Message file event, a new file has created by tool
  100. - `id` (string) File unique ID
  101. - `type` (string) File type,only allow "image" currently
  102. - `belongs_to` (string) Belongs to, it will only be an 'assistant' here
  103. - `url` (string) Remote url of file
  104. - `conversation_id` (string) Conversation ID
  105. - `event: message_end` Message end event, receiving this event means streaming has ended.
  106. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  107. - `message_id` (string) Unique message ID
  108. - `conversation_id` (string) Conversation ID
  109. - `metadata` (object) Metadata
  110. - `usage` (Usage) Model usage information
  111. - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List
  112. - `event: tts_message` TTS audio stream event, that is, speech synthesis output. The content is an audio block in Mp3 format, encoded as a base64 string. When playing, simply decode the base64 and feed it into the player. (This message is available only when auto-play is enabled)
  113. - `task_id` (string) Task ID, used for request tracking and the stop response interface below
  114. - `message_id` (string) Unique message ID
  115. - `audio` (string) The audio after speech synthesis, encoded in base64 text content, when playing, simply decode the base64 and feed it into the player
  116. - `created_at` (int) Creation timestamp, e.g.: 1705395332
  117. - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of the audio stream.
  118. - `task_id` (string) Task ID, used for request tracking and the stop response interface below
  119. - `message_id` (string) Unique message ID
  120. - `audio` (string) The end event has no audio, so this is an empty string
  121. - `created_at` (int) Creation timestamp, e.g.: 1705395332
  122. - `event: message_replace` Message content replacement event.
  123. When output content moderation is enabled, if the content is flagged, then the message content will be replaced with a preset reply through this event.
  124. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  125. - `message_id` (string) Unique message ID
  126. - `conversation_id` (string) Conversation ID
  127. - `answer` (string) Replacement content (directly replaces all LLM reply text)
  128. - `created_at` (int) Creation timestamp, e.g., 1705395332
  129. - `event: workflow_started` workflow starts execution
  130. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  131. - `workflow_run_id` (string) Unique ID of workflow execution
  132. - `event` (string) fixed to `workflow_started`
  133. - `data` (object) detail
  134. - `id` (string) Unique ID of workflow execution
  135. - `workflow_id` (string) ID of related workflow
  136. - `sequence_number` (int) Self-increasing serial number, self-increasing in the App, starting from 1
  137. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  138. - `event: node_started` node execution started
  139. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  140. - `workflow_run_id` (string) Unique ID of workflow execution
  141. - `event` (string) fixed to `node_started`
  142. - `data` (object) detail
  143. - `id` (string) Unique ID of workflow execution
  144. - `node_id` (string) ID of node
  145. - `node_type` (string) type of node
  146. - `title` (string) name of node
  147. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  148. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  149. - `inputs` (object) Contents of all preceding node variables used in the node
  150. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  151. - `event: node_finished` node execution ends, success or failure in different states in the same event
  152. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  153. - `workflow_run_id` (string) Unique ID of workflow execution
  154. - `event` (string) fixed to `node_finished`
  155. - `data` (object) detail
  156. - `id` (string) Unique ID of workflow execution
  157. - `node_id` (string) ID of node
  158. - `node_type` (string) type of node
  159. - `title` (string) name of node
  160. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  161. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  162. - `inputs` (object) Contents of all preceding node variables used in the node
  163. - `process_data` (json) Optional node process data
  164. - `outputs` (json) Optional content of output
  165. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  166. - `error` (string) Optional reason of error
  167. - `elapsed_time` (float) Optional total seconds to be used
  168. - `execution_metadata` (json) meta data
  169. - `total_tokens` (int) optional tokens to be used
  170. - `total_price` (decimal) optional Total cost
  171. - `currency` (string) optional e.g. `USD` / `RMB`
  172. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  173. - `event: workflow_finished` workflow execution ends, success or failure in different states in the same event
  174. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  175. - `workflow_run_id` (string) Unique ID of workflow execution
  176. - `event` (string) fixed to `workflow_finished`
  177. - `data` (object) detail
  178. - `id` (string) ID of workflow execution
  179. - `workflow_id` (string) ID of related workflow
  180. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  181. - `outputs` (json) Optional content of output
  182. - `error` (string) Optional reason of error
  183. - `elapsed_time` (float) Optional total seconds to be used
  184. - `total_tokens` (int) Optional tokens to be used
  185. - `total_steps` (int) default 0
  186. - `created_at` (timestamp) start time
  187. - `finished_at` (timestamp) end time
  188. - `event: error`
  189. Exceptions that occur during the streaming process will be output in the form of stream events, and reception of an error event will end the stream.
  190. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  191. - `message_id` (string) Unique message ID
  192. - `status` (int) HTTP status code
  193. - `code` (string) Error code
  194. - `message` (string) Error message
  195. - `event: ping` Ping event every 10 seconds to keep the connection alive.
  196. ### Errors
  197. - 404, Conversation does not exists
  198. - 400, `invalid_param`, abnormal parameter input
  199. - 400, `app_unavailable`, App configuration unavailable
  200. - 400, `provider_not_initialize`, no available model credential configuration
  201. - 400, `provider_quota_exceeded`, model invocation quota insufficient
  202. - 400, `model_currently_not_support`, current model unavailable
  203. - 400, `completion_request_error`, text generation failed
  204. - 500, internal server error
  205. </Col>
  206. <Col sticky>
  207. <CodeGroup title="Request" tag="POST" label="/chat-messages" targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n "inputs": ${JSON.stringify(props.inputs)},\n "query": "What are the specs of the iPhone 13 Pro Max?",\n "response_mode": "streaming",\n "conversation_id": "",\n "user": "abc-123",\n "files": [\n {\n "type": "image",\n "transfer_method": "remote_url",\n "url": "https://cloud.dify.ai/logo/logo-site.png"\n }\n ]\n}'`}>
  208. ```bash {{ title: 'cURL' }}
  209. curl -X POST '${props.appDetail.api_base_url}/chat-messages' \
  210. --header 'Authorization: Bearer {api_key}' \
  211. --header 'Content-Type: application/json' \
  212. --data-raw '{
  213. "inputs": {},
  214. "query": "eh",
  215. "response_mode": "streaming",
  216. "conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276",
  217. "user": "abc-123"
  218. }'
  219. ```
  220. </CodeGroup>
  221. ### Blocking Mode
  222. <CodeGroup title="Response">
  223. ```json {{ title: 'Response' }}
  224. {
  225. "event": "message",
  226. "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",
  227. "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2",
  228. "mode": "chat",
  229. "answer": "iPhone 13 Pro Max specs are listed here:...",
  230. "metadata": {
  231. "usage": {
  232. "prompt_tokens": 1033,
  233. "prompt_unit_price": "0.001",
  234. "prompt_price_unit": "0.001",
  235. "prompt_price": "0.0010330",
  236. "completion_tokens": 128,
  237. "completion_unit_price": "0.002",
  238. "completion_price_unit": "0.001",
  239. "completion_price": "0.0002560",
  240. "total_tokens": 1161,
  241. "total_price": "0.0012890",
  242. "currency": "USD",
  243. "latency": 0.7682376249867957
  244. },
  245. "retriever_resources": [
  246. {
  247. "position": 1,
  248. "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  249. "dataset_name": "iPhone",
  250. "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",
  251. "document_name": "iPhone List",
  252. "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",
  253. "score": 0.98457545,
  254. "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""
  255. }
  256. ]
  257. },
  258. "created_at": 1705407629
  259. }
  260. ```
  261. </CodeGroup>
  262. ### Streaming Mode
  263. <CodeGroup title="Response">
  264. ```streaming {{ title: 'Response' }}
  265. data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "sequence_number": 1, "created_at": 1679586595}}
  266. data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}
  267. data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}
  268. data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}
  269. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}
  270. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}
  271. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}
  272. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}
  273. data: {"event": "message", "message_id": : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}
  274. data: {"event": "message", "message_id": : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}
  275. data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}, "retriever_resources": [{"position": 1, "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", "dataset_name": "iPhone", "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00", "document_name": "iPhone List", "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a", "score": 0.98457545, "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""}]}}
  276. data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}
  277. data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}
  278. ```
  279. </CodeGroup>
  280. </Col>
  281. </Row>
  282. ---
  283. <Heading
  284. url='/files/upload'
  285. method='POST'
  286. title='File Upload'
  287. name='#file-upload'
  288. />
  289. <Row>
  290. <Col>
  291. Upload a file for use when sending messages, enabling multimodal understanding of images and text.
  292. Supports any formats that are supported by your application.
  293. Uploaded files are for use by the current end-user only.
  294. ### Request Body
  295. This interface requires a `multipart/form-data` request.
  296. - `file` (File) Required
  297. The file to be uploaded.
  298. - `user` (string) Required
  299. User identifier, defined by the developer's rules, must be unique within the application.
  300. ### Response
  301. After a successful upload, the server will return the file's ID and related information.
  302. - `id` (uuid) ID
  303. - `name` (string) File name
  304. - `size` (int) File size (bytes)
  305. - `extension` (string) File extension
  306. - `mime_type` (string) File mime-type
  307. - `created_by` (uuid) End-user ID
  308. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  309. ### Errors
  310. - 400, `no_file_uploaded`, a file must be provided
  311. - 400, `too_many_files`, currently only one file is accepted
  312. - 400, `unsupported_preview`, the file does not support preview
  313. - 400, `unsupported_estimate`, the file does not support estimation
  314. - 413, `file_too_large`, the file is too large
  315. - 415, `unsupported_file_type`, unsupported extension, currently only document files are accepted
  316. - 503, `s3_connection_failed`, unable to connect to S3 service
  317. - 503, `s3_permission_denied`, no permission to upload files to S3
  318. - 503, `s3_file_too_large`, file exceeds S3 size limit
  319. - 500, internal server error
  320. </Col>
  321. <Col sticky>
  322. ### Request Example
  323. <CodeGroup title="Request" tag="POST" label="/files/upload" targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\\n--header 'Authorization: Bearer {api_key}' \\\n--form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif] \\\n--form 'user=abc-123'`}>
  324. ```bash {{ title: 'cURL' }}
  325. curl -X POST '${props.appDetail.api_base_url}/files/upload' \
  326. --header 'Authorization: Bearer {api_key}' \
  327. --form 'file=@"/path/to/file"'
  328. ```
  329. </CodeGroup>
  330. ### Response Example
  331. <CodeGroup title="Response">
  332. ```json {{ title: 'Response' }}
  333. {
  334. "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
  335. "name": "example.png",
  336. "size": 1024,
  337. "extension": "png",
  338. "mime_type": "image/png",
  339. "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",
  340. "created_at": 1577836800,
  341. }
  342. ```
  343. </CodeGroup>
  344. </Col>
  345. </Row>
  346. ---
  347. <Heading
  348. url='/chat-messages/:task_id/stop'
  349. method='POST'
  350. title='Stop Generate'
  351. name='#stop-generatebacks'
  352. />
  353. <Row>
  354. <Col>
  355. Only supported in streaming mode.
  356. ### Path
  357. - `task_id` (string) Task ID, can be obtained from the streaming chunk return
  358. ### Request Body
  359. - `user` (string) Required
  360. User identifier, used to define the identity of the end-user, must be consistent with the user passed in the send message interface.
  361. ### Response
  362. - `result` (string) Always returns "success"
  363. </Col>
  364. <Col sticky>
  365. ### Request Example
  366. <CodeGroup title="Request" tag="POST" label="/chat-messages/:task_id/stop" targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \\\n-H 'Authorization: Bearer {api_key}' \\\n-H 'Content-Type: application/json' \\\n--data-raw '{"user": "abc-123"}'`}>
  367. ```bash {{ title: 'cURL' }}
  368. curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \
  369. -H 'Authorization: Bearer {api_key}' \
  370. -H 'Content-Type: application/json' \
  371. --data-raw '{
  372. "user": "abc-123"
  373. }'
  374. ```
  375. </CodeGroup>
  376. ### Response Example
  377. <CodeGroup title="Response">
  378. ```json {{ title: 'Response' }}
  379. {
  380. "result": "success"
  381. }
  382. ```
  383. </CodeGroup>
  384. </Col>
  385. </Row>
  386. ---
  387. <Heading
  388. url='/messages/:message_id/feedbacks'
  389. method='POST'
  390. title='Message Feedback'
  391. name='#feedbacks'
  392. />
  393. <Row>
  394. <Col>
  395. End-users can provide feedback messages, facilitating application developers to optimize expected outputs.
  396. ### Path
  397. <Properties>
  398. <Property name='message_id' type='string' key='message_id'>
  399. Message ID
  400. </Property>
  401. </Properties>
  402. ### Request Body
  403. <Properties>
  404. <Property name='rating' type='string' key='rating'>
  405. Upvote as `like`, downvote as `dislike`, revoke upvote as `null`
  406. </Property>
  407. <Property name='user' type='string' key='user'>
  408. User identifier, defined by the developer's rules, must be unique within the application.
  409. </Property>
  410. <Property name='content' type='string' key='content'>
  411. The specific content of message feedback.
  412. </Property>
  413. </Properties>
  414. ### Response
  415. - `result` (string) Always returns "success"
  416. </Col>
  417. <Col sticky>
  418. <CodeGroup title="Request" tag="POST" label="/messages/:message_id/feedbacks" targetCode={`curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks \\\n --header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n "rating": "like",\n "user": "abc-123",\n "content": "message feedback information"\n}'`}>
  419. ```bash {{ title: 'cURL' }}
  420. curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks' \
  421. --header 'Authorization: Bearer {api_key}' \
  422. --header 'Content-Type: application/json' \
  423. --data-raw '{
  424. "rating": "like",
  425. "user": "abc-123",
  426. "content": "message feedback information"
  427. }'
  428. ```
  429. </CodeGroup>
  430. <CodeGroup title="Response">
  431. ```json {{ title: 'Response' }}
  432. {
  433. "result": "success"
  434. }
  435. ```
  436. </CodeGroup>
  437. </Col>
  438. </Row>
  439. ---
  440. <Heading
  441. url='/messages/{message_id}/suggested'
  442. method='GET'
  443. title='Next Suggested Questions'
  444. name='#suggested'
  445. />
  446. <Row>
  447. <Col>
  448. Get next questions suggestions for the current message
  449. ### Path Params
  450. <Properties>
  451. <Property name='message_id' type='string' key='message_id'>
  452. Message ID
  453. </Property>
  454. </Properties>
  455. ### Query
  456. <Properties>
  457. <Property name='user' type='string' key='user'>
  458. User identifier, used to define the identity of the end-user for retrieval and statistics.
  459. Should be uniquely defined by the developer within the application.
  460. </Property>
  461. </Properties>
  462. </Col>
  463. <Col sticky>
  464. <CodeGroup title="Request" tag="GET" label="/messages/{message_id}/suggested" targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123& \\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--header 'Content-Type: application/json'`}>
  465. ```bash {{ title: 'cURL' }}
  466. curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123' \
  467. --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
  468. --header 'Content-Type: application/json' \
  469. ```
  470. </CodeGroup>
  471. <CodeGroup title="Response">
  472. ```json {{ title: 'Response' }}
  473. {
  474. "result": "success",
  475. "data": [
  476. "a",
  477. "b",
  478. "c"
  479. ]
  480. }
  481. ```
  482. </CodeGroup>
  483. </Col>
  484. </Row>
  485. ---
  486. <Heading
  487. url='/messages'
  488. method='GET'
  489. title='Get Conversation History Messages'
  490. name='#messages'
  491. />
  492. <Row>
  493. <Col>
  494. Returns historical chat records in a scrolling load format, with the first page returning the latest `{limit}` messages, i.e., in reverse order.
  495. ### Query
  496. <Properties>
  497. <Property name='conversation_id' type='string' key='conversation_id'>
  498. Conversation ID
  499. </Property>
  500. <Property name='user' type='string' key='user'>
  501. User identifier, used to define the identity of the end-user for retrieval and statistics.
  502. Should be uniquely defined by the developer within the application.
  503. </Property>
  504. <Property name='first_id' type='string' key='first_id'>
  505. The ID of the first chat record on the current page, default is null.
  506. </Property>
  507. <Property name='limit' type='int' key='limit'>
  508. How many chat history messages to return in one request, default is 20.
  509. </Property>
  510. </Properties>
  511. ### Response
  512. - `data` (array[object]) Message list
  513. - `id` (string) Message ID
  514. - `conversation_id` (string) Conversation ID
  515. - `inputs` (object) User input parameters.
  516. - `query` (string) User input / question content.
  517. - `message_files` (array[object]) Message files
  518. - `id` (string) ID
  519. - `type` (string) File type, image for images
  520. - `url` (string) Preview image URL
  521. - `belongs_to` (string) belongs to,user orassistant
  522. - `answer` (string) Response message content
  523. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  524. - `feedback` (object) Feedback information
  525. - `rating` (string) Upvote as `like` / Downvote as `dislike`
  526. - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List
  527. - `has_more` (bool) Whether there is a next page
  528. - `limit` (int) Number of returned items, if input exceeds system limit, returns system limit amount
  529. </Col>
  530. <Col sticky>
  531. <CodeGroup title="Request" tag="GET" label="/messages" targetCode={`curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id='\\\n --header 'Authorization: Bearer {api_key}'`}>
  532. ```bash {{ title: 'cURL' }}
  533. curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id='
  534. --header 'Authorization: Bearer {api_key}'
  535. ```
  536. </CodeGroup>
  537. ### Response Example
  538. <CodeGroup title="Response">
  539. ```json {{ title: 'Response' }}
  540. {
  541. "limit": 20,
  542. "has_more": false,
  543. "data": [
  544. {
  545. "id": "a076a87f-31e5-48dc-b452-0061adbbc922",
  546. "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  547. "inputs": {
  548. "name": "dify"
  549. },
  550. "query": "iphone 13 pro",
  551. "answer": "The iPhone 13 Pro, released on September 24, 2021, features a 6.1-inch display with a resolution of 1170 x 2532. It is equipped with a Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard) processor, 6 GB of RAM, and offers storage options of 128 GB, 256 GB, 512 GB, and 1 TB. The camera is 12 MP, the battery capacity is 3095 mAh, and it runs on iOS 15.",
  552. "message_files": [],
  553. "feedback": null,
  554. "retriever_resources": [
  555. {
  556. "position": 1,
  557. "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  558. "dataset_name": "iPhone",
  559. "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",
  560. "document_name": "iPhone List",
  561. "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",
  562. "score": 0.98457545,
  563. "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""
  564. }
  565. ],
  566. "created_at": 1705569239,
  567. }
  568. ]
  569. }
  570. ```
  571. </CodeGroup>
  572. </Col>
  573. </Row>
  574. ---
  575. <Heading
  576. url='/conversations'
  577. method='GET'
  578. title='Get Conversations'
  579. name='#conversations'
  580. />
  581. <Row>
  582. <Col>
  583. Retrieve the conversation list for the current user, defaulting to the most recent 20 entries.
  584. ### Query
  585. <Properties>
  586. <Property name='user' type='string' key='user'>
  587. User identifier, used to define the identity of the end-user for retrieval and statistics.
  588. Should be uniquely defined by the developer within the application.
  589. </Property>
  590. <Property name='last_id' type='string' key='last_id'>
  591. (Optional) The ID of the last record on the current page, default is null.
  592. </Property>
  593. <Property name='limit' type='int' key='limit'>
  594. (Optional) How many records to return in one request, default is the most recent 20 entries. Maximum 100, minimum 1.
  595. </Property>
  596. <Property name='sort_by' type='string' key='sort_by'>
  597. (Optional) Sorting Field, Default: -updated_at (sorted in descending order by update time)
  598. - Available Values: created_at, -created_at, updated_at, -updated_at
  599. - The symbol before the field represents the order or reverse, "-" represents reverse order.
  600. </Property>
  601. </Properties>
  602. ### Response
  603. - `data` (array[object]) List of conversations
  604. - `id` (string) Conversation ID
  605. - `name` (string) Conversation name, by default, is generated by LLM.
  606. - `inputs` (object) User input parameters.
  607. - `status` (string) Conversation status
  608. - `introduction` (string) Introduction
  609. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  610. - `updated_at` (timestamp) Update timestamp, e.g., 1705395332
  611. - `has_more` (bool)
  612. - `limit` (int) Number of entries returned, if input exceeds system limit, system limit number is returned
  613. </Col>
  614. <Col sticky>
  615. <CodeGroup title="Request" tag="GET" label="/conversations" targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \\\n --header 'Authorization: Bearer {api_key}'`}>
  616. ```bash {{ title: 'cURL' }}
  617. curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \
  618. --header 'Authorization: Bearer {api_key}'
  619. ```
  620. </CodeGroup>
  621. <CodeGroup title="Response">
  622. ```json {{ title: 'Response' }}
  623. {
  624. "limit": 20,
  625. "has_more": false,
  626. "data": [
  627. {
  628. "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",
  629. "name": "New chat",
  630. "inputs": {
  631. "book": "book",
  632. "myName": "Lucy"
  633. },
  634. "status": "normal",
  635. "created_at": 1679667915,
  636. "updated_at": 1679667915
  637. },
  638. {
  639. "id": "hSIhXBhNe8X1d8Et"
  640. // ...
  641. }
  642. ]
  643. }
  644. ```
  645. </CodeGroup>
  646. </Col>
  647. </Row>
  648. ---
  649. <Heading
  650. url='/conversations/:conversation_id'
  651. method='DELETE'
  652. title='Delete Conversation'
  653. name='#delete'
  654. />
  655. <Row>
  656. <Col>
  657. Delete a conversation.
  658. ### Path
  659. - `conversation_id` (string) Conversation ID
  660. ### Request Body
  661. <Properties>
  662. <Property name='user' type='string' key='user'>
  663. The user identifier, defined by the developer, must ensure uniqueness within the application.
  664. </Property>
  665. </Properties>
  666. ### Response
  667. - `result` (string) Always returns "success"
  668. </Col>
  669. <Col sticky>
  670. <CodeGroup title="Request" tag="DELETE" label="/conversations/:conversation_id" targetCode={`curl -X DELETE '${props.appDetail.api_base_url}/conversations/:conversation_id' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{ \n "user": "abc-123"\n}'`}>
  671. ```bash {{ title: 'cURL' }}
  672. curl -X DELETE '${props.appDetail.api_base_url}/conversations/{conversation_id}' \
  673. --header 'Content-Type: application/json' \
  674. --header 'Accept: application/json' \
  675. --header 'Authorization: Bearer {api_key}' \
  676. --data '{
  677. "user": "abc-123"
  678. }'
  679. ```
  680. </CodeGroup>
  681. <CodeGroup title="Response">
  682. ```json {{ title: 'Response' }}
  683. {
  684. "result": "success"
  685. }
  686. ```
  687. </CodeGroup>
  688. </Col>
  689. </Row>
  690. ---
  691. <Heading
  692. url='/conversations/:conversation_id/name'
  693. method='POST'
  694. title='Conversation Rename'
  695. name='#rename'
  696. />
  697. <Row>
  698. <Col>
  699. ### Request Body
  700. Rename the session, the session name is used for display on clients that support multiple sessions.
  701. ### Path
  702. - `conversation_id` (string) Conversation ID
  703. <Properties>
  704. <Property name='name' type='string' key='name'>
  705. (Optional) The name of the conversation. This parameter can be omitted if `auto_generate` is set to `true`.
  706. </Property>
  707. <Property name='auto_generate' type='bool' key='auto_generate'>
  708. (Optional) Automatically generate the title, default is `false`
  709. </Property>
  710. <Property name='user' type='string' key='user'>
  711. The user identifier, defined by the developer, must ensure uniqueness within the application.
  712. </Property>
  713. </Properties>
  714. ### Response
  715. - `id` (string) Conversation ID
  716. - `name` (string) Conversation name
  717. - `inputs` (object) User input parameters
  718. - `status` (string) Conversation status
  719. - `introduction` (string) Introduction
  720. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  721. - `updated_at` (timestamp) Update timestamp, e.g., 1705395332
  722. </Col>
  723. <Col sticky>
  724. <CodeGroup title="Request" tag="POST" label="/conversations/:conversation_id/name" targetCode={`curl -X POST '${props.appDetail.api_base_url}/conversations/:conversation_id/name' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{ \n "name": "", \n "auto_generate": true, \n "user": "abc-123"\n}'`}>
  725. ```bash {{ title: 'cURL' }}
  726. curl -X POST '${props.appDetail.api_base_url}/conversations/{conversation_id}/name' \
  727. --header 'Content-Type: application/json' \
  728. --header 'Authorization: Bearer {api_key}' \
  729. --data-raw '{
  730. "name": "",
  731. "auto_generate": true,
  732. "user": "abc-123"
  733. }'
  734. ```
  735. </CodeGroup>
  736. <CodeGroup title="Response">
  737. ```json {{ title: 'Response' }}
  738. {
  739. "id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  740. "name": "Chat vs AI",
  741. "inputs": {},
  742. "status": "normal",
  743. "introduction": "",
  744. "created_at": 1705569238,
  745. "updated_at": 1705569238
  746. }
  747. ```
  748. </CodeGroup>
  749. </Col>
  750. </Row>
  751. ---
  752. <Heading
  753. url='/audio-to-text'
  754. method='POST'
  755. title='Speech to Text'
  756. name='#audio'
  757. />
  758. <Row>
  759. <Col>
  760. This endpoint requires a multipart/form-data request.
  761. ### Request Body
  762. <Properties>
  763. <Property name='file' type='file' key='file'>
  764. Audio file.
  765. Supported formats: `['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`
  766. File size limit: 15MB
  767. </Property>
  768. <Property name='user' type='string' key='user'>
  769. User identifier, defined by the developer's rules, must be unique within the application.
  770. </Property>
  771. </Properties>
  772. ### Response
  773. - `text` (string) Output text
  774. </Col>
  775. <Col sticky>
  776. <CodeGroup title="Request" tag="POST" label="/audio-to-text" targetCode={`curl -X POST '${props.appDetail.api_base_url}/audio-to-text' \\\n--header 'Authorization: Bearer {api_key}' \\\n--form 'file=@localfile;type=audio/[mp3|mp4|mpeg|mpga|m4a|wav|webm]'`}>
  777. ```bash {{ title: 'cURL' }}
  778. curl -X POST '${props.appDetail.api_base_url}/conversations/name' \
  779. --header 'Authorization: Bearer {api_key}' \
  780. --form 'file=@localfile;type=audio/mp3'
  781. ```
  782. </CodeGroup>
  783. <CodeGroup title="Response">
  784. ```json {{ text: 'hello' }}
  785. {
  786. "text": ""
  787. }
  788. ```
  789. </CodeGroup>
  790. </Col>
  791. </Row>
  792. ---
  793. <Heading
  794. url='/text-to-audio'
  795. method='POST'
  796. title='Text to Audio'
  797. name='#audio'
  798. />
  799. <Row>
  800. <Col>
  801. Text to speech.
  802. ### Request Body
  803. <Properties>
  804. <Property name='message_id' type='str' key='text'>
  805. For text messages generated by Dify, simply pass the generated message-id directly. The backend will use the message-id to look up the corresponding content and synthesize the voice information directly. If both message_id and text are provided simultaneously, the message_id is given priority.
  806. </Property>
  807. <Property name='text' type='str' key='text'>
  808. Speech generated content。
  809. </Property>
  810. <Property name='user' type='string' key='user'>
  811. The user identifier, defined by the developer, must ensure uniqueness within the app.
  812. </Property>
  813. </Properties>
  814. </Col>
  815. <Col sticky>
  816. <CodeGroup title="Request" tag="POST" label="/text-to-audio" targetCode={`curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",\n "text": "Hello Dify",\n "user": "abc-123"\n}'`}>
  817. ```bash {{ title: 'cURL' }}
  818. curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \
  819. --header 'Authorization: Bearer {api_key}' \
  820. --header 'Content-Type: application/json' \
  821. --data-raw '{
  822. "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",
  823. "text": "Hello Dify",
  824. "user": "abc-123",
  825. "streaming": false
  826. }'
  827. ```
  828. </CodeGroup>
  829. <CodeGroup title="headers">
  830. ```json {{ title: 'headers' }}
  831. {
  832. "Content-Type": "audio/wav"
  833. }
  834. ```
  835. </CodeGroup>
  836. </Col>
  837. </Row>
  838. ---
  839. <Heading
  840. url='/info'
  841. method='GET'
  842. title='Get Application Basic Information'
  843. name='#info'
  844. />
  845. <Row>
  846. <Col>
  847. Used to get basic information about this application
  848. ### Query
  849. <Properties>
  850. <Property name='user' type='string' key='user'>
  851. User identifier, defined by the developer's rules, must be unique within the application.
  852. </Property>
  853. </Properties>
  854. ### Response
  855. - `name` (string) application name
  856. - `description` (string) application description
  857. - `tags` (array[string]) application tags
  858. </Col>
  859. <Col>
  860. <CodeGroup title="Request" tag="GET" label="/info" targetCode={`curl -X GET '${props.appDetail.api_base_url}/info?user=abc-123' \\\n-H 'Authorization: Bearer {api_key}'`}>
  861. ```bash {{ title: 'cURL' }}
  862. curl -X GET '${props.appDetail.api_base_url}/info?user=abc-123' \
  863. -H 'Authorization: Bearer {api_key}'
  864. ```
  865. </CodeGroup>
  866. <CodeGroup title="Response">
  867. ```json {{ title: 'Response' }}
  868. {
  869. "name": "My App",
  870. "description": "This is my app.",
  871. "tags": [
  872. "tag1",
  873. "tag2"
  874. ]
  875. }
  876. ```
  877. </CodeGroup>
  878. </Col>
  879. </Row>
  880. ---
  881. <Heading
  882. url='/parameters'
  883. method='GET'
  884. title='Get Application Parameters Information'
  885. name='#parameters'
  886. />
  887. <Row>
  888. <Col>
  889. Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.
  890. ### Query
  891. <Properties>
  892. <Property name='user' type='string' key='user'>
  893. User identifier, defined by the developer's rules, must be unique within the application.
  894. </Property>
  895. </Properties>
  896. ### Response
  897. - `opening_statement` (string) Opening statement
  898. - `suggested_questions` (array[string]) List of suggested questions for the opening
  899. - `suggested_questions_after_answer` (object) Suggest questions after enabling the answer.
  900. - `enabled` (bool) Whether it is enabled
  901. - `speech_to_text` (object) Speech to text
  902. - `enabled` (bool) Whether it is enabled
  903. - `retriever_resource` (object) Citation and Attribution
  904. - `enabled` (bool) Whether it is enabled
  905. - `annotation_reply` (object) Annotation reply
  906. - `enabled` (bool) Whether it is enabled
  907. - `user_input_form` (array[object]) User input form configuration
  908. - `text-input` (object) Text input control
  909. - `label` (string) Variable display label name
  910. - `variable` (string) Variable ID
  911. - `required` (bool) Whether it is required
  912. - `default` (string) Default value
  913. - `paragraph` (object) Paragraph text input control
  914. - `label` (string) Variable display label name
  915. - `variable` (string) Variable ID
  916. - `required` (bool) Whether it is required
  917. - `default` (string) Default value
  918. - `select` (object) Dropdown control
  919. - `label` (string) Variable display label name
  920. - `variable` (string) Variable ID
  921. - `required` (bool) Whether it is required
  922. - `default` (string) Default value
  923. - `options` (array[string]) Option values
  924. - `file_upload` (object) File upload configuration
  925. - `image` (object) Image settings
  926. Currently only supports image types: `png`, `jpg`, `jpeg`, `webp`, `gif`
  927. - `enabled` (bool) Whether it is enabled
  928. - `number_limits` (int) Image number limit, default is 3
  929. - `transfer_methods` (array[string]) List of transfer methods, remote_url, local_file, must choose one
  930. - `system_parameters` (object) System parameters
  931. - `file_size_limit` (int) Document upload size limit (MB)
  932. - `image_file_size_limit` (int) Image file upload size limit (MB)
  933. - `audio_file_size_limit` (int) Audio file upload size limit (MB)
  934. - `video_file_size_limit` (int) Video file upload size limit (MB)
  935. </Col>
  936. <Col sticky>
  937. <CodeGroup title="Request" tag="GET" label="/parameters" targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters?user=abc-123'`}>
  938. ```bash {{ title: 'cURL' }}
  939. curl -X GET '${props.appDetail.api_base_url}/parameters?user=abc-123' \
  940. --header 'Authorization: Bearer {api_key}'
  941. ```
  942. </CodeGroup>
  943. <CodeGroup title="Response">
  944. ```json {{ title: 'Response' }}
  945. {
  946. "opening_statement": "Hello!",
  947. "suggested_questions_after_answer": {
  948. "enabled": true
  949. },
  950. "speech_to_text": {
  951. "enabled": true
  952. },
  953. "retriever_resource": {
  954. "enabled": true
  955. },
  956. "annotation_reply": {
  957. "enabled": true
  958. },
  959. "user_input_form": [
  960. {
  961. "paragraph": {
  962. "label": "Query",
  963. "variable": "query",
  964. "required": true,
  965. "default": ""
  966. }
  967. }
  968. ],
  969. "file_upload": {
  970. "image": {
  971. "enabled": false,
  972. "number_limits": 3,
  973. "detail": "high",
  974. "transfer_methods": [
  975. "remote_url",
  976. "local_file"
  977. ]
  978. }
  979. },
  980. "system_parameters": {
  981. "file_size_limit": 15,
  982. "image_file_size_limit": 10,
  983. "audio_file_size_limit": 50,
  984. "video_file_size_limit": 100
  985. }
  986. }
  987. ```
  988. </CodeGroup>
  989. </Col>
  990. </Row>
  991. ---
  992. <Heading
  993. url='/meta'
  994. method='GET'
  995. title='Get Application Meta Information'
  996. name='#meta'
  997. />
  998. <Row>
  999. <Col>
  1000. Used to get icons of tools in this application
  1001. ### Query
  1002. <Properties>
  1003. <Property name='user' type='string' key='user'>
  1004. User identifier, defined by the developer's rules, must be unique within the application.
  1005. </Property>
  1006. </Properties>
  1007. ### Response
  1008. - `tool_icons`(object[string]) tool icons
  1009. - `tool_name` (string)
  1010. - `icon` (object|string)
  1011. - (object) icon object
  1012. - `background` (string) background color in hex format
  1013. - `content`(string) emoji
  1014. - (string) url of icon
  1015. </Col>
  1016. <Col>
  1017. <CodeGroup title="Request" tag="GET" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/meta?user=abc-123' \\\n-H 'Authorization: Bearer {api_key}'`}>
  1018. ```bash {{ title: 'cURL' }}
  1019. curl -X GET '${props.appDetail.api_base_url}/meta?user=abc-123' \
  1020. -H 'Authorization: Bearer {api_key}'
  1021. ```
  1022. </CodeGroup>
  1023. <CodeGroup title="Response">
  1024. ```json {{ title: 'Response' }}
  1025. {
  1026. "tool_icons": {
  1027. "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",
  1028. "api_tool": {
  1029. "background": "#252525",
  1030. "content": "\ud83d\ude01"
  1031. }
  1032. }
  1033. }
  1034. ```
  1035. </CodeGroup>
  1036. </Col>
  1037. </Row>