template_advanced_chat.en.mdx 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  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. </Properties>
  411. ### Response
  412. - `result` (string) Always returns "success"
  413. </Col>
  414. <Col sticky>
  415. <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}'`}>
  416. ```bash {{ title: 'cURL' }}
  417. curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks' \
  418. --header 'Authorization: Bearer {api_key}' \
  419. --header 'Content-Type: application/json' \
  420. --data-raw '{
  421. "rating": "like",
  422. "user": "abc-123"
  423. }'
  424. ```
  425. </CodeGroup>
  426. <CodeGroup title="Response">
  427. ```json {{ title: 'Response' }}
  428. {
  429. "result": "success"
  430. }
  431. ```
  432. </CodeGroup>
  433. </Col>
  434. </Row>
  435. ---
  436. <Heading
  437. url='/messages/{message_id}/suggested'
  438. method='GET'
  439. title='Next Suggested Questions'
  440. name='#suggested'
  441. />
  442. <Row>
  443. <Col>
  444. Get next questions suggestions for the current message
  445. ### Path Params
  446. <Properties>
  447. <Property name='message_id' type='string' key='message_id'>
  448. Message ID
  449. </Property>
  450. </Properties>
  451. ### Query
  452. <Properties>
  453. <Property name='user' type='string' key='user'>
  454. User identifier, used to define the identity of the end-user for retrieval and statistics.
  455. Should be uniquely defined by the developer within the application.
  456. </Property>
  457. </Properties>
  458. </Col>
  459. <Col sticky>
  460. <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'`}>
  461. ```bash {{ title: 'cURL' }}
  462. curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123' \
  463. --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
  464. --header 'Content-Type: application/json' \
  465. ```
  466. </CodeGroup>
  467. <CodeGroup title="Response">
  468. ```json {{ title: 'Response' }}
  469. {
  470. "result": "success",
  471. "data": [
  472. "a",
  473. "b",
  474. "c"
  475. ]
  476. }
  477. ```
  478. </CodeGroup>
  479. </Col>
  480. </Row>
  481. ---
  482. <Heading
  483. url='/messages'
  484. method='GET'
  485. title='Get Conversation History Messages'
  486. name='#messages'
  487. />
  488. <Row>
  489. <Col>
  490. Returns historical chat records in a scrolling load format, with the first page returning the latest `{limit}` messages, i.e., in reverse order.
  491. ### Query
  492. <Properties>
  493. <Property name='conversation_id' type='string' key='conversation_id'>
  494. Conversation ID
  495. </Property>
  496. <Property name='user' type='string' key='user'>
  497. User identifier, used to define the identity of the end-user for retrieval and statistics.
  498. Should be uniquely defined by the developer within the application.
  499. </Property>
  500. <Property name='first_id' type='string' key='first_id'>
  501. The ID of the first chat record on the current page, default is null.
  502. </Property>
  503. <Property name='limit' type='int' key='limit'>
  504. How many chat history messages to return in one request, default is 20.
  505. </Property>
  506. </Properties>
  507. ### Response
  508. - `data` (array[object]) Message list
  509. - `id` (string) Message ID
  510. - `conversation_id` (string) Conversation ID
  511. - `inputs` (object) User input parameters.
  512. - `query` (string) User input / question content.
  513. - `message_files` (array[object]) Message files
  514. - `id` (string) ID
  515. - `type` (string) File type, image for images
  516. - `url` (string) Preview image URL
  517. - `belongs_to` (string) belongs to,user orassistant
  518. - `answer` (string) Response message content
  519. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  520. - `feedback` (object) Feedback information
  521. - `rating` (string) Upvote as `like` / Downvote as `dislike`
  522. - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List
  523. - `has_more` (bool) Whether there is a next page
  524. - `limit` (int) Number of returned items, if input exceeds system limit, returns system limit amount
  525. </Col>
  526. <Col sticky>
  527. <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}'`}>
  528. ```bash {{ title: 'cURL' }}
  529. curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id='
  530. --header 'Authorization: Bearer {api_key}'
  531. ```
  532. </CodeGroup>
  533. ### Response Example
  534. <CodeGroup title="Response">
  535. ```json {{ title: 'Response' }}
  536. {
  537. "limit": 20,
  538. "has_more": false,
  539. "data": [
  540. {
  541. "id": "a076a87f-31e5-48dc-b452-0061adbbc922",
  542. "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  543. "inputs": {
  544. "name": "dify"
  545. },
  546. "query": "iphone 13 pro",
  547. "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.",
  548. "message_files": [],
  549. "feedback": null,
  550. "retriever_resources": [
  551. {
  552. "position": 1,
  553. "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  554. "dataset_name": "iPhone",
  555. "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",
  556. "document_name": "iPhone List",
  557. "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",
  558. "score": 0.98457545,
  559. "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\""
  560. }
  561. ],
  562. "created_at": 1705569239,
  563. }
  564. ]
  565. }
  566. ```
  567. </CodeGroup>
  568. </Col>
  569. </Row>
  570. ---
  571. <Heading
  572. url='/conversations'
  573. method='GET'
  574. title='Get Conversations'
  575. name='#conversations'
  576. />
  577. <Row>
  578. <Col>
  579. Retrieve the conversation list for the current user, defaulting to the most recent 20 entries.
  580. ### Query
  581. <Properties>
  582. <Property name='user' type='string' key='user'>
  583. User identifier, used to define the identity of the end-user for retrieval and statistics.
  584. Should be uniquely defined by the developer within the application.
  585. </Property>
  586. <Property name='last_id' type='string' key='last_id'>
  587. (Optional) The ID of the last record on the current page, default is null.
  588. </Property>
  589. <Property name='limit' type='int' key='limit'>
  590. (Optional) How many records to return in one request, default is the most recent 20 entries. Maximum 100, minimum 1.
  591. </Property>
  592. <Property name='sort_by' type='string' key='sort_by'>
  593. (Optional) Sorting Field, Default: -updated_at (sorted in descending order by update time)
  594. - Available Values: created_at, -created_at, updated_at, -updated_at
  595. - The symbol before the field represents the order or reverse, "-" represents reverse order.
  596. </Property>
  597. </Properties>
  598. ### Response
  599. - `data` (array[object]) List of conversations
  600. - `id` (string) Conversation ID
  601. - `name` (string) Conversation name, by default, is generated by LLM.
  602. - `inputs` (object) User input parameters.
  603. - `status` (string) Conversation status
  604. - `introduction` (string) Introduction
  605. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  606. - `updated_at` (timestamp) Update timestamp, e.g., 1705395332
  607. - `has_more` (bool)
  608. - `limit` (int) Number of entries returned, if input exceeds system limit, system limit number is returned
  609. </Col>
  610. <Col sticky>
  611. <CodeGroup title="Request" tag="GET" label="/conversations" targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20'`}>
  612. ```bash {{ title: 'cURL' }}
  613. curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \
  614. --header 'Authorization: Bearer {api_key}'
  615. ```
  616. </CodeGroup>
  617. <CodeGroup title="Response">
  618. ```json {{ title: 'Response' }}
  619. {
  620. "limit": 20,
  621. "has_more": false,
  622. "data": [
  623. {
  624. "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",
  625. "name": "New chat",
  626. "inputs": {
  627. "book": "book",
  628. "myName": "Lucy"
  629. },
  630. "status": "normal",
  631. "created_at": 1679667915,
  632. "updated_at": 1679667915
  633. },
  634. {
  635. "id": "hSIhXBhNe8X1d8Et"
  636. // ...
  637. }
  638. ]
  639. }
  640. ```
  641. </CodeGroup>
  642. </Col>
  643. </Row>
  644. ---
  645. <Heading
  646. url='/conversations/:conversation_id'
  647. method='DELETE'
  648. title='Delete Conversation'
  649. name='#delete'
  650. />
  651. <Row>
  652. <Col>
  653. Delete a conversation.
  654. ### Path
  655. - `conversation_id` (string) Conversation ID
  656. ### Request Body
  657. <Properties>
  658. <Property name='user' type='string' key='user'>
  659. The user identifier, defined by the developer, must ensure uniqueness within the application.
  660. </Property>
  661. </Properties>
  662. ### Response
  663. - `result` (string) Always returns "success"
  664. </Col>
  665. <Col sticky>
  666. <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}'`}>
  667. ```bash {{ title: 'cURL' }}
  668. curl -X DELETE '${props.appDetail.api_base_url}/conversations/{conversation_id}' \
  669. --header 'Content-Type: application/json' \
  670. --header 'Accept: application/json' \
  671. --header 'Authorization: Bearer {api_key}' \
  672. --data '{
  673. "user": "abc-123"
  674. }'
  675. ```
  676. </CodeGroup>
  677. <CodeGroup title="Response">
  678. ```json {{ title: 'Response' }}
  679. {
  680. "result": "success"
  681. }
  682. ```
  683. </CodeGroup>
  684. </Col>
  685. </Row>
  686. ---
  687. <Heading
  688. url='/conversations/:conversation_id/name'
  689. method='POST'
  690. title='Conversation Rename'
  691. name='#rename'
  692. />
  693. <Row>
  694. <Col>
  695. ### Request Body
  696. Rename the session, the session name is used for display on clients that support multiple sessions.
  697. ### Path
  698. - `conversation_id` (string) Conversation ID
  699. <Properties>
  700. <Property name='name' type='string' key='name'>
  701. (Optional) The name of the conversation. This parameter can be omitted if `auto_generate` is set to `true`.
  702. </Property>
  703. <Property name='auto_generate' type='bool' key='auto_generate'>
  704. (Optional) Automatically generate the title, default is `false`
  705. </Property>
  706. <Property name='user' type='string' key='user'>
  707. The user identifier, defined by the developer, must ensure uniqueness within the application.
  708. </Property>
  709. </Properties>
  710. ### Response
  711. - `id` (string) Conversation ID
  712. - `name` (string) Conversation name
  713. - `inputs` (object) User input parameters
  714. - `status` (string) Conversation status
  715. - `introduction` (string) Introduction
  716. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  717. - `updated_at` (timestamp) Update timestamp, e.g., 1705395332
  718. </Col>
  719. <Col sticky>
  720. <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}'`}>
  721. ```bash {{ title: 'cURL' }}
  722. curl -X POST '${props.appDetail.api_base_url}/conversations/{conversation_id}/name' \
  723. --header 'Content-Type: application/json' \
  724. --header 'Authorization: Bearer {api_key}' \
  725. --data-raw '{
  726. "name": "",
  727. "auto_generate": true,
  728. "user": "abc-123"
  729. }'
  730. ```
  731. </CodeGroup>
  732. <CodeGroup title="Response">
  733. ```json {{ title: 'Response' }}
  734. {
  735. "id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  736. "name": "Chat vs AI",
  737. "inputs": {},
  738. "status": "normal",
  739. "introduction": "",
  740. "created_at": 1705569238,
  741. "updated_at": 1705569238
  742. }
  743. ```
  744. </CodeGroup>
  745. </Col>
  746. </Row>
  747. ---
  748. <Heading
  749. url='/audio-to-text'
  750. method='POST'
  751. title='Speech to Text'
  752. name='#audio'
  753. />
  754. <Row>
  755. <Col>
  756. This endpoint requires a multipart/form-data request.
  757. ### Request Body
  758. <Properties>
  759. <Property name='file' type='file' key='file'>
  760. Audio file.
  761. Supported formats: `['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`
  762. File size limit: 15MB
  763. </Property>
  764. <Property name='user' type='string' key='user'>
  765. User identifier, defined by the developer's rules, must be unique within the application.
  766. </Property>
  767. </Properties>
  768. ### Response
  769. - `text` (string) Output text
  770. </Col>
  771. <Col sticky>
  772. <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]'`}>
  773. ```bash {{ title: 'cURL' }}
  774. curl -X POST '${props.appDetail.api_base_url}/conversations/name' \
  775. --header 'Authorization: Bearer {api_key}' \
  776. --form 'file=@localfile;type=audio/mp3'
  777. ```
  778. </CodeGroup>
  779. <CodeGroup title="Response">
  780. ```json {{ text: 'hello' }}
  781. {
  782. "text": ""
  783. }
  784. ```
  785. </CodeGroup>
  786. </Col>
  787. </Row>
  788. ---
  789. <Heading
  790. url='/text-to-audio'
  791. method='POST'
  792. title='Text to Audio'
  793. name='#audio'
  794. />
  795. <Row>
  796. <Col>
  797. Text to speech.
  798. ### Request Body
  799. <Properties>
  800. <Property name='message_id' type='str' key='text'>
  801. 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.
  802. </Property>
  803. <Property name='text' type='str' key='text'>
  804. Speech generated content。
  805. </Property>
  806. <Property name='user' type='string' key='user'>
  807. The user identifier, defined by the developer, must ensure uniqueness within the app.
  808. </Property>
  809. </Properties>
  810. </Col>
  811. <Col sticky>
  812. <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}'`}>
  813. ```bash {{ title: 'cURL' }}
  814. curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \
  815. --header 'Authorization: Bearer {api_key}' \
  816. --header 'Content-Type: application/json' \
  817. --data-raw '{
  818. "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",
  819. "text": "Hello Dify",
  820. "user": "abc-123",
  821. "streaming": false
  822. }'
  823. ```
  824. </CodeGroup>
  825. <CodeGroup title="headers">
  826. ```json {{ title: 'headers' }}
  827. {
  828. "Content-Type": "audio/wav"
  829. }
  830. ```
  831. </CodeGroup>
  832. </Col>
  833. </Row>
  834. ---
  835. <Heading
  836. url='/info'
  837. method='GET'
  838. title='Get Application Basic Information'
  839. name='#info'
  840. />
  841. <Row>
  842. <Col>
  843. Used to get basic information about this application
  844. ### Query
  845. <Properties>
  846. <Property name='user' type='string' key='user'>
  847. User identifier, defined by the developer's rules, must be unique within the application.
  848. </Property>
  849. </Properties>
  850. ### Response
  851. - `name` (string) application name
  852. - `description` (string) application description
  853. - `tags` (array[string]) application tags
  854. </Col>
  855. <Col>
  856. <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}'`}>
  857. ```bash {{ title: 'cURL' }}
  858. curl -X GET '${props.appDetail.api_base_url}/info?user=abc-123' \
  859. -H 'Authorization: Bearer {api_key}'
  860. ```
  861. </CodeGroup>
  862. <CodeGroup title="Response">
  863. ```json {{ title: 'Response' }}
  864. {
  865. "name": "My App",
  866. "description": "This is my app.",
  867. "tags": [
  868. "tag1",
  869. "tag2"
  870. ]
  871. }
  872. ```
  873. </CodeGroup>
  874. </Col>
  875. </Row>
  876. ---
  877. <Heading
  878. url='/parameters'
  879. method='GET'
  880. title='Get Application Parameters Information'
  881. name='#parameters'
  882. />
  883. <Row>
  884. <Col>
  885. Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.
  886. ### Query
  887. <Properties>
  888. <Property name='user' type='string' key='user'>
  889. User identifier, defined by the developer's rules, must be unique within the application.
  890. </Property>
  891. </Properties>
  892. ### Response
  893. - `opening_statement` (string) Opening statement
  894. - `suggested_questions` (array[string]) List of suggested questions for the opening
  895. - `suggested_questions_after_answer` (object) Suggest questions after enabling the answer.
  896. - `enabled` (bool) Whether it is enabled
  897. - `speech_to_text` (object) Speech to text
  898. - `enabled` (bool) Whether it is enabled
  899. - `retriever_resource` (object) Citation and Attribution
  900. - `enabled` (bool) Whether it is enabled
  901. - `annotation_reply` (object) Annotation reply
  902. - `enabled` (bool) Whether it is enabled
  903. - `user_input_form` (array[object]) User input form configuration
  904. - `text-input` (object) Text input control
  905. - `label` (string) Variable display label name
  906. - `variable` (string) Variable ID
  907. - `required` (bool) Whether it is required
  908. - `default` (string) Default value
  909. - `paragraph` (object) Paragraph text input control
  910. - `label` (string) Variable display label name
  911. - `variable` (string) Variable ID
  912. - `required` (bool) Whether it is required
  913. - `default` (string) Default value
  914. - `select` (object) Dropdown control
  915. - `label` (string) Variable display label name
  916. - `variable` (string) Variable ID
  917. - `required` (bool) Whether it is required
  918. - `default` (string) Default value
  919. - `options` (array[string]) Option values
  920. - `file_upload` (object) File upload configuration
  921. - `image` (object) Image settings
  922. Currently only supports image types: `png`, `jpg`, `jpeg`, `webp`, `gif`
  923. - `enabled` (bool) Whether it is enabled
  924. - `number_limits` (int) Image number limit, default is 3
  925. - `transfer_methods` (array[string]) List of transfer methods, remote_url, local_file, must choose one
  926. - `system_parameters` (object) System parameters
  927. - `file_size_limit` (int) Document upload size limit (MB)
  928. - `image_file_size_limit` (int) Image file upload size limit (MB)
  929. - `audio_file_size_limit` (int) Audio file upload size limit (MB)
  930. - `video_file_size_limit` (int) Video file upload size limit (MB)
  931. </Col>
  932. <Col sticky>
  933. <CodeGroup title="Request" tag="GET" label="/parameters" targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters?user=abc-123'`}>
  934. ```bash {{ title: 'cURL' }}
  935. curl -X GET '${props.appDetail.api_base_url}/parameters?user=abc-123' \
  936. --header 'Authorization: Bearer {api_key}'
  937. ```
  938. </CodeGroup>
  939. <CodeGroup title="Response">
  940. ```json {{ title: 'Response' }}
  941. {
  942. "opening_statement": "Hello!",
  943. "suggested_questions_after_answer": {
  944. "enabled": true
  945. },
  946. "speech_to_text": {
  947. "enabled": true
  948. },
  949. "retriever_resource": {
  950. "enabled": true
  951. },
  952. "annotation_reply": {
  953. "enabled": true
  954. },
  955. "user_input_form": [
  956. {
  957. "paragraph": {
  958. "label": "Query",
  959. "variable": "query",
  960. "required": true,
  961. "default": ""
  962. }
  963. }
  964. ],
  965. "file_upload": {
  966. "image": {
  967. "enabled": false,
  968. "number_limits": 3,
  969. "detail": "high",
  970. "transfer_methods": [
  971. "remote_url",
  972. "local_file"
  973. ]
  974. }
  975. },
  976. "system_parameters": {
  977. "file_size_limit": 15,
  978. "image_file_size_limit": 10,
  979. "audio_file_size_limit": 50,
  980. "video_file_size_limit": 100
  981. }
  982. }
  983. ```
  984. </CodeGroup>
  985. </Col>
  986. </Row>
  987. ---
  988. <Heading
  989. url='/meta'
  990. method='GET'
  991. title='Get Application Meta Information'
  992. name='#meta'
  993. />
  994. <Row>
  995. <Col>
  996. Used to get icons of tools in this application
  997. ### Query
  998. <Properties>
  999. <Property name='user' type='string' key='user'>
  1000. User identifier, defined by the developer's rules, must be unique within the application.
  1001. </Property>
  1002. </Properties>
  1003. ### Response
  1004. - `tool_icons`(object[string]) tool icons
  1005. - `tool_name` (string)
  1006. - `icon` (object|string)
  1007. - (object) icon object
  1008. - `background` (string) background color in hex format
  1009. - `content`(string) emoji
  1010. - (string) url of icon
  1011. </Col>
  1012. <Col>
  1013. <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}'`}>
  1014. ```bash {{ title: 'cURL' }}
  1015. curl -X GET '${props.appDetail.api_base_url}/meta?user=abc-123' \
  1016. -H 'Authorization: Bearer {api_key}'
  1017. ```
  1018. </CodeGroup>
  1019. <CodeGroup title="Response">
  1020. ```json {{ title: 'Response' }}
  1021. {
  1022. "tool_icons": {
  1023. "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",
  1024. "api_tool": {
  1025. "background": "#252525",
  1026. "content": "\ud83d\ude01"
  1027. }
  1028. }
  1029. }
  1030. ```
  1031. </CodeGroup>
  1032. </Col>
  1033. </Row>