template_advanced_chat.en.mdx 45 KB

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