template_advanced_chat.en.mdx 47 KB

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