Run Workflow
Run Workflow
After enabling the Workflow API and creating an API key, you can run workflows by making API requests with parameters and retrieve the execution results.
Request Method
POST
Endpoint
https://api-{endpoint}.gptbots.ai/v1/workflow/invoke
Request Authentication
Please refer to Overview in API Reference.
Request
Request Example
curl -X POST 'https://api-{endpoint}.gptbots.ai/v1/workflow/invoke' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"userId": "<your_user_id>",
"input": {
<your_start>
}
}'
curl -X POST 'https://api-{endpoint}.gptbots.ai/v1/workflow/invoke' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"userId": "<your_user_id>",
"input": {
<your_start>
}
}'
บล็อกโค้ดนี้ในหน้าต่างลอย
Request Headers
Field | Type | Required | Description |
---|---|---|---|
Authorization | Bearer ${API Key} | Use Authorization: Bearer ${API Key} for authentication. Get API key from API Key page. | |
Content-Type | application/json | Yes | Data type, set to application/json . |
Request Parameters
Field | Type | Required | Description |
---|---|---|---|
userId | string | No | Serves as an identifier of the initiator of this request. |
input | object | Yes | Represents the Start node of the workflow. The parameters in this field must match the parameters specified in the Start node of the workflow. |
Response
Response Example
{
"workflowRunId": "xxxx-5b15-4cbf-999c-1b218934xxxx",
"input": {
"input": "What should I do after a breakup?"
},
"output": {
"output": "Breakups are a normal part of life. While it can be painful, it can also serve as an opportunity for growth and self-reflection. Here are some suggestions that might help you: \n\n..."
},
"workflowExecutionTime": 24277,
"status": "SUCCEED",
"totalCost": 1.3754,
"totalTokens": 3464,
"startTime": 1741768313025,
"endTime": 1741768337310
}
{
"workflowRunId": "xxxx-5b15-4cbf-999c-1b218934xxxx",
"input": {
"input": "What should I do after a breakup?"
},
"output": {
"output": "Breakups are a normal part of life. While it can be painful, it can also serve as an opportunity for growth and self-reflection. Here are some suggestions that might help you: \n\n..."
},
"workflowExecutionTime": 24277,
"status": "SUCCEED",
"totalCost": 1.3754,
"totalTokens": 3464,
"startTime": 1741768313025,
"endTime": 1741768337310
}
บล็อกโค้ดนี้ในหน้าต่างลอย
Response Parameters
Field | Type | Description |
---|---|---|
workflowRunId | string | Operation ID of the workflow, serving as the unique identifier for this execution. |
input | object | Input content of the Start node. This must match the content of the "input field" in the Request. |
output | object | Output content of the End node. This will also show the workflow's execution result. |
workflowExecutionTime | number | Time taken for executing the workflow (Unit: ms). |
status | string | The integration status of the workflow. Possible values inlude: * SUCCED:Successful integration * FAILED:Failed integration * RUNNING:Running workflow |
totalCost | number | Total credits consumed (consumption of all nodes); unit: credit. |
totalTokens | number | Total Token consumed (consumption of all nodes) |
startTime | number | Timestamp of action start (unit: ms) |
endTime | number | Timestamp of action end (unit: ms) |