Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

template_workflow.en.mdx 50KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129
  1. import { CodeGroup } from '../code.tsx'
  2. import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from '../md.tsx'
  3. # Workflow App API
  4. Workflow applications offers non-session support and is ideal for translation, article writing, summarization AI, and more.
  5. <div>
  6. ### Base URL
  7. <CodeGroup title="Code" targetCode={props.appDetail.api_base_url} />
  8. ### Authentication
  9. The Service API uses `API-Key` authentication.
  10. <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>
  11. For all API requests, include your API Key in the `Authorization` HTTP Header, as shown below:
  12. <CodeGroup title="Code" targetCode='Authorization: Bearer {API_KEY}' />
  13. </div>
  14. ---
  15. <Heading
  16. url='/workflows/run'
  17. method='POST'
  18. title='Execute Workflow'
  19. name='#Execute-Workflow'
  20. />
  21. <Row>
  22. <Col>
  23. Execute workflow, cannot be executed without a published workflow.
  24. ### Request Body
  25. - `inputs` (object) Required
  26. Allows the entry of various variable values defined by the App.
  27. 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.
  28. The workflow application requires at least one key/value pair to be inputted. The variable can be of File Array type.
  29. File Array type variable is suitable for inputting files combined with text understanding and answering questions, available only when the model supports file parsing and understanding capability.
  30. If the variable is of File Array type, the corresponding value should be a list whose elements contain following attributions:
  31. - `type` (string) Supported type:
  32. - `document` ('TXT', 'MD', 'MARKDOWN', 'PDF', 'HTML', 'XLSX', 'XLS', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB')
  33. - `image` ('JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG')
  34. - `audio` ('MP3', 'M4A', 'WAV', 'WEBM', 'AMR')
  35. - `video` ('MP4', 'MOV', 'MPEG', 'MPGA')
  36. - `custom` (Other file types)
  37. - `transfer_method` (string) Transfer method, `remote_url` for image URL / `local_file` for file upload
  38. - `url` (string) Image URL (when the transfer method is `remote_url`)
  39. - `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`)
  40. - `response_mode` (string) Required
  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. <i>Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.</i>
  45. - `user` (string) Required
  46. User identifier, used to define the identity of the end-user for retrieval and statistics.
  47. Should be uniquely defined by the developer within the application.
  48. <br/>
  49. <i>The user identifier should be consistent with the user passed in the message sending interface. The Service API does not share conversations created by the WebApp.</i>
  50. - `files` (array[object]) Optional
  51. - `trace_id` (string) Optional
  52. Trace ID. Used for integration with existing business trace components to achieve end-to-end distributed tracing. If not provided, the system will automatically generate a trace_id. Supports the following three ways to pass, in order of priority:
  53. 1. Header: via HTTP Header `X-Trace-Id`, highest priority.
  54. 2. Query parameter: via URL query parameter `trace_id`.
  55. 3. Request Body: via request body field `trace_id` (i.e., this field).
  56. ### Response
  57. When `response_mode` is `blocking`, return a CompletionResponse object.
  58. When `response_mode` is `streaming`, return a ChunkCompletionResponse stream.
  59. ### CompletionResponse
  60. Returns the App result, `Content-Type` is `application/json`.
  61. - `workflow_run_id` (string) Unique ID of workflow execution
  62. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  63. - `data` (object) detail of result
  64. - `id` (string) ID of workflow execution
  65. - `workflow_id` (string) ID of related workflow
  66. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  67. - `outputs` (json) Optional content of output
  68. - `error` (string) Optional reason of error
  69. - `elapsed_time` (float) Optional total seconds to be used
  70. - `total_tokens` (int) Optional tokens to be used
  71. - `total_steps` (int) default 0
  72. - `created_at` (timestamp) start time
  73. - `finished_at` (timestamp) end time
  74. ### ChunkCompletionResponse
  75. Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.
  76. Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:
  77. <CodeGroup>
  78. ```streaming {{ title: 'Response' }}
  79. data: {"event": "text_chunk", "workflow_run_id": "b85e5fc5-751b-454d-b14e-dc5f240b0a31", "task_id": "bd029338-b068-4d34-a331-fc85478922c2", "data": {"text": "\u4e3a\u4e86", "from_variable_selector": ["1745912968134", "text"]}}\n\n
  80. ```
  81. </CodeGroup>
  82. The structure of the streaming chunks varies depending on the `event`:
  83. - `event: workflow_started` workflow starts execution
  84. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  85. - `workflow_run_id` (string) Unique ID of workflow execution
  86. - `event` (string) fixed to `workflow_started`
  87. - `data` (object) detail
  88. - `id` (string) Unique ID of workflow execution
  89. - `workflow_id` (string) ID of related workflow
  90. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  91. - `event: node_started` node execution started
  92. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  93. - `workflow_run_id` (string) Unique ID of workflow execution
  94. - `event` (string) fixed to `node_started`
  95. - `data` (object) detail
  96. - `id` (string) Unique ID of workflow execution
  97. - `node_id` (string) ID of node
  98. - `node_type` (string) type of node
  99. - `title` (string) name of node
  100. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  101. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  102. - `inputs` (object) Contents of all preceding node variables used in the node
  103. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  104. - `event: text_chunk` Text fragment
  105. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  106. - `workflow_run_id` (string) Unique ID of workflow execution
  107. - `event` (string) fixed to `text_chunk`
  108. - `data` (object) detail
  109. - `text` (string) Text content
  110. - `from_variable_selector` (array) Text source path, helping developers understand which node and variable generated the text
  111. - `event: node_finished` node execution ends, success or failure in different states in the same event
  112. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  113. - `workflow_run_id` (string) Unique ID of workflow execution
  114. - `event` (string) fixed to `node_finished`
  115. - `data` (object) detail
  116. - `id` (string) Unique ID of workflow execution
  117. - `node_id` (string) ID of node
  118. - `node_type` (string) type of node
  119. - `title` (string) name of node
  120. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  121. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  122. - `inputs` (object) Contents of all preceding node variables used in the node
  123. - `process_data` (json) Optional node process data
  124. - `outputs` (json) Optional content of output
  125. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  126. - `error` (string) Optional reason of error
  127. - `elapsed_time` (float) Optional total seconds to be used
  128. - `execution_metadata` (json) meta data
  129. - `total_tokens` (int) optional tokens to be used
  130. - `total_price` (decimal) optional Total cost
  131. - `currency` (string) optional e.g. `USD` / `RMB`
  132. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  133. - `event: workflow_finished` workflow execution ends, success or failure in different states in the same event
  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_finished`
  137. - `data` (object) detail
  138. - `id` (string) ID of workflow execution
  139. - `workflow_id` (string) ID of related workflow
  140. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  141. - `outputs` (json) Optional content of output
  142. - `error` (string) Optional reason of error
  143. - `elapsed_time` (float) Optional total seconds to be used
  144. - `total_tokens` (int) Optional tokens to be used
  145. - `total_steps` (int) default 0
  146. - `created_at` (timestamp) start time
  147. - `finished_at` (timestamp) end time
  148. - `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)
  149. - `task_id` (string) Task ID, used for request tracking and the stop response interface below
  150. - `message_id` (string) Unique message ID
  151. - `audio` (string) The audio after speech synthesis, encoded in base64 text content, when playing, simply decode the base64 and feed it into the player
  152. - `created_at` (int) Creation timestamp, e.g.: 1705395332
  153. - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of the audio stream.
  154. - `task_id` (string) Task ID, used for request tracking and the stop response interface below
  155. - `message_id` (string) Unique message ID
  156. - `audio` (string) The end event has no audio, so this is an empty string
  157. - `created_at` (int) Creation timestamp, e.g.: 1705395332
  158. - `event: ping` Ping event every 10 seconds to keep the connection alive.
  159. ### Errors
  160. - 400, `invalid_param`, abnormal parameter input
  161. - 400, `app_unavailable`, App configuration unavailable
  162. - 400, `provider_not_initialize`, no available model credential configuration
  163. - 400, `provider_quota_exceeded`, model invocation quota insufficient
  164. - 400, `model_currently_not_support`, current model unavailable
  165. - 400, `workflow_request_error`, workflow execution failed
  166. - 500, internal server error
  167. </Col>
  168. <Col sticky>
  169. <CodeGroup
  170. title="Request"
  171. tag="POST"
  172. label="/workflows/run"
  173. targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/run' \\
  174. --header 'Authorization: Bearer {api_key}' \\
  175. --header 'Content-Type: application/json' \\
  176. --data-raw '{
  177. "inputs": ${JSON.stringify(props.inputs)},
  178. "response_mode": "streaming",
  179. "user": "abc-123"
  180. }'`}
  181. />
  182. <CodeGroup title="Example: file array as an input variable">
  183. ```json {{ title: 'File variable example' }}
  184. {
  185. "inputs": {
  186. "{variable_name}":
  187. [
  188. {
  189. "transfer_method": "local_file",
  190. "upload_file_id": "{upload_file_id}",
  191. "type": "{document_type}"
  192. }
  193. ]
  194. }
  195. }
  196. ```
  197. </CodeGroup>
  198. ### Blocking Mode
  199. <CodeGroup title="Response">
  200. ```json {{ title: 'Response' }}
  201. {
  202. "workflow_run_id": "djflajgkldjgd",
  203. "task_id": "9da23599-e713-473b-982c-4328d4f5c78a",
  204. "data": {
  205. "id": "fdlsjfjejkghjda",
  206. "workflow_id": "fldjaslkfjlsda",
  207. "status": "succeeded",
  208. "outputs": {
  209. "text": "Nice to meet you."
  210. },
  211. "error": null,
  212. "elapsed_time": 0.875,
  213. "total_tokens": 3562,
  214. "total_steps": 8,
  215. "created_at": 1705407629,
  216. "finished_at": 1727807631
  217. }
  218. }
  219. ```
  220. </CodeGroup>
  221. ### Streaming Mode
  222. <CodeGroup title="Response">
  223. ```streaming {{ title: 'Response' }}
  224. 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", "created_at": 1679586595}}
  225. 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}}
  226. 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}}
  227. 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}}
  228. 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"}
  229. 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": ""}
  230. ```
  231. </CodeGroup>
  232. <CodeGroup title="File upload sample code">
  233. ```json {{ title: 'File upload sample code' }}
  234. import requests
  235. import json
  236. def upload_file(file_path, user):
  237. upload_url = "https://api.dify.ai/v1/files/upload"
  238. headers = {
  239. "Authorization": "Bearer app-xxxxxxxx",
  240. }
  241. try:
  242. print("Upload file...")
  243. with open(file_path, 'rb') as file:
  244. files = {
  245. 'file': (file_path, file, 'text/plain') # Make sure the file is uploaded with the appropriate MIME type
  246. }
  247. data = {
  248. "user": user,
  249. "type": "TXT" # Set the file type to TXT
  250. }
  251. response = requests.post(upload_url, headers=headers, files=files, data=data)
  252. if response.status_code == 201: # 201 means creation is successful
  253. print("File uploaded successfully")
  254. return response.json().get("id") # Get the uploaded file ID
  255. else:
  256. print(f"File upload failed, status code: {response.status_code}")
  257. return None
  258. except Exception as e:
  259. print(f"Error occurred: {str(e)}")
  260. return None
  261. def run_workflow(file_id, user, response_mode="blocking"):
  262. workflow_url = "https://api.dify.ai/v1/workflows/run"
  263. headers = {
  264. "Authorization": "Bearer app-xxxxxxxxx",
  265. "Content-Type": "application/json"
  266. }
  267. data = {
  268. "inputs": {
  269. "orig_mail": [{
  270. "transfer_method": "local_file",
  271. "upload_file_id": file_id,
  272. "type": "document"
  273. }]
  274. },
  275. "response_mode": response_mode,
  276. "user": user
  277. }
  278. try:
  279. print("Run Workflow...")
  280. response = requests.post(workflow_url, headers=headers, json=data)
  281. if response.status_code == 200:
  282. print("Workflow execution successful")
  283. return response.json()
  284. else:
  285. print(f"Workflow execution failed, status code: {response.status_code}")
  286. return {"status": "error", "message": f"Failed to execute workflow, status code: {response.status_code}"}
  287. except Exception as e:
  288. print(f"Error occurred: {str(e)}")
  289. return {"status": "error", "message": str(e)}
  290. # Usage Examples
  291. file_path = "{your_file_path}"
  292. user = "difyuser"
  293. # Upload files
  294. file_id = upload_file(file_path, user)
  295. if file_id:
  296. # The file was uploaded successfully, and the workflow continues to run
  297. result = run_workflow(file_id, user)
  298. print(result)
  299. else:
  300. print("File upload failed and workflow cannot be executed")
  301. ```
  302. </CodeGroup>
  303. </Col>
  304. </Row>
  305. ---
  306. <Heading
  307. url='/workflows/:workflow_id/run'
  308. method='POST'
  309. title='Execute Specific Workflow'
  310. name='#Execute-Specific-Workflow'
  311. />
  312. <Row>
  313. <Col>
  314. Execute a specific version of workflow by specifying the workflow ID in the path parameter.
  315. ### Path
  316. - `workflow_id` (string) Required Workflow ID to specify a specific version of workflow
  317. How to obtain: In the version history interface, click the copy icon on the right side of each version entry to copy the complete workflow ID. Each version entry contains a copyable ID field.
  318. ### Request Body
  319. - `inputs` (object) Required
  320. Allows the entry of various variable values defined by the App.
  321. 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.
  322. The workflow application requires at least one key/value pair to be inputted. The variable can be of File Array type.
  323. File Array type variable is suitable for inputting files combined with text understanding and answering questions, available only when the model supports file parsing and understanding capability.
  324. If the variable is of File Array type, the corresponding value should be a list whose elements contain following attributions:
  325. - `type` (string) Supported type:
  326. - `document` ('TXT', 'MD', 'MARKDOWN', 'PDF', 'HTML', 'XLSX', 'XLS', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB')
  327. - `image` ('JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG')
  328. - `audio` ('MP3', 'M4A', 'WAV', 'WEBM', 'AMR')
  329. - `video` ('MP4', 'MOV', 'MPEG', 'MPGA')
  330. - `custom` (Other file types)
  331. - `transfer_method` (string) Transfer method, `remote_url` for image URL / `local_file` for file upload
  332. - `url` (string) Image URL (when the transfer method is `remote_url`)
  333. - `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`)
  334. - `response_mode` (string) Required
  335. The mode of response return, supporting:
  336. - `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)).
  337. - `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)
  338. <i>Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.</i>
  339. - `user` (string) Required
  340. User identifier, used to define the identity of the end-user for retrieval and statistics.
  341. Should be uniquely defined by the developer within the application.
  342. <br/>
  343. <i>The user identifier should be consistent with the user passed in the message sending interface. The Service API does not share conversations created by the WebApp.</i>
  344. - `files` (array[object]) Optional
  345. - `trace_id` (string) Optional
  346. Trace ID. Used for integration with existing business trace components to achieve end-to-end distributed tracing. If not provided, the system will automatically generate a trace_id. Supports the following three ways to pass, in order of priority:
  347. 1. Header: via HTTP Header `X-Trace-Id`, highest priority.
  348. 2. Query parameter: via URL query parameter `trace_id`.
  349. 3. Request Body: via request body field `trace_id` (i.e., this field).
  350. ### Response
  351. When `response_mode` is `blocking`, return a CompletionResponse object.
  352. When `response_mode` is `streaming`, return a ChunkCompletionResponse stream.
  353. ### CompletionResponse
  354. Returns the App result, `Content-Type` is `application/json`.
  355. - `workflow_run_id` (string) Unique ID of workflow execution
  356. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  357. - `data` (object) detail of result
  358. - `id` (string) ID of workflow execution
  359. - `workflow_id` (string) ID of related workflow
  360. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  361. - `outputs` (json) Optional content of output
  362. - `error` (string) Optional reason of error
  363. - `elapsed_time` (float) Optional total seconds to be used
  364. - `total_tokens` (int) Optional tokens to be used
  365. - `total_steps` (int) default 0
  366. - `created_at` (timestamp) start time
  367. - `finished_at` (timestamp) end time
  368. ### ChunkCompletionResponse
  369. Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.
  370. Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:
  371. <CodeGroup>
  372. ```streaming {{ title: 'Response' }}
  373. data: {"event": "text_chunk", "workflow_run_id": "b85e5fc5-751b-454d-b14e-dc5f240b0a31", "task_id": "bd029338-b068-4d34-a331-fc85478922c2", "data": {"text": "\u4e3a\u4e86", "from_variable_selector": ["1745912968134", "text"]}}\n\n
  374. ```
  375. </CodeGroup>
  376. The structure of the streaming chunks varies depending on the `event`:
  377. - `event: workflow_started` workflow starts execution
  378. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  379. - `workflow_run_id` (string) Unique ID of workflow execution
  380. - `event` (string) fixed to `workflow_started`
  381. - `data` (object) detail
  382. - `id` (string) Unique ID of workflow execution
  383. - `workflow_id` (string) ID of related workflow
  384. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  385. - `event: node_started` node execution started
  386. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  387. - `workflow_run_id` (string) Unique ID of workflow execution
  388. - `event` (string) fixed to `node_started`
  389. - `data` (object) detail
  390. - `id` (string) Unique ID of workflow execution
  391. - `node_id` (string) ID of node
  392. - `node_type` (string) type of node
  393. - `title` (string) name of node
  394. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  395. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  396. - `inputs` (object) Contents of all preceding node variables used in the node
  397. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  398. - `event: text_chunk` Text fragment
  399. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  400. - `workflow_run_id` (string) Unique ID of workflow execution
  401. - `event` (string) fixed to `text_chunk`
  402. - `data` (object) detail
  403. - `text` (string) Text content
  404. - `from_variable_selector` (array) Text source path, helps developers understand which variable of which node the text is generated from
  405. - `event: node_finished` node execution finished, success and failure are different states in the same event
  406. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  407. - `workflow_run_id` (string) Unique ID of workflow execution
  408. - `event` (string) fixed to `node_finished`
  409. - `data` (object) detail
  410. - `id` (string) Unique ID of node execution
  411. - `node_id` (string) ID of node
  412. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  413. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  414. - `inputs` (object) Contents of all preceding node variables used in the node
  415. - `process_data` (json) Optional Process data of node
  416. - `outputs` (json) Optional content of output
  417. - `status` (string) status of execution `running` / `succeeded` / `failed` / `stopped`
  418. - `error` (string) Optional reason of error
  419. - `elapsed_time` (float) Optional total seconds to be used
  420. - `execution_metadata` (json) metadata
  421. - `total_tokens` (int) optional tokens to be used
  422. - `total_price` (decimal) optional total cost
  423. - `currency` (string) optional currency, such as `USD` / `RMB`
  424. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  425. - `event: workflow_finished` workflow execution finished, success and failure are different states in the same event
  426. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  427. - `workflow_run_id` (string) Unique ID of workflow execution
  428. - `event` (string) fixed to `workflow_finished`
  429. - `data` (object) detail
  430. - `id` (string) Unique ID of workflow execution
  431. - `workflow_id` (string) ID of related workflow
  432. - `status` (string) status of execution `running` / `succeeded` / `failed` / `stopped`
  433. - `outputs` (json) Optional content of output
  434. - `error` (string) Optional reason of error
  435. - `elapsed_time` (float) Optional total seconds to be used
  436. - `total_tokens` (int) Optional tokens to be used
  437. - `total_steps` (int) default 0
  438. - `created_at` (timestamp) start time
  439. - `finished_at` (timestamp) end time
  440. - `event: tts_message` TTS audio stream event, i.e., speech synthesis output. The content is an audio block in Mp3 format, encoded as a base64 string, which can be decoded directly when playing. (Only available when auto-play is enabled)
  441. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  442. - `message_id` (string) Unique message ID
  443. - `audio` (string) The audio block after speech synthesis is encoded as base64 text content, which can be directly base64 decoded and sent to the player when playing
  444. - `created_at` (int) Creation timestamp, e.g., 1705395332
  445. - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of audio stream return.
  446. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  447. - `message_id` (string) Unique message ID
  448. - `audio` (string) The end event has no audio, so this is an empty string
  449. - `created_at` (int) Creation timestamp, e.g., 1705395332
  450. - `event: ping` Ping event every 10s to keep the connection alive.
  451. ### Errors
  452. - 400, `invalid_param`, Invalid input parameters
  453. - 400, `app_unavailable`, App configuration unavailable
  454. - 400, `provider_not_initialize`, No available model credentials configured
  455. - 400, `provider_quota_exceeded`, Insufficient model call quota
  456. - 400, `model_currently_not_support`, Current model unavailable
  457. - 400, `workflow_not_found`, Specified workflow version not found
  458. - 400, `draft_workflow_error`, Cannot use draft workflow version
  459. - 400, `workflow_id_format_error`, Workflow ID format error, UUID format required
  460. - 400, `workflow_request_error`, Workflow execution failed
  461. - 500, Internal service error
  462. </Col>
  463. <Col sticky>
  464. <CodeGroup
  465. title="Request"
  466. tag="POST"
  467. label="/workflows/:workflow_id/run"
  468. targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/{workflow_id}/run' \\
  469. --header 'Authorization: Bearer {api_key}' \\
  470. --header 'Content-Type: application/json' \\
  471. --data-raw '{
  472. "inputs": ${JSON.stringify(props.inputs)},
  473. "response_mode": "streaming",
  474. "user": "abc-123"
  475. }'`}
  476. />
  477. <CodeGroup title="Example: file array as an input variable">
  478. ```json {{ title: 'File variable example' }}
  479. {
  480. "inputs": {
  481. "{variable_name}":
  482. [
  483. {
  484. "transfer_method": "local_file",
  485. "upload_file_id": "{upload_file_id}",
  486. "type": "{document_type}"
  487. }
  488. ]
  489. }
  490. }
  491. ```
  492. </CodeGroup>
  493. ### Blocking Mode
  494. <CodeGroup title="Response">
  495. ```json {{ title: 'Response' }}
  496. {
  497. "workflow_run_id": "djflajgkldjgd",
  498. "task_id": "9da23599-e713-473b-982c-4328d4f5c78a",
  499. "data": {
  500. "id": "fdlsjfjejkghjda",
  501. "workflow_id": "fldjaslkfjlsda",
  502. "status": "succeeded",
  503. "outputs": {
  504. "text": "Nice to meet you."
  505. },
  506. "error": null,
  507. "elapsed_time": 0.875,
  508. "total_tokens": 3562,
  509. "total_steps": 8,
  510. "created_at": 1705407629,
  511. "finished_at": 1727807631
  512. }
  513. }
  514. ```
  515. </CodeGroup>
  516. ### Streaming Mode
  517. <CodeGroup title="Response">
  518. ```streaming {{ title: 'Response' }}
  519. 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", "created_at": 1679586595}}
  520. 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}}
  521. 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}}
  522. 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}}
  523. 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"}
  524. 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": ""}
  525. ```
  526. </CodeGroup>
  527. </Col>
  528. </Row>
  529. ---
  530. <Heading
  531. url='/workflows/run/:workflow_run_id'
  532. method='GET'
  533. title='Get Workflow Run Detail'
  534. name='#get-workflow-run-detail'
  535. />
  536. <Row>
  537. <Col>
  538. Retrieve the current execution results of a workflow task based on the workflow execution ID.
  539. ### Path
  540. - `workflow_run_id` (string) Workflow run ID, can be obtained from the streaming chunk return
  541. ### Response
  542. - `id` (string) ID of workflow execution
  543. - `workflow_id` (string) ID of related workflow
  544. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  545. - `inputs` (json) content of input
  546. - `outputs` (json) content of output
  547. - `error` (string) reason of error
  548. - `total_steps` (int) total steps of task
  549. - `total_tokens` (int) total tokens to be used
  550. - `created_at` (timestamp) start time
  551. - `finished_at` (timestamp) end time
  552. - `elapsed_time` (float) total seconds to be used
  553. </Col>
  554. <Col sticky>
  555. ### Request Example
  556. <CodeGroup
  557. title="Request"
  558. tag="GET"
  559. label="/workflows/run/:workflow_run_id"
  560. targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id' \\
  561. -H 'Authorization: Bearer {api_key}' \\
  562. -H 'Content-Type: application/json'`}
  563. />
  564. ### Response Example
  565. <CodeGroup title="Response">
  566. ```json {{ title: 'Response' }}
  567. {
  568. "id": "b1ad3277-089e-42c6-9dff-6820d94fbc76",
  569. "workflow_id": "19eff89f-ec03-4f75-b0fc-897e7effea02",
  570. "status": "succeeded",
  571. "inputs": "{\"sys.files\": [], \"sys.user_id\": \"abc-123\"}",
  572. "outputs": null,
  573. "error": null,
  574. "total_steps": 3,
  575. "total_tokens": 0,
  576. "created_at": 1705407629,
  577. "finished_at": 1727807631,
  578. "elapsed_time": 30.098514399956912
  579. }
  580. ```
  581. </CodeGroup>
  582. </Col>
  583. </Row>
  584. ---
  585. <Heading
  586. url='/workflows/tasks/:task_id/stop'
  587. method='POST'
  588. title='Stop Generate'
  589. name='#stop-generatebacks'
  590. />
  591. <Row>
  592. <Col>
  593. Only supported in streaming mode.
  594. ### Path
  595. - `task_id` (string) Task ID, can be obtained from the streaming chunk return
  596. ### Request Body
  597. - `user` (string) Required
  598. User identifier, used to define the identity of the end-user, must be consistent with the user passed in the message sending interface. The Service API does not share conversations created by the WebApp.
  599. ### Response
  600. - `result` (string) Always returns "success"
  601. </Col>
  602. <Col sticky>
  603. ### Request Example
  604. <CodeGroup
  605. title="Request"
  606. tag="POST"
  607. label="/workflows/tasks/:task_id/stop"
  608. targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/tasks/:task_id/stop' \\
  609. -H 'Authorization: Bearer {api_key}' \\
  610. -H 'Content-Type: application/json' \\
  611. --data-raw '{"user": "abc-123"}'`}
  612. />
  613. ### Response Example
  614. <CodeGroup title="Response">
  615. ```json {{ title: 'Response' }}
  616. {
  617. "result": "success"
  618. }
  619. ```
  620. </CodeGroup>
  621. </Col>
  622. </Row>
  623. ---
  624. <Heading
  625. url='/files/upload'
  626. method='POST'
  627. title='File Upload'
  628. name='#file-upload'
  629. />
  630. <Row>
  631. <Col>
  632. Upload a file for use when sending messages, enabling multimodal understanding of images and text.
  633. Supports any formats that are supported by your workflow.
  634. Uploaded files are for use by the current end-user only.
  635. ### Request Body
  636. This interface requires a `multipart/form-data` request.
  637. - `file` (File) Required
  638. The file to be uploaded.
  639. - `user` (string) Required
  640. User identifier, defined by the developer's rules, must be unique within the application. The Service API does not share conversations created by the WebApp.
  641. ### Response
  642. After a successful upload, the server will return the file's ID and related information.
  643. - `id` (uuid) ID
  644. - `name` (string) File name
  645. - `size` (int) File size (bytes)
  646. - `extension` (string) File extension
  647. - `mime_type` (string) File mime-type
  648. - `created_by` (uuid) End-user ID
  649. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  650. ### Errors
  651. - 400, `no_file_uploaded`, a file must be provided
  652. - 400, `too_many_files`, currently only one file is accepted
  653. - 400, `unsupported_preview`, the file does not support preview
  654. - 400, `unsupported_estimate`, the file does not support estimation
  655. - 413, `file_too_large`, the file is too large
  656. - 415, `unsupported_file_type`, unsupported extension, currently only document files are accepted
  657. - 503, `s3_connection_failed`, unable to connect to S3 service
  658. - 503, `s3_permission_denied`, no permission to upload files to S3
  659. - 503, `s3_file_too_large`, file exceeds S3 size limit
  660. - 500, internal server error
  661. </Col>
  662. <Col sticky>
  663. ### Request Example
  664. <CodeGroup
  665. title="Request"
  666. tag="POST"
  667. label="/files/upload"
  668. targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\
  669. --header 'Authorization: Bearer {api_key}' \\
  670. --form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\
  671. --form 'user=abc-123'`}
  672. />
  673. ### Response Example
  674. <CodeGroup title="Response">
  675. ```json {{ title: 'Response' }}
  676. {
  677. "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
  678. "name": "example.png",
  679. "size": 1024,
  680. "extension": "png",
  681. "mime_type": "image/png",
  682. "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",
  683. "created_at": 1577836800,
  684. }
  685. ```
  686. </CodeGroup>
  687. </Col>
  688. </Row>
  689. ---
  690. <Heading
  691. url='/files/:file_id/preview'
  692. method='GET'
  693. title='File Preview'
  694. name='#file-preview'
  695. />
  696. <Row>
  697. <Col>
  698. Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API.
  699. <i>Files can only be accessed if they belong to messages within the requesting application.</i>
  700. ### Path Parameters
  701. - `file_id` (string) Required
  702. The unique identifier of the file to preview, obtained from the File Upload API response.
  703. ### Query Parameters
  704. - `as_attachment` (boolean) Optional
  705. Whether to force download the file as an attachment. Default is `false` (preview in browser).
  706. ### Response
  707. Returns the file content with appropriate headers for browser display or download.
  708. - `Content-Type` Set based on file mime type
  709. - `Content-Length` File size in bytes (if available)
  710. - `Content-Disposition` Set to "attachment" if `as_attachment=true`
  711. - `Cache-Control` Caching headers for performance
  712. - `Accept-Ranges` Set to "bytes" for audio/video files
  713. ### Errors
  714. - 400, `invalid_param`, abnormal parameter input
  715. - 403, `file_access_denied`, file access denied or file does not belong to current application
  716. - 404, `file_not_found`, file not found or has been deleted
  717. - 500, internal server error
  718. </Col>
  719. <Col sticky>
  720. ### Request Example
  721. <CodeGroup
  722. title="Request"
  723. tag="GET"
  724. label="/files/:file_id/preview"
  725. targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\
  726. --header 'Authorization: Bearer {api_key}'`}
  727. />
  728. ### Download as Attachment
  729. <CodeGroup
  730. title="Download Request"
  731. tag="GET"
  732. label="/files/:file_id/preview?as_attachment=true"
  733. targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\
  734. --header 'Authorization: Bearer {api_key}' \\
  735. --output downloaded_file.png`}
  736. />
  737. ### Response Headers Example
  738. <CodeGroup title="Response Headers">
  739. ```http {{ title: 'Headers - Image Preview' }}
  740. Content-Type: image/png
  741. Content-Length: 1024
  742. Cache-Control: public, max-age=3600
  743. ```
  744. </CodeGroup>
  745. ### Download Response Headers
  746. <CodeGroup title="Download Response Headers">
  747. ```http {{ title: 'Headers - File Download' }}
  748. Content-Type: image/png
  749. Content-Length: 1024
  750. Content-Disposition: attachment; filename*=UTF-8''example.png
  751. Cache-Control: public, max-age=3600
  752. ```
  753. </CodeGroup>
  754. </Col>
  755. </Row>
  756. ---
  757. <Heading
  758. url='/workflows/logs'
  759. method='GET'
  760. title='Get Workflow Logs'
  761. name='#Get-Workflow-Logs'
  762. />
  763. <Row>
  764. <Col>
  765. Returns workflow logs, with the first page returning the latest `{limit}` messages, i.e., in reverse order.
  766. ### Query
  767. <Properties>
  768. <Property name='keyword' type='string' key='keyword'>
  769. Keyword to search
  770. </Property>
  771. <Property name='status' type='string' key='status'>
  772. succeeded/failed/stopped
  773. </Property>
  774. <Property name='page' type='int' key='page'>
  775. current page, default is 1.
  776. </Property>
  777. <Property name='limit' type='int' key='limit'>
  778. How many chat history messages to return in one request, default is 20.
  779. </Property>
  780. <Property name='created_by_end_user_session_id' type='str' key='created_by_end_user_session_id'>
  781. Created by which endUser, for example, `abc-123`.
  782. </Property>
  783. <Property name='created_by_account' type='str' key='created_by_account'>
  784. Created by which email account, for example, lizb@test.com.
  785. </Property>
  786. </Properties>
  787. ### Response
  788. - `page` (int) Current page
  789. - `limit` (int) Number of returned items, if input exceeds system limit, returns system limit amount
  790. - `total` (int) Number of total items
  791. - `has_more` (bool) Whether there is a next page
  792. - `data` (array[object]) Log list
  793. - `id` (string) ID
  794. - `workflow_run` (object) Workflow run
  795. - `id` (string) ID
  796. - `version` (string) Version
  797. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  798. - `error` (string) Optional reason of error
  799. - `elapsed_time` (float) total seconds to be used
  800. - `total_tokens` (int) tokens to be used
  801. - `total_steps` (int) default 0
  802. - `created_at` (timestamp) start time
  803. - `finished_at` (timestamp) end time
  804. - `created_from` (string) Created from
  805. - `created_by_role` (string) Created by role
  806. - `created_by_account` (string) Optional Created by account
  807. - `created_by_end_user` (object) Created by end user
  808. - `id` (string) ID
  809. - `type` (string) Type
  810. - `is_anonymous` (bool) Is anonymous
  811. - `session_id` (string) Session ID
  812. - `created_at` (timestamp) create time
  813. </Col>
  814. <Col sticky>
  815. <CodeGroup
  816. title="Request"
  817. tag="GET"
  818. label="/workflows/logs"
  819. targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/logs'\\
  820. --header 'Authorization: Bearer {api_key}'`}
  821. />
  822. ### Response Example
  823. <CodeGroup title="Response">
  824. ```json {{ title: 'Response' }}
  825. {
  826. "page": 1,
  827. "limit": 1,
  828. "total": 7,
  829. "has_more": true,
  830. "data": [
  831. {
  832. "id": "e41b93f1-7ca2-40fd-b3a8-999aeb499cc0",
  833. "workflow_run": {
  834. "id": "c0640fc8-03ef-4481-a96c-8a13b732a36e",
  835. "version": "2024-08-01 12:17:09.771832",
  836. "status": "succeeded",
  837. "error": null,
  838. "elapsed_time": 1.3588523610014818,
  839. "total_tokens": 0,
  840. "total_steps": 3,
  841. "created_at": 1726139643,
  842. "finished_at": 1726139644
  843. },
  844. "created_from": "service-api",
  845. "created_by_role": "end_user",
  846. "created_by_account": null,
  847. "created_by_end_user": {
  848. "id": "7f7d9117-dd9d-441d-8970-87e5e7e687a3",
  849. "type": "service_api",
  850. "is_anonymous": false,
  851. "session_id": "abc-123"
  852. },
  853. "created_at": 1726139644
  854. }
  855. ]
  856. }
  857. ```
  858. </CodeGroup>
  859. </Col>
  860. </Row>
  861. ---
  862. <Heading
  863. url='/info'
  864. method='GET'
  865. title='Get Application Basic Information'
  866. name='#info'
  867. />
  868. <Row>
  869. <Col>
  870. Used to get basic information about this application
  871. ### Response
  872. - `name` (string) application name
  873. - `description` (string) application description
  874. - `tags` (array[string]) application tags
  875. - `mode` (string) application mode
  876. - `author_name` (string) application author name
  877. </Col>
  878. <Col>
  879. <CodeGroup
  880. title="Request"
  881. tag="GET"
  882. label="/info"
  883. targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\
  884. -H 'Authorization: Bearer {api_key}'`}
  885. />
  886. <CodeGroup title="Response">
  887. ```json {{ title: 'Response' }}
  888. {
  889. "name": "My App",
  890. "description": "This is my app.",
  891. "tags": [
  892. "tag1",
  893. "tag2"
  894. ],
  895. "mode": "workflow",
  896. "author_name": "Dify"
  897. }
  898. ```
  899. </CodeGroup>
  900. </Col>
  901. </Row>
  902. ---
  903. <Heading
  904. url='/parameters'
  905. method='GET'
  906. title='Get Application Parameters Information'
  907. name='#parameters'
  908. />
  909. <Row>
  910. <Col>
  911. Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.
  912. ### Response
  913. - `user_input_form` (array[object]) User input form configuration
  914. - `text-input` (object) Text input control
  915. - `label` (string) Variable display label name
  916. - `variable` (string) Variable ID
  917. - `required` (bool) Whether it is required
  918. - `default` (string) Default value
  919. - `paragraph` (object) Paragraph text input control
  920. - `label` (string) Variable display label name
  921. - `variable` (string) Variable ID
  922. - `required` (bool) Whether it is required
  923. - `default` (string) Default value
  924. - `select` (object) Dropdown control
  925. - `label` (string) Variable display label name
  926. - `variable` (string) Variable ID
  927. - `required` (bool) Whether it is required
  928. - `default` (string) Default value
  929. - `options` (array[string]) Option values
  930. - `file_upload` (object) File upload configuration
  931. - `document` (object) Document settings
  932. Currently only supports document types: `txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`.
  933. - `enabled` (bool) Whether it is enabled
  934. - `number_limits` (int) Document number limit, default is 3
  935. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  936. - `image` (object) Image settings
  937. Currently only supports image types: `png`, `jpg`, `jpeg`, `webp`, `gif`.
  938. - `enabled` (bool) Whether it is enabled
  939. - `number_limits` (int) Image number limit, default is 3
  940. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  941. - `audio` (object) Audio settings
  942. Currently only supports audio types: `mp3`, `m4a`, `wav`, `webm`, `amr`.
  943. - `enabled` (bool) Whether it is enabled
  944. - `number_limits` (int) Audio number limit, default is 3
  945. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  946. - `video` (object) Video settings
  947. Currently only supports video types: `mp4`, `mov`, `mpeg`, `mpga`.
  948. - `enabled` (bool) Whether it is enabled
  949. - `number_limits` (int) Video number limit, default is 3
  950. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  951. - `custom` (object) Custom settings
  952. - `enabled` (bool) Whether it is enabled
  953. - `number_limits` (int) Custom number limit, default is 3
  954. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  955. - `system_parameters` (object) System parameters
  956. - `file_size_limit` (int) Document upload size limit (MB)
  957. - `image_file_size_limit` (int) Image file upload size limit (MB)
  958. - `audio_file_size_limit` (int) Audio file upload size limit (MB)
  959. - `video_file_size_limit` (int) Video file upload size limit (MB)
  960. </Col>
  961. <Col sticky>
  962. <CodeGroup
  963. title="Request"
  964. tag="GET"
  965. label="/parameters"
  966. targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}
  967. />
  968. <CodeGroup title="Response">
  969. ```json {{ title: 'Response' }}
  970. {
  971. "user_input_form": [
  972. {
  973. "paragraph": {
  974. "label": "Query",
  975. "variable": "query",
  976. "required": true,
  977. "default": ""
  978. }
  979. }
  980. ],
  981. "file_upload": {
  982. "image": {
  983. "enabled": false,
  984. "number_limits": 3,
  985. "detail": "high",
  986. "transfer_methods": [
  987. "remote_url",
  988. "local_file"
  989. ]
  990. }
  991. },
  992. "system_parameters": {
  993. "file_size_limit": 15,
  994. "image_file_size_limit": 10,
  995. "audio_file_size_limit": 50,
  996. "video_file_size_limit": 100
  997. }
  998. }
  999. ```
  1000. </CodeGroup>
  1001. </Col>
  1002. </Row>
  1003. ---
  1004. <Heading
  1005. url='/site'
  1006. method='GET'
  1007. title='Get Application WebApp Settings'
  1008. name='#site'
  1009. />
  1010. <Row>
  1011. <Col>
  1012. Used to get the WebApp settings of the application.
  1013. ### Response
  1014. - `title` (string) WebApp name
  1015. - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture
  1016. - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL.
  1017. - `icon_background` (string) Background color in hex format
  1018. - `icon_url` (string) Icon URL
  1019. - `description` (string) Description
  1020. - `copyright` (string) Copyright information
  1021. - `privacy_policy` (string) Privacy policy link
  1022. - `custom_disclaimer` (string) Custom disclaimer
  1023. - `default_language` (string) Default language
  1024. - `show_workflow_steps` (bool) Whether to show workflow details
  1025. </Col>
  1026. <Col>
  1027. <CodeGroup
  1028. title="Request"
  1029. tag="POST"
  1030. label="/meta"
  1031. targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\
  1032. -H 'Authorization: Bearer {api_key}'`}
  1033. />
  1034. <CodeGroup title="Response">
  1035. ```json {{ title: 'Response' }}
  1036. {
  1037. "title": "My App",
  1038. "icon_type": "emoji",
  1039. "icon": "😄",
  1040. "icon_background": "#FFEAD5",
  1041. "icon_url": null,
  1042. "description": "This is my app.",
  1043. "copyright": "all rights reserved",
  1044. "privacy_policy": "",
  1045. "custom_disclaimer": "All generated by AI",
  1046. "default_language": "en-US",
  1047. "show_workflow_steps": false,
  1048. }
  1049. ```
  1050. </CodeGroup>
  1051. </Col>
  1052. </Row>
  1053. ___