Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

template.en.mdx 29KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. import { CodeGroup } from '../code.tsx'
  2. import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from '../md.tsx'
  3. # Completion App API
  4. The text generation application 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='/completion-messages'
  17. method='POST'
  18. title='Create Completion Message'
  19. name='#Create-Completion-Message'
  20. />
  21. <Row>
  22. <Col>
  23. Send a request to the text generation application.
  24. ### Request Body
  25. <Properties>
  26. <Property name='inputs' type='object' key='inputs'>
  27. Allows the entry of various variable values defined by the App.
  28. 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.
  29. The text generation application requires at least one key/value pair to be inputted.
  30. - `query` (string) Required
  31. The input text, the content to be processed.
  32. </Property>
  33. <Property name='response_mode' type='string' key='response_mode'>
  34. The mode of response return, supporting:
  35. - `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)).
  36. - `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)
  37. <i>Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.</i>
  38. </Property>
  39. <Property name='user' type='string' key='user'>
  40. User identifier, used to define the identity of the end-user, convenient for retrieval and statistics.
  41. The rules are defined by the developer and need to ensure that the user identifier is unique within the application. The Service API does not share conversations created by the WebApp.
  42. </Property>
  43. <Property name='files' type='array[object]' key='files'>
  44. File list, suitable for inputting files (images) combined with text understanding and answering questions, available only when the model supports Vision capability.
  45. - `type` (string) Supported type: `image` (currently only supports image type)
  46. - `transfer_method` (string) Transfer method, `remote_url` for image URL / `local_file` for file upload
  47. - `url` (string) Image URL (when the transfer method is `remote_url`)
  48. - `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`)
  49. </Property>
  50. </Properties>
  51. ### Response
  52. When `response_mode` is `blocking`, return a CompletionResponse object.
  53. When `response_mode` is `streaming`, return a ChunkCompletionResponse stream.
  54. ### ChatCompletionResponse
  55. Returns the complete App result, `Content-Type` is `application/json`.
  56. - `message_id` (string) Unique message ID
  57. - `mode` (string) App mode, fixed as `chat`
  58. - `answer` (string) Complete response content
  59. - `metadata` (object) Metadata
  60. - `usage` (Usage) Model usage information
  61. - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List
  62. - `created_at` (int) Message creation timestamp, e.g., 1705395332
  63. ### ChunkChatCompletionResponse
  64. Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.
  65. Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:
  66. <CodeGroup>
  67. ```streaming {{ title: 'Response' }}
  68. data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n
  69. ```
  70. </CodeGroup>
  71. The structure of the streaming chunks varies depending on the `event`:
  72. - `event: message` LLM returns text chunk event, i.e., the complete text is output in a chunked fashion.
  73. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  74. - `message_id` (string) Unique message ID
  75. - `answer` (string) LLM returned text chunk content
  76. - `created_at` (int) Creation timestamp, e.g., 1705395332
  77. - `event: message_end` Message end event, receiving this event means streaming has ended.
  78. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  79. - `message_id` (string) Unique message ID
  80. - `metadata` (object) Metadata
  81. - `usage` (Usage) Model usage information
  82. - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List
  83. - `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)
  84. - `task_id` (string) Task ID, used for request tracking and the stop response interface below
  85. - `message_id` (string) Unique message ID
  86. - `audio` (string) The audio after speech synthesis, encoded in base64 text content, when playing, simply decode the base64 and feed it into the player
  87. - `created_at` (int) Creation timestamp, e.g.: 1705395332
  88. - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of the audio stream.
  89. - `task_id` (string) Task ID, used for request tracking and the stop response interface below
  90. - `message_id` (string) Unique message ID
  91. - `audio` (string) The end event has no audio, so this is an empty string
  92. - `created_at` (int) Creation timestamp, e.g.: 1705395332
  93. - `event: message_replace` Message content replacement event.
  94. 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.
  95. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  96. - `message_id` (string) Unique message ID
  97. - `answer` (string) Replacement content (directly replaces all LLM reply text)
  98. - `created_at` (int) Creation timestamp, e.g., 1705395332
  99. - `event: error`
  100. 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.
  101. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  102. - `message_id` (string) Unique message ID
  103. - `status` (int) HTTP status code
  104. - `code` (string) Error code
  105. - `message` (string) Error message
  106. - `event: ping` Ping event every 10 seconds to keep the connection alive.
  107. ### Errors
  108. - 404, Conversation does not exists
  109. - 400, `invalid_param`, abnormal parameter input
  110. - 400, `app_unavailable`, App configuration unavailable
  111. - 400, `provider_not_initialize`, no available model credential configuration
  112. - 400, `provider_quota_exceeded`, model invocation quota insufficient
  113. - 400, `model_currently_not_support`, current model unavailable
  114. - 400, `completion_request_error`, text generation failed
  115. - 500, internal server error
  116. </Col>
  117. <Col sticky>
  118. <CodeGroup
  119. title="Request"
  120. tag="POST"
  121. label="/completion-messages"
  122. targetCode={`curl -X POST '${props.appDetail.api_base_url}/completion-messages' \\
  123. --header 'Authorization: Bearer {api_key}' \\
  124. --header 'Content-Type: application/json' \\
  125. --data-raw '{
  126. "inputs": {"query": "Hello, world!"},
  127. "response_mode": "streaming",
  128. "user": "abc-123"
  129. }'`}
  130. />
  131. ### Blocking Mode
  132. <CodeGroup title="Response">
  133. ```json {{ title: 'Response' }}
  134. {
  135. "event": "message",
  136. "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",
  137. "mode": "completion",
  138. "answer": "Hello World!...",
  139. "metadata": {
  140. "usage": {
  141. "prompt_tokens": 1033,
  142. "prompt_unit_price": "0.001",
  143. "prompt_price_unit": "0.001",
  144. "prompt_price": "0.0010330",
  145. "completion_tokens": 128,
  146. "completion_unit_price": "0.002",
  147. "completion_price_unit": "0.001",
  148. "completion_price": "0.0002560",
  149. "total_tokens": 1161,
  150. "total_price": "0.0012890",
  151. "currency": "USD",
  152. "latency": 0.7682376249867957
  153. }
  154. },
  155. "created_at": 1705407629
  156. }
  157. ```
  158. </CodeGroup>
  159. ### Streaming Mode
  160. <CodeGroup title="Response">
  161. ```streaming {{ title: 'Response' }}
  162. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " I", "created_at": 1679586595}
  163. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": "'m", "created_at": 1679586595}
  164. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " glad", "created_at": 1679586595}
  165. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " to", "created_at": 1679586595}
  166. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " meet", "created_at": 1679586595}
  167. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " you", "created_at": 1679586595}
  168. data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "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}}}
  169. 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"}
  170. 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": ""}
  171. ```
  172. </CodeGroup>
  173. </Col>
  174. </Row>
  175. ---
  176. <Heading
  177. url='/files/upload'
  178. method='POST'
  179. title='File Upload'
  180. name='#file-upload'
  181. />
  182. <Row>
  183. <Col>
  184. Upload a file (currently only images are supported) for use when sending messages, enabling multimodal understanding of images and text.
  185. Supports png, jpg, jpeg, webp, gif formats.
  186. <i>Uploaded files are for use by the current end-user only.</i>
  187. ### Request Body
  188. This interface requires a `multipart/form-data` request.
  189. - `file` (File) Required
  190. The file to be uploaded.
  191. - `user` (string) Required
  192. 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.
  193. ### Response
  194. After a successful upload, the server will return the file's ID and related information.
  195. - `id` (uuid) ID
  196. - `name` (string) File name
  197. - `size` (int) File size (bytes)
  198. - `extension` (string) File extension
  199. - `mime_type` (string) File mime-type
  200. - `created_by` (uuid) End-user ID
  201. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  202. ### Errors
  203. - 400, `no_file_uploaded`, a file must be provided
  204. - 400, `too_many_files`, currently only one file is accepted
  205. - 400, `unsupported_preview`, the file does not support preview
  206. - 400, `unsupported_estimate`, the file does not support estimation
  207. - 413, `file_too_large`, the file is too large
  208. - 415, `unsupported_file_type`, unsupported extension, currently only document files are accepted
  209. - 503, `s3_connection_failed`, unable to connect to S3 service
  210. - 503, `s3_permission_denied`, no permission to upload files to S3
  211. - 503, `s3_file_too_large`, file exceeds S3 size limit
  212. - 500, internal server error
  213. </Col>
  214. <Col sticky>
  215. ### Request Example
  216. <CodeGroup
  217. title="Request"
  218. tag="POST"
  219. label="/files/upload"
  220. targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\
  221. --header 'Authorization: Bearer {api_key}' \\
  222. --form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\
  223. --form 'user=abc-123'`}
  224. />
  225. ### Response Example
  226. <CodeGroup title="Response">
  227. ```json {{ title: 'Response' }}
  228. {
  229. "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
  230. "name": "example.png",
  231. "size": 1024,
  232. "extension": "png",
  233. "mime_type": "image/png",
  234. "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",
  235. "created_at": 1577836800,
  236. }
  237. ```
  238. </CodeGroup>
  239. </Col>
  240. </Row>
  241. ---
  242. <Heading
  243. url='/files/:file_id/preview'
  244. method='GET'
  245. title='File Preview'
  246. name='#file-preview'
  247. />
  248. <Row>
  249. <Col>
  250. Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API.
  251. <i>Files can only be accessed if they belong to messages within the requesting application.</i>
  252. ### Path Parameters
  253. - `file_id` (string) Required
  254. The unique identifier of the file to preview, obtained from the File Upload API response.
  255. ### Query Parameters
  256. - `as_attachment` (boolean) Optional
  257. Whether to force download the file as an attachment. Default is `false` (preview in browser).
  258. ### Response
  259. Returns the file content with appropriate headers for browser display or download.
  260. - `Content-Type` Set based on file mime type
  261. - `Content-Length` File size in bytes (if available)
  262. - `Content-Disposition` Set to "attachment" if `as_attachment=true`
  263. - `Cache-Control` Caching headers for performance
  264. - `Accept-Ranges` Set to "bytes" for audio/video files
  265. ### Errors
  266. - 400, `invalid_param`, abnormal parameter input
  267. - 403, `file_access_denied`, file access denied or file does not belong to current application
  268. - 404, `file_not_found`, file not found or has been deleted
  269. - 500, internal server error
  270. </Col>
  271. <Col sticky>
  272. ### Request Example
  273. <CodeGroup
  274. title="Request"
  275. tag="GET"
  276. label="/files/:file_id/preview"
  277. targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\
  278. --header 'Authorization: Bearer {api_key}'`}
  279. />
  280. ### Download as Attachment
  281. <CodeGroup
  282. title="Download
  283. Request"
  284. tag="GET"
  285. label="/files/:file_id/preview?as_attachment=true"
  286. targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\
  287. --header 'Authorization: Bearer {api_key}' \\
  288. --output downloaded_file.png`}
  289. />
  290. ### Response Headers Example
  291. <CodeGroup title="Response Headers">
  292. ```http {{ title: 'Headers - Image Preview' }}
  293. Content-Type: image/png
  294. Content-Length: 1024
  295. Cache-Control: public, max-age=3600
  296. ```
  297. </CodeGroup>
  298. ### Download Response Headers
  299. <CodeGroup title="Download Response Headers">
  300. ```http {{ title: 'Headers - File Download' }}
  301. Content-Type: image/png
  302. Content-Length: 1024
  303. Content-Disposition: attachment; filename*=UTF-8''example.png
  304. Cache-Control: public, max-age=3600
  305. ```
  306. </CodeGroup>
  307. </Col>
  308. </Row>
  309. ---
  310. <Heading
  311. url='/completion-messages/:task_id/stop'
  312. method='POST'
  313. title='Stop Generate'
  314. name='#stop-generatebacks'
  315. />
  316. <Row>
  317. <Col>
  318. Only supported in streaming mode.
  319. ### Path
  320. - `task_id` (string) Task ID, can be obtained from the streaming chunk return
  321. Request Body
  322. - `user` (string) Required
  323. User identifier, used to define the identity of the end-user, must be consistent with the user passed in the send message interface. The Service API does not share conversations created by the WebApp.
  324. ### Response
  325. - `result` (string) Always returns "success"
  326. </Col>
  327. <Col sticky>
  328. ### Request Example
  329. <CodeGroup
  330. title="Request"
  331. tag="POST"
  332. label="/completion-messages/:task_id/stop"
  333. targetCode={`curl -X POST '${props.appDetail.api_base_url}/completion-messages/:task_id/stop' \\
  334. -H 'Authorization: Bearer {api_key}' \\
  335. -H 'Content-Type: application/json' \\
  336. --data-raw '{ "user": "abc-123"}'`}
  337. />
  338. ### Response Example
  339. <CodeGroup title="Response">
  340. ```json {{ title: 'Response' }}
  341. {
  342. "result": "success"
  343. }
  344. ```
  345. </CodeGroup>
  346. </Col>
  347. </Row>
  348. ---
  349. <Heading
  350. url='/messages/:message_id/feedbacks'
  351. method='POST'
  352. title='Message Feedback'
  353. name='#feedbacks'
  354. />
  355. <Row>
  356. <Col>
  357. End-users can provide feedback messages, facilitating application developers to optimize expected outputs.
  358. ### Path
  359. <Properties>
  360. <Property name='message_id' type='string' key='message_id'>
  361. Message ID
  362. </Property>
  363. </Properties>
  364. ### Request Body
  365. <Properties>
  366. <Property name='rating' type='string' key='rating'>
  367. Upvote as `like`, downvote as `dislike`, revoke upvote as `null`
  368. </Property>
  369. <Property name='user' type='string' key='user'>
  370. User identifier, defined by the developer's rules, must be unique within the application.
  371. </Property>
  372. <Property name='content' type='string' key='content'>
  373. The specific content of message feedback.
  374. </Property>
  375. </Properties>
  376. ### Response
  377. - `result` (string) Always returns "success"
  378. </Col>
  379. <Col sticky>
  380. <CodeGroup
  381. title="Request"
  382. tag="POST"
  383. label="/messages/:message_id/feedbacks"
  384. targetCode={`curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks \\
  385. --header 'Authorization: Bearer {api_key}' \\
  386. --header 'Content-Type: application/json' \\
  387. --data-raw '{
  388. "rating": "like",
  389. "user": "abc-123",
  390. "content": "message feedback information"
  391. }'`}
  392. />
  393. <CodeGroup title="Response">
  394. ```json {{ title: 'Response' }}
  395. {
  396. "result": "success"
  397. }
  398. ```
  399. </CodeGroup>
  400. </Col>
  401. </Row>
  402. ---
  403. <Heading
  404. url='/app/feedbacks'
  405. method='GET'
  406. title='Get feedbacks of application'
  407. name='#app-feedbacks'
  408. />
  409. <Row>
  410. <Col>
  411. Get application's feedbacks.
  412. ### Query
  413. <Properties>
  414. <Property name='page' type='string' key='page'>
  415. (optional)pagination,default:1
  416. </Property>
  417. </Properties>
  418. <Properties>
  419. <Property name='limit' type='string' key='limit'>
  420. (optional) records per page default:20
  421. </Property>
  422. </Properties>
  423. ### Response
  424. - `data` (List) return apps feedback list.
  425. </Col>
  426. <Col sticky>
  427. <CodeGroup
  428. title="Request"
  429. tag="GET"
  430. label="/app/feedbacks"
  431. targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}
  432. />
  433. <CodeGroup title="Response">
  434. ```json {{ title: 'Response' }}
  435. {
  436. "data": [
  437. {
  438. "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",
  439. "app_id": "f252d396-fe48-450e-94ec-e184218e7346",
  440. "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",
  441. "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",
  442. "rating": "like",
  443. "content": "message feedback information-3",
  444. "from_source": "user",
  445. "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",
  446. "from_account_id": null,
  447. "created_at": "2025-04-24T09:24:38",
  448. "updated_at": "2025-04-24T09:24:38"
  449. }
  450. ]
  451. }
  452. ```
  453. </CodeGroup>
  454. </Col>
  455. </Row>
  456. ---
  457. <Heading
  458. url='/text-to-audio'
  459. method='POST'
  460. title='Text to Audio'
  461. name='#audio'
  462. />
  463. <Row>
  464. <Col>
  465. Text to speech.
  466. ### Request Body
  467. <Properties>
  468. <Property name='message_id' type='str' key='message_id'>
  469. 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.
  470. </Property>
  471. <Property name='text' type='str' key='text'>
  472. Speech generated content.
  473. </Property>
  474. <Property name='user' type='string' key='user'>
  475. The user identifier, defined by the developer, must ensure uniqueness within the app.
  476. </Property>
  477. </Properties>
  478. </Col>
  479. <Col sticky>
  480. <CodeGroup
  481. title="Request"
  482. tag="POST"
  483. label="/text-to-audio"
  484. targetCode={`curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \\
  485. --header 'Authorization: Bearer {api_key}' \\
  486. --header 'Content-Type: application/json' \\
  487. --data-raw '{
  488. "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",
  489. "text": "Hello Dify",
  490. "user": "abc-123"
  491. }'`}
  492. />
  493. <CodeGroup title="headers">
  494. ```json {{ title: 'headers' }}
  495. {
  496. "Content-Type": "audio/wav"
  497. }
  498. ```
  499. </CodeGroup>
  500. </Col>
  501. </Row>
  502. ---
  503. <Heading
  504. url='/info'
  505. method='GET'
  506. title='Get Application Basic Information'
  507. name='#info'
  508. />
  509. <Row>
  510. <Col>
  511. Used to get basic information about this application
  512. ### Response
  513. - `name` (string) application name
  514. - `description` (string) application description
  515. - `tags` (array[string]) application tags
  516. - `mode` (string) application mode
  517. - `author_name` (string) author name
  518. </Col>
  519. <Col>
  520. <CodeGroup
  521. title="Request"
  522. tag="GET"
  523. label="/info"
  524. targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\
  525. -H 'Authorization: Bearer {api_key}'`}
  526. />
  527. <CodeGroup title="Response">
  528. ```json {{ title: 'Response' }}
  529. {
  530. "name": "My App",
  531. "description": "This is my app.",
  532. "tags": [
  533. "tag1",
  534. "tag2"
  535. ],
  536. "mode": "chat",
  537. "author_name": "Dify"
  538. }
  539. ```
  540. </CodeGroup>
  541. </Col>
  542. </Row>
  543. ---
  544. <Heading
  545. url='/parameters'
  546. method='GET'
  547. title='Get Application Parameters Information'
  548. name='#parameters'
  549. />
  550. <Row>
  551. <Col>
  552. Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.
  553. ### Response
  554. - `opening_statement` (string) Opening statement
  555. - `suggested_questions` (array[string]) List of suggested questions for the opening
  556. - `suggested_questions_after_answer` (object) Suggest questions after enabling the answer.
  557. - `enabled` (bool) Whether it is enabled
  558. - `speech_to_text` (object) Speech to text
  559. - `enabled` (bool) Whether it is enabled
  560. - `retriever_resource` (object) Citation and Attribution
  561. - `enabled` (bool) Whether it is enabled
  562. - `annotation_reply` (object) Annotation reply
  563. - `enabled` (bool) Whether it is enabled
  564. - `user_input_form` (array[object]) User input form configuration
  565. - `text-input` (object) Text input control
  566. - `label` (string) Variable display label name
  567. - `variable` (string) Variable ID
  568. - `required` (bool) Whether it is required
  569. - `default` (string) Default value
  570. - `paragraph` (object) Paragraph text input control
  571. - `label` (string) Variable display label name
  572. - `variable` (string) Variable ID
  573. - `required` (bool) Whether it is required
  574. - `default` (string) Default value
  575. - `select` (object) Dropdown control
  576. - `label` (string) Variable display label name
  577. - `variable` (string) Variable ID
  578. - `required` (bool) Whether it is required
  579. - `default` (string) Default value
  580. - `options` (array[string]) Option values
  581. - `file_upload` (object) File upload configuration
  582. - `document` (object) Document settings
  583. Currently only supports document types: `txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`.
  584. - `enabled` (bool) Whether it is enabled
  585. - `number_limits` (int) Document number limit, default is 3
  586. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  587. - `image` (object) Image settings
  588. Currently only supports image types: `png`, `jpg`, `jpeg`, `webp`, `gif`.
  589. - `enabled` (bool) Whether it is enabled
  590. - `number_limits` (int) Image number limit, default is 3
  591. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  592. - `audio` (object) Audio settings
  593. Currently only supports audio types: `mp3`, `m4a`, `wav`, `webm`, `amr`.
  594. - `enabled` (bool) Whether it is enabled
  595. - `number_limits` (int) Audio number limit, default is 3
  596. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  597. - `video` (object) Video settings
  598. Currently only supports video types: `mp4`, `mov`, `mpeg`, `mpga`.
  599. - `enabled` (bool) Whether it is enabled
  600. - `number_limits` (int) Video number limit, default is 3
  601. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  602. - `custom` (object) Custom settings
  603. - `enabled` (bool) Whether it is enabled
  604. - `number_limits` (int) Custom number limit, default is 3
  605. - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
  606. - `system_parameters` (object) System parameters
  607. - `file_size_limit` (int) Document upload size limit (MB)
  608. - `image_file_size_limit` (int) Image file upload size limit (MB)
  609. - `audio_file_size_limit` (int) Audio file upload size limit (MB)
  610. - `video_file_size_limit` (int) Video file upload size limit (MB)
  611. </Col>
  612. <Col sticky>
  613. <CodeGroup
  614. title="Request"
  615. tag="GET"
  616. label="/parameters"
  617. targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}
  618. />
  619. <CodeGroup title="Response">
  620. ```json {{ title: 'Response' }}
  621. {
  622. "opening_statement": "Hello!",
  623. "suggested_questions_after_answer": {
  624. "enabled": true
  625. },
  626. "speech_to_text": {
  627. "enabled": true
  628. },
  629. "retriever_resource": {
  630. "enabled": true
  631. },
  632. "annotation_reply": {
  633. "enabled": true
  634. },
  635. "user_input_form": [
  636. {
  637. "paragraph": {
  638. "label": "Query",
  639. "variable": "query",
  640. "required": true,
  641. "default": ""
  642. }
  643. }
  644. ],
  645. "file_upload": {
  646. "image": {
  647. "enabled": false,
  648. "number_limits": 3,
  649. "detail": "high",
  650. "transfer_methods": [
  651. "remote_url",
  652. "local_file"
  653. ]
  654. }
  655. },
  656. "system_parameters": {
  657. "file_size_limit": 15,
  658. "image_file_size_limit": 10,
  659. "audio_file_size_limit": 50,
  660. "video_file_size_limit": 100
  661. }
  662. }
  663. ```
  664. </CodeGroup>
  665. </Col>
  666. </Row>
  667. ---
  668. <Heading
  669. url='/site'
  670. method='GET'
  671. title='Get Application WebApp Settings'
  672. name='#site'
  673. />
  674. <Row>
  675. <Col>
  676. Used to get the WebApp settings of the application.
  677. ### Response
  678. - `title` (string) WebApp name
  679. - `chat_color_theme` (string) Chat color theme, in hex format
  680. - `chat_color_theme_inverted` (bool) Whether the chat color theme is inverted
  681. - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture
  682. - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL.
  683. - `icon_background` (string) Background color in hex format
  684. - `icon_url` (string) Icon URL
  685. - `description` (string) Description
  686. - `copyright` (string) Copyright information
  687. - `privacy_policy` (string) Privacy policy link
  688. - `custom_disclaimer` (string) Custom disclaimer
  689. - `default_language` (string) Default language
  690. - `show_workflow_steps` (bool) Whether to show workflow details
  691. - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon
  692. </Col>
  693. <Col>
  694. <CodeGroup
  695. title="Request"
  696. tag="POST"
  697. label="/meta"
  698. targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\
  699. -H 'Authorization: Bearer {api_key}'`}
  700. />
  701. <CodeGroup title="Response">
  702. ```json {{ title: 'Response' }}
  703. {
  704. "title": "My App",
  705. "chat_color_theme": "#ff4a4a",
  706. "chat_color_theme_inverted": false,
  707. "icon_type": "emoji",
  708. "icon": "😄",
  709. "icon_background": "#FFEAD5",
  710. "icon_url": null,
  711. "description": "This is my app.",
  712. "copyright": "all rights reserved",
  713. "privacy_policy": "",
  714. "custom_disclaimer": "All generated by AI",
  715. "default_language": "en-US",
  716. "show_workflow_steps": false,
  717. "use_icon_as_answer_icon": false,
  718. }
  719. ```
  720. </CodeGroup>
  721. </Col>
  722. </Row>
  723. ___