<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>
For all API requests, include your API Key in the `Authorization`HTTP Header, as shown below:
<CodeGroup title="Code">
```javascript
Authorization: Bearer {API_KEY}
```
</CodeGroup>
</div>
---
<Heading
url='/workflows/run'
method='POST'
title='Execute workflow'
name='#Execute-Workflow'
/>
<Row>
<Col>
Execute workflow, cannot be executed without a published workflow.
### Request Body
- `inputs` (object) Required
Allows the entry of various variable values defined by the App.
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.
The workflow application requires at least one key/value pair to be inputted.
- `response_mode` (string) Required
The mode of response return, supporting:
- `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)).
- `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)
<i>Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.</i>
- `user` (string) Required
User identifier, used to define the identity of the end-user for retrieval and statistics.
Should be uniquely defined by the developer within the application.
- `files` (array[object]) Optional
File list, suitable for inputting files (images) combined with text understanding and answering questions, available only when the model supports Vision capability.
- `transfer_method` (string) Transfer method, `remote_url` for image URL / `local_file` for file upload
- `url` (string) Image URL (when the transfer method is `remote_url`)
- `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`)
### Response
When `response_mode` is `blocking`, return a CompletionResponse object.
When `response_mode` is `streaming`, return a ChunkCompletionResponse stream.
### CompletionResponse
Returns the App result, `Content-Type` is `application/json`.
- `log_id` (string) Unique log ID
- `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
- `data` (object) detail of result
- `id` (string) ID of workflow execution
- `workflow_id` (string) ID of relatied workflow
- `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
- `outputs` (json) Optional content of output
- `error` (string) Optional reason of error
- `elapsed_time` (float) Optional total seconds to be used
- `total_tokens` (int) Optional tokens to be used
- `total_steps` (int) defualt 0
- `created_at` (timestamp) start time
- `finished_at` (timestamp) end time
### ChunkCompletionResponse
Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.
Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:
<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>
For all API requests, include your API Key in the `Authorization`HTTP Header, as shown below:
<CodeGroup title="Code">
```javascript
Authorization: Bearer {API_KEY}
```
</CodeGroup>
</div>
---
<Heading
url='/workflows/run'
method='POST'
title='Execute workflow'
name='#Execute-Workflow'
/>
<Row>
<Col>
Execute workflow, cannot be executed without a published workflow.
### Request Body
- `inputs` (object) Required
Allows the entry of various variable values defined by the App.
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.
The workflow application requires at least one key/value pair to be inputted.
- `response_mode` (string) Required
The mode of response return, supporting:
- `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)).
- `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)
<i>Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.</i>
- `user` (string) Required
User identifier, used to define the identity of the end-user for retrieval and statistics.
Should be uniquely defined by the developer within the application.
- `files` (array[object]) Optional
File list, suitable for inputting files (images) combined with text understanding and answering questions, available only when the model supports Vision capability.
- `transfer_method` (string) Transfer method, `remote_url` for image URL / `local_file` for file upload
- `url` (string) Image URL (when the transfer method is `remote_url`)
- `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`)
### Response
When `response_mode` is `blocking`, return a CompletionResponse object.
When `response_mode` is `streaming`, return a ChunkCompletionResponse stream.
### CompletionResponse
Returns the App result, `Content-Type` is `application/json`.
- `log_id` (string) Unique log ID
- `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
- `data` (object) detail of result
- `id` (string) ID of workflow execution
- `workflow_id` (string) ID of relatied workflow
- `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
- `outputs` (json) Optional content of output
- `error` (string) Optional reason of error
- `elapsed_time` (float) Optional total seconds to be used
- `total_tokens` (int) Optional tokens to be used
- `total_steps` (int) defualt 0
- `created_at` (timestamp) start time
- `finished_at` (timestamp) end time
### ChunkCompletionResponse
Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.
Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below: