You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

template_advanced_chat.en.mdx 63KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677
  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. - `event` (string) Event type, fixed to `message`
  78. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  79. - `id` (string) unique ID
  80. - `message_id` (string) Unique message ID
  81. - `conversation_id` (string) Conversation ID
  82. - `mode` (string) App mode, fixed as `chat`
  83. - `answer` (string) Complete response content
  84. - `metadata` (object) Metadata
  85. - `usage` (Usage) Model usage information
  86. - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List
  87. - `created_at` (int) Message creation timestamp, e.g., 1705395332
  88. ### ChunkChatCompletionResponse
  89. Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.
  90. Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:
  91. <CodeGroup>
  92. ```streaming {{ title: 'Response' }}
  93. data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n
  94. ```
  95. </CodeGroup>
  96. The structure of the streaming chunks varies depending on the `event`:
  97. - `event: message` LLM returns text chunk event, i.e., the complete text is output in a chunked fashion.
  98. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  99. - `message_id` (string) Unique message ID
  100. - `conversation_id` (string) Conversation ID
  101. - `answer` (string) LLM returned text chunk content
  102. - `created_at` (int) Creation timestamp, e.g., 1705395332
  103. - `event: message_file` Message file event, a new file has created by tool
  104. - `id` (string) File unique ID
  105. - `type` (string) File type,only allow "image" currently
  106. - `belongs_to` (string) Belongs to, it will only be an 'assistant' here
  107. - `url` (string) Remote url of file
  108. - `conversation_id` (string) Conversation ID
  109. - `event: message_end` Message end event, receiving this event means streaming has ended.
  110. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  111. - `message_id` (string) Unique message ID
  112. - `conversation_id` (string) Conversation ID
  113. - `metadata` (object) Metadata
  114. - `usage` (Usage) Model usage information
  115. - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List
  116. - `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)
  117. - `task_id` (string) Task ID, used for request tracking and the stop response interface below
  118. - `message_id` (string) Unique message ID
  119. - `audio` (string) The audio after speech synthesis, encoded in base64 text content, when playing, simply decode the base64 and feed it into the player
  120. - `created_at` (int) Creation timestamp, e.g.: 1705395332
  121. - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of the audio stream.
  122. - `task_id` (string) Task ID, used for request tracking and the stop response interface below
  123. - `message_id` (string) Unique message ID
  124. - `audio` (string) The end event has no audio, so this is an empty string
  125. - `created_at` (int) Creation timestamp, e.g.: 1705395332
  126. - `event: message_replace` Message content replacement event.
  127. 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.
  128. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  129. - `message_id` (string) Unique message ID
  130. - `conversation_id` (string) Conversation ID
  131. - `answer` (string) Replacement content (directly replaces all LLM reply text)
  132. - `created_at` (int) Creation timestamp, e.g., 1705395332
  133. - `event: workflow_started` workflow starts execution
  134. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  135. - `workflow_run_id` (string) Unique ID of workflow execution
  136. - `event` (string) fixed to `workflow_started`
  137. - `data` (object) detail
  138. - `id` (string) Unique ID of workflow execution
  139. - `workflow_id` (string) ID of related workflow
  140. - `sequence_number` (int) Self-increasing serial number, self-increasing in the App, starting from 1
  141. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  142. - `event: node_started` node execution started
  143. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  144. - `workflow_run_id` (string) Unique ID of workflow execution
  145. - `event` (string) fixed to `node_started`
  146. - `data` (object) detail
  147. - `id` (string) Unique ID of workflow execution
  148. - `node_id` (string) ID of node
  149. - `node_type` (string) type of node
  150. - `title` (string) name of node
  151. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  152. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  153. - `inputs` (object) Contents of all preceding node variables used in the node
  154. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  155. - `event: node_finished` node execution ends, success or failure in different states in the same event
  156. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  157. - `workflow_run_id` (string) Unique ID of workflow execution
  158. - `event` (string) fixed to `node_finished`
  159. - `data` (object) detail
  160. - `id` (string) Unique ID of workflow execution
  161. - `node_id` (string) ID of node
  162. - `node_type` (string) type of node
  163. - `title` (string) name of node
  164. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  165. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  166. - `inputs` (object) Contents of all preceding node variables used in the node
  167. - `process_data` (json) Optional node process data
  168. - `outputs` (json) Optional content of output
  169. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  170. - `error` (string) Optional reason of error
  171. - `elapsed_time` (float) Optional total seconds to be used
  172. - `execution_metadata` (json) meta data
  173. - `total_tokens` (int) optional tokens to be used
  174. - `total_price` (decimal) optional Total cost
  175. - `currency` (string) optional e.g. `USD` / `RMB`
  176. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  177. - `event: workflow_finished` workflow execution ends, success or failure in different states in the same event
  178. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  179. - `workflow_run_id` (string) Unique ID of workflow execution
  180. - `event` (string) fixed to `workflow_finished`
  181. - `data` (object) detail
  182. - `id` (string) ID of workflow execution
  183. - `workflow_id` (string) ID of related workflow
  184. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  185. - `outputs` (json) Optional content of output
  186. - `error` (string) Optional reason of error
  187. - `elapsed_time` (float) Optional total seconds to be used
  188. - `total_tokens` (int) Optional tokens to be used
  189. - `total_steps` (int) default 0
  190. - `created_at` (timestamp) start time
  191. - `finished_at` (timestamp) end time
  192. - `event: error`
  193. 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.
  194. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  195. - `message_id` (string) Unique message ID
  196. - `status` (int) HTTP status code
  197. - `code` (string) Error code
  198. - `message` (string) Error message
  199. - `event: ping` Ping event every 10 seconds to keep the connection alive.
  200. ### Errors
  201. - 404, Conversation does not exists
  202. - 400, `invalid_param`, abnormal parameter input
  203. - 400, `app_unavailable`, App configuration unavailable
  204. - 400, `provider_not_initialize`, no available model credential configuration
  205. - 400, `provider_quota_exceeded`, model invocation quota insufficient
  206. - 400, `model_currently_not_support`, current model unavailable
  207. - 400, `completion_request_error`, text generation failed
  208. - 500, internal server error
  209. </Col>
  210. <Col sticky>
  211. <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}'`}>
  212. ```bash {{ title: 'cURL' }}
  213. curl -X POST '${props.appDetail.api_base_url}/chat-messages' \
  214. --header 'Authorization: Bearer {api_key}' \
  215. --header 'Content-Type: application/json' \
  216. --data-raw '{
  217. "inputs": {},
  218. "query": "eh",
  219. "response_mode": "streaming",
  220. "conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276",
  221. "user": "abc-123"
  222. }'
  223. ```
  224. </CodeGroup>
  225. ### Blocking Mode
  226. <CodeGroup title="Response">
  227. ```json {{ title: 'Response' }}
  228. {
  229. "event": "message",
  230. "task_id": "c3800678-a077-43df-a102-53f23ed20b88",
  231. "id": "9da23599-e713-473b-982c-4328d4f5c78a",
  232. "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",
  233. "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2",
  234. "mode": "chat",
  235. "answer": "iPhone 13 Pro Max specs are listed here:...",
  236. "metadata": {
  237. "usage": {
  238. "prompt_tokens": 1033,
  239. "prompt_unit_price": "0.001",
  240. "prompt_price_unit": "0.001",
  241. "prompt_price": "0.0010330",
  242. "completion_tokens": 128,
  243. "completion_unit_price": "0.002",
  244. "completion_price_unit": "0.001",
  245. "completion_price": "0.0002560",
  246. "total_tokens": 1161,
  247. "total_price": "0.0012890",
  248. "currency": "USD",
  249. "latency": 0.7682376249867957
  250. },
  251. "retriever_resources": [
  252. {
  253. "position": 1,
  254. "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  255. "dataset_name": "iPhone",
  256. "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",
  257. "document_name": "iPhone List",
  258. "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",
  259. "score": 0.98457545,
  260. "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\""
  261. }
  262. ]
  263. },
  264. "created_at": 1705407629
  265. }
  266. ```
  267. </CodeGroup>
  268. ### Streaming Mode
  269. <CodeGroup title="Response">
  270. ```streaming {{ title: 'Response' }}
  271. 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}}
  272. 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}}
  273. 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}}
  274. 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}}
  275. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}
  276. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}
  277. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}
  278. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}
  279. data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}
  280. data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}
  281. 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\""}]}}
  282. 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"}
  283. 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": ""}
  284. ```
  285. </CodeGroup>
  286. </Col>
  287. </Row>
  288. ---
  289. <Heading
  290. url='/files/upload'
  291. method='POST'
  292. title='File Upload'
  293. name='#file-upload'
  294. />
  295. <Row>
  296. <Col>
  297. Upload a file for use when sending messages, enabling multimodal understanding of images and text.
  298. Supports any formats that are supported by your application.
  299. Uploaded files are for use by the current end-user only.
  300. ### Request Body
  301. This interface requires a `multipart/form-data` request.
  302. - `file` (File) Required
  303. The file to be uploaded.
  304. - `user` (string) Required
  305. User identifier, defined by the developer's rules, must be unique within the application.
  306. ### Response
  307. After a successful upload, the server will return the file's ID and related information.
  308. - `id` (uuid) ID
  309. - `name` (string) File name
  310. - `size` (int) File size (bytes)
  311. - `extension` (string) File extension
  312. - `mime_type` (string) File mime-type
  313. - `created_by` (uuid) End-user ID
  314. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  315. ### Errors
  316. - 400, `no_file_uploaded`, a file must be provided
  317. - 400, `too_many_files`, currently only one file is accepted
  318. - 400, `unsupported_preview`, the file does not support preview
  319. - 400, `unsupported_estimate`, the file does not support estimation
  320. - 413, `file_too_large`, the file is too large
  321. - 415, `unsupported_file_type`, unsupported extension, currently only document files are accepted
  322. - 503, `s3_connection_failed`, unable to connect to S3 service
  323. - 503, `s3_permission_denied`, no permission to upload files to S3
  324. - 503, `s3_file_too_large`, file exceeds S3 size limit
  325. - 500, internal server error
  326. </Col>
  327. <Col sticky>
  328. ### Request Example
  329. <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'`}>
  330. ```bash {{ title: 'cURL' }}
  331. curl -X POST '${props.appDetail.api_base_url}/files/upload' \
  332. --header 'Authorization: Bearer {api_key}' \
  333. --form 'file=@"/path/to/file"'
  334. ```
  335. </CodeGroup>
  336. ### Response Example
  337. <CodeGroup title="Response">
  338. ```json {{ title: 'Response' }}
  339. {
  340. "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
  341. "name": "example.png",
  342. "size": 1024,
  343. "extension": "png",
  344. "mime_type": "image/png",
  345. "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",
  346. "created_at": 1577836800,
  347. }
  348. ```
  349. </CodeGroup>
  350. </Col>
  351. </Row>
  352. ---
  353. <Heading
  354. url='/chat-messages/:task_id/stop'
  355. method='POST'
  356. title='Stop Generate'
  357. name='#stop-generatebacks'
  358. />
  359. <Row>
  360. <Col>
  361. Only supported in streaming mode.
  362. ### Path
  363. - `task_id` (string) Task ID, can be obtained from the streaming chunk return
  364. ### Request Body
  365. - `user` (string) Required
  366. User identifier, used to define the identity of the end-user, must be consistent with the user passed in the send message interface.
  367. ### Response
  368. - `result` (string) Always returns "success"
  369. </Col>
  370. <Col sticky>
  371. ### Request Example
  372. <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"}'`}>
  373. ```bash {{ title: 'cURL' }}
  374. curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \
  375. -H 'Authorization: Bearer {api_key}' \
  376. -H 'Content-Type: application/json' \
  377. --data-raw '{
  378. "user": "abc-123"
  379. }'
  380. ```
  381. </CodeGroup>
  382. ### Response Example
  383. <CodeGroup title="Response">
  384. ```json {{ title: 'Response' }}
  385. {
  386. "result": "success"
  387. }
  388. ```
  389. </CodeGroup>
  390. </Col>
  391. </Row>
  392. ---
  393. <Heading
  394. url='/messages/:message_id/feedbacks'
  395. method='POST'
  396. title='Message Feedback'
  397. name='#feedbacks'
  398. />
  399. <Row>
  400. <Col>
  401. End-users can provide feedback messages, facilitating application developers to optimize expected outputs.
  402. ### Path
  403. <Properties>
  404. <Property name='message_id' type='string' key='message_id'>
  405. Message ID
  406. </Property>
  407. </Properties>
  408. ### Request Body
  409. <Properties>
  410. <Property name='rating' type='string' key='rating'>
  411. Upvote as `like`, downvote as `dislike`, revoke upvote as `null`
  412. </Property>
  413. <Property name='user' type='string' key='user'>
  414. User identifier, defined by the developer's rules, must be unique within the application.
  415. </Property>
  416. <Property name='content' type='string' key='content'>
  417. The specific content of message feedback.
  418. </Property>
  419. </Properties>
  420. ### Response
  421. - `result` (string) Always returns "success"
  422. </Col>
  423. <Col sticky>
  424. <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}'`}>
  425. ```bash {{ title: 'cURL' }}
  426. curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks' \
  427. --header 'Authorization: Bearer {api_key}' \
  428. --header 'Content-Type: application/json' \
  429. --data-raw '{
  430. "rating": "like",
  431. "user": "abc-123",
  432. "content": "message feedback information"
  433. }'
  434. ```
  435. </CodeGroup>
  436. <CodeGroup title="Response">
  437. ```json {{ title: 'Response' }}
  438. {
  439. "result": "success"
  440. }
  441. ```
  442. </CodeGroup>
  443. </Col>
  444. </Row>
  445. ---
  446. <Heading
  447. url='/app/feedbacks'
  448. method='GET'
  449. title='Get feedbacks of application'
  450. name='#app-feedbacks'
  451. />
  452. <Row>
  453. <Col>
  454. Get application's feedbacks.
  455. ### Query
  456. <Properties>
  457. <Property name='page' type='string' key='page'>
  458. (optional)pagination,default:1
  459. </Property>
  460. </Properties>
  461. <Properties>
  462. <Property name='limit' type='string' key='limit'>
  463. (optional) records per page default:20
  464. </Property>
  465. </Properties>
  466. ### Response
  467. - `data` (List) return apps feedback list.
  468. </Col>
  469. <Col sticky>
  470. <CodeGroup title="Request" tag="GET" label="/app/feedbacks" targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}>
  471. ```bash {{ title: 'cURL' }}
  472. curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \
  473. --header 'Authorization: Bearer {api_key}' \
  474. --header 'Content-Type: application/json'
  475. ```
  476. </CodeGroup>
  477. <CodeGroup title="Response">
  478. ```json {{ title: 'Response' }}
  479. {
  480. "data": [
  481. {
  482. "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",
  483. "app_id": "f252d396-fe48-450e-94ec-e184218e7346",
  484. "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",
  485. "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",
  486. "rating": "like",
  487. "content": "message feedback information-3",
  488. "from_source": "user",
  489. "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",
  490. "from_account_id": null,
  491. "created_at": "2025-04-24T09:24:38",
  492. "updated_at": "2025-04-24T09:24:38"
  493. }
  494. ]
  495. }
  496. ```
  497. </CodeGroup>
  498. </Col>
  499. </Row>
  500. ---
  501. <Heading
  502. url='/messages/{message_id}/suggested'
  503. method='GET'
  504. title='Next Suggested Questions'
  505. name='#suggested'
  506. />
  507. <Row>
  508. <Col>
  509. Get next questions suggestions for the current message
  510. ### Path Params
  511. <Properties>
  512. <Property name='message_id' type='string' key='message_id'>
  513. Message ID
  514. </Property>
  515. </Properties>
  516. ### Query
  517. <Properties>
  518. <Property name='user' type='string' key='user'>
  519. User identifier, used to define the identity of the end-user for retrieval and statistics.
  520. Should be uniquely defined by the developer within the application.
  521. </Property>
  522. </Properties>
  523. </Col>
  524. <Col sticky>
  525. <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'`}>
  526. ```bash {{ title: 'cURL' }}
  527. curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123' \
  528. --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
  529. --header 'Content-Type: application/json' \
  530. ```
  531. </CodeGroup>
  532. <CodeGroup title="Response">
  533. ```json {{ title: 'Response' }}
  534. {
  535. "result": "success",
  536. "data": [
  537. "a",
  538. "b",
  539. "c"
  540. ]
  541. }
  542. ```
  543. </CodeGroup>
  544. </Col>
  545. </Row>
  546. ---
  547. <Heading
  548. url='/messages'
  549. method='GET'
  550. title='Get Conversation History Messages'
  551. name='#messages'
  552. />
  553. <Row>
  554. <Col>
  555. Returns historical chat records in a scrolling load format, with the first page returning the latest `{limit}` messages, i.e., in reverse order.
  556. ### Query
  557. <Properties>
  558. <Property name='conversation_id' type='string' key='conversation_id'>
  559. Conversation ID
  560. </Property>
  561. <Property name='user' type='string' key='user'>
  562. User identifier, used to define the identity of the end-user for retrieval and statistics.
  563. Should be uniquely defined by the developer within the application.
  564. </Property>
  565. <Property name='first_id' type='string' key='first_id'>
  566. The ID of the first chat record on the current page, default is null.
  567. </Property>
  568. <Property name='limit' type='int' key='limit'>
  569. How many chat history messages to return in one request, default is 20.
  570. </Property>
  571. </Properties>
  572. ### Response
  573. - `data` (array[object]) Message list
  574. - `id` (string) Message ID
  575. - `conversation_id` (string) Conversation ID
  576. - `inputs` (object) User input parameters.
  577. - `query` (string) User input / question content.
  578. - `message_files` (array[object]) Message files
  579. - `id` (string) ID
  580. - `type` (string) File type, image for images
  581. - `url` (string) Preview image URL
  582. - `belongs_to` (string) belongs to,user orassistant
  583. - `answer` (string) Response message content
  584. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  585. - `feedback` (object) Feedback information
  586. - `rating` (string) Upvote as `like` / Downvote as `dislike`
  587. - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List
  588. - `has_more` (bool) Whether there is a next page
  589. - `limit` (int) Number of returned items, if input exceeds system limit, returns system limit amount
  590. </Col>
  591. <Col sticky>
  592. <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}'`}>
  593. ```bash {{ title: 'cURL' }}
  594. curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id='
  595. --header 'Authorization: Bearer {api_key}'
  596. ```
  597. </CodeGroup>
  598. ### Response Example
  599. <CodeGroup title="Response">
  600. ```json {{ title: 'Response' }}
  601. {
  602. "limit": 20,
  603. "has_more": false,
  604. "data": [
  605. {
  606. "id": "a076a87f-31e5-48dc-b452-0061adbbc922",
  607. "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  608. "inputs": {
  609. "name": "dify"
  610. },
  611. "query": "iphone 13 pro",
  612. "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.",
  613. "message_files": [],
  614. "feedback": null,
  615. "retriever_resources": [
  616. {
  617. "position": 1,
  618. "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  619. "dataset_name": "iPhone",
  620. "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",
  621. "document_name": "iPhone List",
  622. "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",
  623. "score": 0.98457545,
  624. "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\""
  625. }
  626. ],
  627. "created_at": 1705569239,
  628. }
  629. ]
  630. }
  631. ```
  632. </CodeGroup>
  633. </Col>
  634. </Row>
  635. ---
  636. <Heading
  637. url='/conversations'
  638. method='GET'
  639. title='Get Conversations'
  640. name='#conversations'
  641. />
  642. <Row>
  643. <Col>
  644. Retrieve the conversation list for the current user, defaulting to the most recent 20 entries.
  645. ### Query
  646. <Properties>
  647. <Property name='user' type='string' key='user'>
  648. User identifier, used to define the identity of the end-user for retrieval and statistics.
  649. Should be uniquely defined by the developer within the application.
  650. </Property>
  651. <Property name='last_id' type='string' key='last_id'>
  652. (Optional) The ID of the last record on the current page, default is null.
  653. </Property>
  654. <Property name='limit' type='int' key='limit'>
  655. (Optional) How many records to return in one request, default is the most recent 20 entries. Maximum 100, minimum 1.
  656. </Property>
  657. <Property name='sort_by' type='string' key='sort_by'>
  658. (Optional) Sorting Field, Default: -updated_at (sorted in descending order by update time)
  659. - Available Values: created_at, -created_at, updated_at, -updated_at
  660. - The symbol before the field represents the order or reverse, "-" represents reverse order.
  661. </Property>
  662. </Properties>
  663. ### Response
  664. - `data` (array[object]) List of conversations
  665. - `id` (string) Conversation ID
  666. - `name` (string) Conversation name, by default, is generated by LLM.
  667. - `inputs` (object) User input parameters.
  668. - `status` (string) Conversation status
  669. - `introduction` (string) Introduction
  670. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  671. - `updated_at` (timestamp) Update timestamp, e.g., 1705395332
  672. - `has_more` (bool)
  673. - `limit` (int) Number of entries returned, if input exceeds system limit, system limit number is returned
  674. </Col>
  675. <Col sticky>
  676. <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}'`}>
  677. ```bash {{ title: 'cURL' }}
  678. curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \
  679. --header 'Authorization: Bearer {api_key}'
  680. ```
  681. </CodeGroup>
  682. <CodeGroup title="Response">
  683. ```json {{ title: 'Response' }}
  684. {
  685. "limit": 20,
  686. "has_more": false,
  687. "data": [
  688. {
  689. "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",
  690. "name": "New chat",
  691. "inputs": {
  692. "book": "book",
  693. "myName": "Lucy"
  694. },
  695. "status": "normal",
  696. "created_at": 1679667915,
  697. "updated_at": 1679667915
  698. },
  699. {
  700. "id": "hSIhXBhNe8X1d8Et"
  701. // ...
  702. }
  703. ]
  704. }
  705. ```
  706. </CodeGroup>
  707. </Col>
  708. </Row>
  709. ---
  710. <Heading
  711. url='/conversations/:conversation_id'
  712. method='DELETE'
  713. title='Delete Conversation'
  714. name='#delete'
  715. />
  716. <Row>
  717. <Col>
  718. Delete a conversation.
  719. ### Path
  720. - `conversation_id` (string) Conversation ID
  721. ### Request Body
  722. <Properties>
  723. <Property name='user' type='string' key='user'>
  724. The user identifier, defined by the developer, must ensure uniqueness within the application.
  725. </Property>
  726. </Properties>
  727. ### Response
  728. - `result` (string) Always returns "success"
  729. </Col>
  730. <Col sticky>
  731. <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}'`}>
  732. ```bash {{ title: 'cURL' }}
  733. curl -X DELETE '${props.appDetail.api_base_url}/conversations/{conversation_id}' \
  734. --header 'Content-Type: application/json' \
  735. --header 'Accept: application/json' \
  736. --header 'Authorization: Bearer {api_key}' \
  737. --data '{
  738. "user": "abc-123"
  739. }'
  740. ```
  741. </CodeGroup>
  742. <CodeGroup title="Response">
  743. ```text {{ title: 'Response' }}
  744. 204 No Content
  745. ```
  746. </CodeGroup>
  747. </Col>
  748. </Row>
  749. ---
  750. <Heading
  751. url='/conversations/:conversation_id/name'
  752. method='POST'
  753. title='Conversation Rename'
  754. name='#rename'
  755. />
  756. <Row>
  757. <Col>
  758. ### Request Body
  759. Rename the session, the session name is used for display on clients that support multiple sessions.
  760. ### Path
  761. - `conversation_id` (string) Conversation ID
  762. <Properties>
  763. <Property name='name' type='string' key='name'>
  764. (Optional) The name of the conversation. This parameter can be omitted if `auto_generate` is set to `true`.
  765. </Property>
  766. <Property name='auto_generate' type='bool' key='auto_generate'>
  767. (Optional) Automatically generate the title, default is `false`
  768. </Property>
  769. <Property name='user' type='string' key='user'>
  770. The user identifier, defined by the developer, must ensure uniqueness within the application.
  771. </Property>
  772. </Properties>
  773. ### Response
  774. - `id` (string) Conversation ID
  775. - `name` (string) Conversation name
  776. - `inputs` (object) User input parameters
  777. - `status` (string) Conversation status
  778. - `introduction` (string) Introduction
  779. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  780. - `updated_at` (timestamp) Update timestamp, e.g., 1705395332
  781. </Col>
  782. <Col sticky>
  783. <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}'`}>
  784. ```bash {{ title: 'cURL' }}
  785. curl -X POST '${props.appDetail.api_base_url}/conversations/{conversation_id}/name' \
  786. --header 'Content-Type: application/json' \
  787. --header 'Authorization: Bearer {api_key}' \
  788. --data-raw '{
  789. "name": "",
  790. "auto_generate": true,
  791. "user": "abc-123"
  792. }'
  793. ```
  794. </CodeGroup>
  795. <CodeGroup title="Response">
  796. ```json {{ title: 'Response' }}
  797. {
  798. "id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  799. "name": "Chat vs AI",
  800. "inputs": {},
  801. "status": "normal",
  802. "introduction": "",
  803. "created_at": 1705569238,
  804. "updated_at": 1705569238
  805. }
  806. ```
  807. </CodeGroup>
  808. </Col>
  809. </Row>
  810. ---
  811. <Heading
  812. url='/conversations/:conversation_id/variables'
  813. method='GET'
  814. title='Get Conversation Variables'
  815. name='#conversation-variables'
  816. />
  817. <Row>
  818. <Col>
  819. Retrieve variables from a specific conversation. This endpoint is useful for extracting structured data that was captured during the conversation.
  820. ### Path Parameters
  821. <Properties>
  822. <Property name='conversation_id' type='string' key='conversation_id'>
  823. The ID of the conversation to retrieve variables from.
  824. </Property>
  825. </Properties>
  826. ### Query Parameters
  827. <Properties>
  828. <Property name='user' type='string' key='user'>
  829. The user identifier, defined by the developer, must ensure uniqueness within the application
  830. </Property>
  831. <Property name='last_id' type='string' key='last_id'>
  832. (Optional) The ID of the last record on the current page, default is null.
  833. </Property>
  834. <Property name='limit' type='int' key='limit'>
  835. (Optional) How many records to return in one request, default is the most recent 20 entries. Maximum 100, minimum 1.
  836. </Property>
  837. </Properties>
  838. ### Response
  839. - `limit` (int) Number of items per page
  840. - `has_more` (bool) Whether there is a next page
  841. - `data` (array[object]) List of variables
  842. - `id` (string) Variable ID
  843. - `name` (string) Variable name
  844. - `value_type` (string) Variable type (string, number, object, etc.)
  845. - `value` (string) Variable value
  846. - `description` (string) Variable description
  847. - `created_at` (int) Creation timestamp
  848. - `updated_at` (int) Last update timestamp
  849. ### Errors
  850. - 404, `conversation_not_exists`, Conversation not found
  851. </Col>
  852. <Col sticky>
  853. <CodeGroup title="Request" tag="GET" label="/conversations/:conversation_id/variables" targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \\\n--header 'Authorization: Bearer {api_key}'`}>
  854. ```bash {{ title: 'cURL' }}
  855. curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \
  856. --header 'Authorization: Bearer {api_key}'
  857. ```
  858. </CodeGroup>
  859. <CodeGroup title="Request with variable name filter">
  860. ```bash {{ title: 'cURL' }}
  861. curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123&variable_name=customer_name' \
  862. --header 'Authorization: Bearer {api_key}'
  863. ```
  864. </CodeGroup>
  865. <CodeGroup title="Response">
  866. ```json {{ title: 'Response' }}
  867. {
  868. "limit": 100,
  869. "has_more": false,
  870. "data": [
  871. {
  872. "id": "variable-uuid-1",
  873. "name": "customer_name",
  874. "value_type": "string",
  875. "value": "John Doe",
  876. "description": "Customer name extracted from the conversation",
  877. "created_at": 1650000000000,
  878. "updated_at": 1650000000000
  879. },
  880. {
  881. "id": "variable-uuid-2",
  882. "name": "order_details",
  883. "value_type": "json",
  884. "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}",
  885. "description": "Order details from the customer",
  886. "created_at": 1650000000000,
  887. "updated_at": 1650000000000
  888. }
  889. ]
  890. }
  891. ```
  892. </CodeGroup>
  893. </Col>
  894. </Row>
  895. ---
  896. <Heading
  897. url='/audio-to-text'
  898. method='POST'
  899. title='Speech to Text'
  900. name='#audio'
  901. />
  902. <Row>
  903. <Col>
  904. This endpoint requires a multipart/form-data request.
  905. ### Request Body
  906. <Properties>
  907. <Property name='file' type='file' key='file'>
  908. Audio file.
  909. Supported formats: `['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`
  910. File size limit: 15MB
  911. </Property>
  912. <Property name='user' type='string' key='user'>
  913. User identifier, defined by the developer's rules, must be unique within the application.
  914. </Property>
  915. </Properties>
  916. ### Response
  917. - `text` (string) Output text
  918. </Col>
  919. <Col sticky>
  920. <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]'`}>
  921. ```bash {{ title: 'cURL' }}
  922. curl -X POST '${props.appDetail.api_base_url}/conversations/name' \
  923. --header 'Authorization: Bearer {api_key}' \
  924. --form 'file=@localfile;type=audio/mp3'
  925. ```
  926. </CodeGroup>
  927. <CodeGroup title="Response">
  928. ```json {{ title: 'Response' }}
  929. {
  930. "text": ""
  931. }
  932. ```
  933. </CodeGroup>
  934. </Col>
  935. </Row>
  936. ---
  937. <Heading
  938. url='/text-to-audio'
  939. method='POST'
  940. title='Text to Audio'
  941. name='#audio'
  942. />
  943. <Row>
  944. <Col>
  945. Text to speech.
  946. ### Request Body
  947. <Properties>
  948. <Property name='message_id' type='str' key='message_id'>
  949. 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.
  950. </Property>
  951. <Property name='text' type='str' key='text'>
  952. Speech generated content。
  953. </Property>
  954. <Property name='user' type='string' key='user'>
  955. The user identifier, defined by the developer, must ensure uniqueness within the app.
  956. </Property>
  957. </Properties>
  958. </Col>
  959. <Col sticky>
  960. <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}'`}>
  961. ```bash {{ title: 'cURL' }}
  962. curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \
  963. --header 'Authorization: Bearer {api_key}' \
  964. --header 'Content-Type: application/json' \
  965. --data-raw '{
  966. "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",
  967. "text": "Hello Dify",
  968. "user": "abc-123",
  969. "streaming": false
  970. }'
  971. ```
  972. </CodeGroup>
  973. <CodeGroup title="headers">
  974. ```json {{ title: 'headers' }}
  975. {
  976. "Content-Type": "audio/wav"
  977. }
  978. ```
  979. </CodeGroup>
  980. </Col>
  981. </Row>
  982. ---
  983. <Heading
  984. url='/info'
  985. method='GET'
  986. title='Get Application Basic Information'
  987. name='#info'
  988. />
  989. <Row>
  990. <Col>
  991. Used to get basic information about this application
  992. ### Response
  993. - `name` (string) application name
  994. - `description` (string) application description
  995. - `tags` (array[string]) application tags
  996. - `mode` (string) application mode
  997. - `author_name` (string) application author name
  998. </Col>
  999. <Col>
  1000. <CodeGroup title="Request" tag="GET" label="/info" targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\\n-H 'Authorization: Bearer {api_key}'`}>
  1001. ```bash {{ title: 'cURL' }}
  1002. curl -X GET '${props.appDetail.api_base_url}/info' \
  1003. -H 'Authorization: Bearer {api_key}'
  1004. ```
  1005. </CodeGroup>
  1006. <CodeGroup title="Response">
  1007. ```json {{ title: 'Response' }}
  1008. {
  1009. "name": "My App",
  1010. "description": "This is my app.",
  1011. "tags": [
  1012. "tag1",
  1013. "tag2"
  1014. ],
  1015. "mode": "advanced-chat",
  1016. "author_name": "Dify"
  1017. }
  1018. ```
  1019. </CodeGroup>
  1020. </Col>
  1021. </Row>
  1022. ---
  1023. <Heading
  1024. url='/parameters'
  1025. method='GET'
  1026. title='Get Application Parameters Information'
  1027. name='#parameters'
  1028. />
  1029. <Row>
  1030. <Col>
  1031. Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.
  1032. ### Response
  1033. - `opening_statement` (string) Opening statement
  1034. - `suggested_questions` (array[string]) List of suggested questions for the opening
  1035. - `suggested_questions_after_answer` (object) Suggest questions after enabling the answer.
  1036. - `enabled` (bool) Whether it is enabled
  1037. - `speech_to_text` (object) Speech to text
  1038. - `enabled` (bool) Whether it is enabled
  1039. - `text_to_speech` (object) Text to speech
  1040. - `enabled` (bool) Whether it is enabled
  1041. - `voice` (string) Voice type
  1042. - `language` (string) Language
  1043. - `autoPlay` (string) Auto play
  1044. - `enabled` Enabled
  1045. - `disabled` Disabled
  1046. - `retriever_resource` (object) Citation and Attribution
  1047. - `enabled` (bool) Whether it is enabled
  1048. - `annotation_reply` (object) Annotation reply
  1049. - `enabled` (bool) Whether it is enabled
  1050. - `user_input_form` (array[object]) User input form configuration
  1051. - `text-input` (object) Text input control
  1052. - `label` (string) Variable display label name
  1053. - `variable` (string) Variable ID
  1054. - `required` (bool) Whether it is required
  1055. - `default` (string) Default value
  1056. - `paragraph` (object) Paragraph text input control
  1057. - `label` (string) Variable display label name
  1058. - `variable` (string) Variable ID
  1059. - `required` (bool) Whether it is required
  1060. - `default` (string) Default value
  1061. - `select` (object) Dropdown control
  1062. - `label` (string) Variable display label name
  1063. - `variable` (string) Variable ID
  1064. - `required` (bool) Whether it is required
  1065. - `default` (string) Default value
  1066. - `options` (array[string]) Option values
  1067. - `file_upload` (object) File upload configuration
  1068. - `image` (object) Image settings
  1069. Currently only supports image types: `png`, `jpg`, `jpeg`, `webp`, `gif`
  1070. - `enabled` (bool) Whether it is enabled
  1071. - `number_limits` (int) Image number limit, default is 3
  1072. - `transfer_methods` (array[string]) List of transfer methods, remote_url, local_file, must choose one
  1073. - `system_parameters` (object) System parameters
  1074. - `file_size_limit` (int) Document upload size limit (MB)
  1075. - `image_file_size_limit` (int) Image file upload size limit (MB)
  1076. - `audio_file_size_limit` (int) Audio file upload size limit (MB)
  1077. - `video_file_size_limit` (int) Video file upload size limit (MB)
  1078. </Col>
  1079. <Col sticky>
  1080. <CodeGroup title="Request" tag="GET" label="/parameters" targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}>
  1081. ```bash {{ title: 'cURL' }}
  1082. curl -X GET '${props.appDetail.api_base_url}/parameters' \
  1083. --header 'Authorization: Bearer {api_key}'
  1084. ```
  1085. </CodeGroup>
  1086. <CodeGroup title="Response">
  1087. ```json {{ title: 'Response' }}
  1088. {
  1089. "opening_statement": "Hello!",
  1090. "suggested_questions_after_answer": {
  1091. "enabled": true
  1092. },
  1093. "speech_to_text": {
  1094. "enabled": true
  1095. },
  1096. "text_to_speech": {
  1097. "enabled": true,
  1098. "voice": "sambert-zhinan-v1",
  1099. "language": "zh-Hans",
  1100. "autoPlay": "disabled"
  1101. },
  1102. "retriever_resource": {
  1103. "enabled": true
  1104. },
  1105. "annotation_reply": {
  1106. "enabled": true
  1107. },
  1108. "user_input_form": [
  1109. {
  1110. "paragraph": {
  1111. "label": "Query",
  1112. "variable": "query",
  1113. "required": true,
  1114. "default": ""
  1115. }
  1116. }
  1117. ],
  1118. "file_upload": {
  1119. "image": {
  1120. "enabled": false,
  1121. "number_limits": 3,
  1122. "detail": "high",
  1123. "transfer_methods": [
  1124. "remote_url",
  1125. "local_file"
  1126. ]
  1127. }
  1128. },
  1129. "system_parameters": {
  1130. "file_size_limit": 15,
  1131. "image_file_size_limit": 10,
  1132. "audio_file_size_limit": 50,
  1133. "video_file_size_limit": 100
  1134. }
  1135. }
  1136. ```
  1137. </CodeGroup>
  1138. </Col>
  1139. </Row>
  1140. ---
  1141. <Heading
  1142. url='/meta'
  1143. method='GET'
  1144. title='Get Application Meta Information'
  1145. name='#meta'
  1146. />
  1147. <Row>
  1148. <Col>
  1149. Used to get icons of tools in this application
  1150. ### Response
  1151. - `tool_icons`(object[string]) tool icons
  1152. - `tool_name` (string)
  1153. - `icon` (object|string)
  1154. - (object) icon object
  1155. - `background` (string) background color in hex format
  1156. - `content`(string) emoji
  1157. - (string) url of icon
  1158. </Col>
  1159. <Col>
  1160. <CodeGroup title="Request" tag="GET" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/meta' \\\n-H 'Authorization: Bearer {api_key}'`}>
  1161. ```bash {{ title: 'cURL' }}
  1162. curl -X GET '${props.appDetail.api_base_url}/meta' \
  1163. -H 'Authorization: Bearer {api_key}'
  1164. ```
  1165. </CodeGroup>
  1166. <CodeGroup title="Response">
  1167. ```json {{ title: 'Response' }}
  1168. {
  1169. "tool_icons": {
  1170. "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",
  1171. "api_tool": {
  1172. "background": "#252525",
  1173. "content": "\ud83d\ude01"
  1174. }
  1175. }
  1176. }
  1177. ```
  1178. </CodeGroup>
  1179. </Col>
  1180. </Row>
  1181. ---
  1182. <Heading
  1183. url='/site'
  1184. method='GET'
  1185. title='Get Application WebApp Settings'
  1186. name='#site'
  1187. />
  1188. <Row>
  1189. <Col>
  1190. Used to get the WebApp settings of the application.
  1191. ### Response
  1192. - `title` (string) WebApp name
  1193. - `chat_color_theme` (string) Chat color theme, in hex format
  1194. - `chat_color_theme_inverted` (bool) Whether the chat color theme is inverted
  1195. - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture
  1196. - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL
  1197. - `icon_background` (string) Background color in hex format
  1198. - `icon_url` (string) Icon URL
  1199. - `description` (string) Description
  1200. - `copyright` (string) Copyright information
  1201. - `privacy_policy` (string) Privacy policy link
  1202. - `custom_disclaimer` (string) Custom disclaimer
  1203. - `default_language` (string) Default language
  1204. - `show_workflow_steps` (bool) Whether to show workflow details
  1205. - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon
  1206. </Col>
  1207. <Col>
  1208. <CodeGroup title="Request" tag="POST" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\\n-H 'Authorization: Bearer {api_key}'`}>
  1209. ```bash {{ title: 'cURL' }}
  1210. curl -X GET '${props.appDetail.api_base_url}/site' \
  1211. -H 'Authorization: Bearer {api_key}'
  1212. ```
  1213. </CodeGroup>
  1214. <CodeGroup title="Response">
  1215. ```json {{ title: 'Response' }}
  1216. {
  1217. "title": "My App",
  1218. "chat_color_theme": "#ff4a4a",
  1219. "chat_color_theme_inverted": false,
  1220. "icon_type": "emoji",
  1221. "icon": "😄",
  1222. "icon_background": "#FFEAD5",
  1223. "icon_url": null,
  1224. "description": "This is my app.",
  1225. "copyright": "all rights reserved",
  1226. "privacy_policy": "",
  1227. "custom_disclaimer": "All generated by AI",
  1228. "default_language": "en-US",
  1229. "show_workflow_steps": false,
  1230. "use_icon_as_answer_icon": false,
  1231. }
  1232. ```
  1233. </CodeGroup>
  1234. </Col>
  1235. </Row>
  1236. ___
  1237. <Heading
  1238. url='/apps/annotations'
  1239. method='GET'
  1240. title='Get Annotation List'
  1241. name='#annotation_list'
  1242. />
  1243. <Row>
  1244. <Col>
  1245. ### Query
  1246. <Properties>
  1247. <Property name='page' type='string' key='page'>
  1248. Page number
  1249. </Property>
  1250. <Property name='limit' type='string' key='limit'>
  1251. Number of items returned, default 20, range 1-100
  1252. </Property>
  1253. </Properties>
  1254. </Col>
  1255. <Col sticky>
  1256. <CodeGroup
  1257. title="Request"
  1258. tag="GET"
  1259. label="/apps/annotations"
  1260. targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotations?page=1&limit=20' \\\n--header 'Authorization: Bearer {api_key}'`}
  1261. >
  1262. ```bash {{ title: 'cURL' }}
  1263. curl --location --request GET '${props.apiBaseUrl}/apps/annotations?page=1&limit=20' \
  1264. --header 'Authorization: Bearer {api_key}'
  1265. ```
  1266. </CodeGroup>
  1267. <CodeGroup title="Response">
  1268. ```json {{ title: 'Response' }}
  1269. {
  1270. "data": [
  1271. {
  1272. "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",
  1273. "question": "What is your name?",
  1274. "answer": "I am Dify.",
  1275. "hit_count": 0,
  1276. "created_at": 1735625869
  1277. }
  1278. ],
  1279. "has_more": false,
  1280. "limit": 20,
  1281. "total": 1,
  1282. "page": 1
  1283. }
  1284. ```
  1285. </CodeGroup>
  1286. </Col>
  1287. </Row>
  1288. ---
  1289. <Heading
  1290. url='/apps/annotations'
  1291. method='POST'
  1292. title='Create Annotation'
  1293. name='#create_annotation'
  1294. />
  1295. <Row>
  1296. <Col>
  1297. ### Query
  1298. <Properties>
  1299. <Property name='question' type='string' key='question'>
  1300. Question
  1301. </Property>
  1302. <Property name='answer' type='string' key='answer'>
  1303. Answer
  1304. </Property>
  1305. </Properties>
  1306. </Col>
  1307. <Col sticky>
  1308. <CodeGroup
  1309. title="Request"
  1310. tag="POST"
  1311. label="/apps/annotations"
  1312. targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotations' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"question": "What is your name?","answer": "I am Dify."}'`}
  1313. >
  1314. ```bash {{ title: 'cURL' }}
  1315. curl --location --request POST '${props.apiBaseUrl}/apps/annotations' \
  1316. --header 'Authorization: Bearer {api_key}' \
  1317. --header 'Content-Type: application/json' \
  1318. --data-raw '{
  1319. "question": "What is your name?",
  1320. "answer": "I am Dify."
  1321. }'
  1322. ```
  1323. </CodeGroup>
  1324. <CodeGroup title="Response">
  1325. ```json {{ title: 'Response' }}
  1326. {
  1327. "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",
  1328. "question": "What is your name?",
  1329. "answer": "I am Dify.",
  1330. "hit_count": 0,
  1331. "created_at": 1735625869
  1332. }
  1333. ```
  1334. </CodeGroup>
  1335. </Col>
  1336. </Row>
  1337. ---
  1338. <Heading
  1339. url='/apps/annotations/{annotation_id}'
  1340. method='PUT'
  1341. title='Update Annotation'
  1342. name='#update_annotation'
  1343. />
  1344. <Row>
  1345. <Col>
  1346. ### Query
  1347. <Properties>
  1348. <Property name='annotation_id' type='string' key='annotation_id'>
  1349. Annotation ID
  1350. </Property>
  1351. <Property name='question' type='string' key='question'>
  1352. Question
  1353. </Property>
  1354. <Property name='answer' type='string' key='answer'>
  1355. Answer
  1356. </Property>
  1357. </Properties>
  1358. </Col>
  1359. <Col sticky>
  1360. <CodeGroup
  1361. title="Request"
  1362. tag="PUT"
  1363. label="/apps/annotations/{annotation_id}"
  1364. targetCode={`curl --location --request PUT '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"question": "What is your name?","answer": "I am Dify."}'`}
  1365. >
  1366. ```bash {{ title: 'cURL' }}
  1367. curl --location --request PUT '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \
  1368. --header 'Authorization: Bearer {api_key}' \
  1369. --header 'Content-Type: application/json' \
  1370. --data-raw '{
  1371. "question": "What is your name?",
  1372. "answer": "I am Dify."
  1373. }'
  1374. ```
  1375. </CodeGroup>
  1376. <CodeGroup title="Response">
  1377. ```json {{ title: 'Response' }}
  1378. {
  1379. "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",
  1380. "question": "What is your name?",
  1381. "answer": "I am Dify.",
  1382. "hit_count": 0,
  1383. "created_at": 1735625869
  1384. }
  1385. ```
  1386. </CodeGroup>
  1387. </Col>
  1388. </Row>
  1389. ---
  1390. <Heading
  1391. url='/apps/annotations/{annotation_id}'
  1392. method='DELETE'
  1393. title='Delete Annotation'
  1394. name='#delete_annotation'
  1395. />
  1396. <Row>
  1397. <Col>
  1398. ### Query
  1399. <Properties>
  1400. <Property name='annotation_id' type='string' key='annotation_id'>
  1401. Annotation ID
  1402. </Property>
  1403. </Properties>
  1404. </Col>
  1405. <Col sticky>
  1406. <CodeGroup
  1407. title="Request"
  1408. tag="PUT"
  1409. label="/apps/annotations/{annotation_id}"
  1410. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`}
  1411. >
  1412. ```bash {{ title: 'cURL' }}
  1413. curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \
  1414. --header 'Authorization: Bearer {api_key}'
  1415. ```
  1416. </CodeGroup>
  1417. <CodeGroup title="Response">
  1418. ```text {{ title: 'Response' }}
  1419. 204 No Content
  1420. ```
  1421. </CodeGroup>
  1422. </Col>
  1423. </Row>
  1424. ---
  1425. <Heading
  1426. url='/apps/annotation-reply/{action}'
  1427. method='POST'
  1428. title='Initial Annotation Reply Settings'
  1429. name='#initial_annotation_reply_settings'
  1430. />
  1431. <Row>
  1432. <Col>
  1433. ### Query
  1434. <Properties>
  1435. <Property name='action' type='string' key='action'>
  1436. Action, can only be 'enable' or 'disable'
  1437. </Property>
  1438. <Property name='embedding_provider_name' type='string' key='embedding_provider_name'>
  1439. Specified embedding model provider, must be set up in the system first, corresponding to the provider field(Optional)
  1440. </Property>
  1441. <Property name='embedding_model_name' type='string' key='embedding_model_name'>
  1442. Specified embedding model, corresponding to the model field(Optional)
  1443. </Property>
  1444. <Property name='score_threshold' type='number' key='score_threshold'>
  1445. The similarity threshold for matching annotated replies. Only annotations with scores above this threshold will be recalled.
  1446. </Property>
  1447. </Properties>
  1448. </Col>
  1449. <Col sticky>
  1450. The provider and model name of the embedding model can be obtained through the following interface: v1/workspaces/current/models/model-types/text-embedding. For specific instructions, see: Maintain Knowledge Base via API. The Authorization used is the Dataset API Token.
  1451. <CodeGroup
  1452. title="Request"
  1453. tag="POST"
  1454. label="/apps/annotation-reply/{action}"
  1455. targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotation-reply/{action}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"score_threshold": 0.9, "embedding_provider_name": "zhipu", "embedding_model_name": "embedding_3"}'`}
  1456. >
  1457. ```bash {{ title: 'cURL' }}
  1458. curl --location --request POST 'https://api.dify.ai/v1/apps/annotation-reply/{action}' \
  1459. --header 'Authorization: Bearer {api_key}' \
  1460. --header 'Content-Type: application/json' \
  1461. --data-raw '{
  1462. "score_threshold": 0.9,
  1463. "embedding_provider_name": "zhipu",
  1464. "embedding_model_name": "embedding_3"
  1465. }'
  1466. ```
  1467. </CodeGroup>
  1468. <CodeGroup title="Response">
  1469. ```json {{ title: 'Response' }}
  1470. {
  1471. "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802",
  1472. "job_status": "waiting"
  1473. }
  1474. ```
  1475. </CodeGroup>
  1476. This interface is executed asynchronously, so it will return a job_id. You can get the final execution result by querying the job status interface.
  1477. </Col>
  1478. </Row>
  1479. ---
  1480. <Heading
  1481. url='/apps/annotation-reply/{action}/status/{job_id}'
  1482. method='GET'
  1483. title='Query Initial Annotation Reply Settings Task Status'
  1484. name='#initial_annotation_reply_settings_task_status'
  1485. />
  1486. <Row>
  1487. <Col>
  1488. ### Query
  1489. <Properties>
  1490. <Property name='action' type='string' key='action'>
  1491. Action, can only be 'enable' or 'disable', must be the same as the action in the initial annotation reply settings interface
  1492. </Property>
  1493. <Property name='job_id' type='string' key='job_id'>
  1494. Job ID, obtained from the initial annotation reply settings interface
  1495. </Property>
  1496. </Properties>
  1497. </Col>
  1498. <Col sticky>
  1499. <CodeGroup
  1500. title="Request"
  1501. tag="GET"
  1502. label="/apps/annotations"
  1503. targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1504. >
  1505. ```bash {{ title: 'cURL' }}
  1506. curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \
  1507. --header 'Authorization: Bearer {api_key}'
  1508. ```
  1509. </CodeGroup>
  1510. <CodeGroup title="Response">
  1511. ```json {{ title: 'Response' }}
  1512. {
  1513. "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802",
  1514. "job_status": "waiting",
  1515. "error_msg": ""
  1516. }
  1517. ```
  1518. </CodeGroup>
  1519. </Col>
  1520. </Row>