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.en.mdx 30KB

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