提交工作流运行
curl --request POST \
--url https://www.chenyu.cn/api/open/v2/workflow/run/submit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"workflow_id": "<string>",
"revision_id": "<string>",
"inputs": {},
"idempotency_key": "<string>",
"accept_external_cost_risk": true
}
'import requests
url = "https://www.chenyu.cn/api/open/v2/workflow/run/submit"
payload = {
"workflow_id": "<string>",
"revision_id": "<string>",
"inputs": {},
"idempotency_key": "<string>",
"accept_external_cost_risk": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
workflow_id: '<string>',
revision_id: '<string>',
inputs: {},
idempotency_key: '<string>',
accept_external_cost_risk: true
})
};
fetch('https://www.chenyu.cn/api/open/v2/workflow/run/submit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.chenyu.cn/api/open/v2/workflow/run/submit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'workflow_id' => '<string>',
'revision_id' => '<string>',
'inputs' => [
],
'idempotency_key' => '<string>',
'accept_external_cost_risk' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.chenyu.cn/api/open/v2/workflow/run/submit"
payload := strings.NewReader("{\n \"workflow_id\": \"<string>\",\n \"revision_id\": \"<string>\",\n \"inputs\": {},\n \"idempotency_key\": \"<string>\",\n \"accept_external_cost_risk\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.chenyu.cn/api/open/v2/workflow/run/submit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"workflow_id\": \"<string>\",\n \"revision_id\": \"<string>\",\n \"inputs\": {},\n \"idempotency_key\": \"<string>\",\n \"accept_external_cost_risk\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.chenyu.cn/api/open/v2/workflow/run/submit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"workflow_id\": \"<string>\",\n \"revision_id\": \"<string>\",\n \"inputs\": {},\n \"idempotency_key\": \"<string>\",\n \"accept_external_cost_risk\": true\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"msg": "<string>",
"data": {
"run_order_id": "<string>",
"workflow_id": "<string>",
"revision_id": "<string>",
"quote_currency": "<string>",
"quote_amount": "<string>",
"freeze_status": "<string>",
"run_status": "<string>",
"task_id": "<string>",
"prompt_id": "<string>",
"billing_run_id": "<string>",
"idempotent_replay": true
},
"data.error": {
"reason": "<string>",
"detail": "<string>",
"engine_code": "<string>",
"status_code": 123
}
}运行管理
提交工作流运行
提交一次工作流运行任务
POST
/
api
/
open
/
v2
/
workflow
/
run
/
submit
提交工作流运行
curl --request POST \
--url https://www.chenyu.cn/api/open/v2/workflow/run/submit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"workflow_id": "<string>",
"revision_id": "<string>",
"inputs": {},
"idempotency_key": "<string>",
"accept_external_cost_risk": true
}
'import requests
url = "https://www.chenyu.cn/api/open/v2/workflow/run/submit"
payload = {
"workflow_id": "<string>",
"revision_id": "<string>",
"inputs": {},
"idempotency_key": "<string>",
"accept_external_cost_risk": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
workflow_id: '<string>',
revision_id: '<string>',
inputs: {},
idempotency_key: '<string>',
accept_external_cost_risk: true
})
};
fetch('https://www.chenyu.cn/api/open/v2/workflow/run/submit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.chenyu.cn/api/open/v2/workflow/run/submit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'workflow_id' => '<string>',
'revision_id' => '<string>',
'inputs' => [
],
'idempotency_key' => '<string>',
'accept_external_cost_risk' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.chenyu.cn/api/open/v2/workflow/run/submit"
payload := strings.NewReader("{\n \"workflow_id\": \"<string>\",\n \"revision_id\": \"<string>\",\n \"inputs\": {},\n \"idempotency_key\": \"<string>\",\n \"accept_external_cost_risk\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.chenyu.cn/api/open/v2/workflow/run/submit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"workflow_id\": \"<string>\",\n \"revision_id\": \"<string>\",\n \"inputs\": {},\n \"idempotency_key\": \"<string>\",\n \"accept_external_cost_risk\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.chenyu.cn/api/open/v2/workflow/run/submit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"workflow_id\": \"<string>\",\n \"revision_id\": \"<string>\",\n \"inputs\": {},\n \"idempotency_key\": \"<string>\",\n \"accept_external_cost_risk\": true\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"msg": "<string>",
"data": {
"run_order_id": "<string>",
"workflow_id": "<string>",
"revision_id": "<string>",
"quote_currency": "<string>",
"quote_amount": "<string>",
"freeze_status": "<string>",
"run_status": "<string>",
"task_id": "<string>",
"prompt_id": "<string>",
"billing_run_id": "<string>",
"idempotent_replay": true
},
"data.error": {
"reason": "<string>",
"detail": "<string>",
"engine_code": "<string>",
"status_code": 123
}
}提交工作流运行
提交一次工作流运行任务。系统会先按工作流报价进行预扣费,任务完成后按实际消耗结算,多退少补以实际账单为准。idempotency_key 必填。同一用户、相同工作流、相同幂等键的重复请求会返回同一笔运行记录,避免网络重试造成重复提交。调用本接口前,必须先查询 工作流详情,并根据返回的
editable_parameter_manifest 组装 inputs。参数名使用 manifest 条目的 name,参数值按 value_type 和 ui_schema 填写。请求参数
string
required
工作流 ID
string
工作流版本 ID。建议使用详情接口返回的
revision_id,不传时使用当前已发布版本object
工作流输入参数。每个 key 必须来自详情接口
editable_parameter_manifest[].name;未声明的 key 会被拒绝。具体类型、下拉选项、必填规则和文件传法请参考 工作流详情中的参数填写规则string
required
幂等键,由调用方生成。建议使用业务订单号、请求流水号或 UUID
boolean
是否确认接受第三方模型费用风险。工作流可能产生外部模型费用时应传
trueinputs 填写规则
- 调用工作流详情接口,读取
revision_id和editable_parameter_manifest - 对每个
required=true的条目,在inputs中使用条目的name作为 key string传字符串,int/float传 JSON 数字,bool传 JSON 布尔值ui_schema.control="select"时传ui_schema.options[].value中的一个,并保留该值原本的 JSON 类型- 图片、视频、音频或文件参数需要传资源字符串;本地文件先调用 上传工作流资源,再传返回的
asset_uri
不要使用
display_name 或 bindings[].field 作为 inputs 的 key,也不要额外传 manifest 中不存在的字段。数字参数当前没有统一的最大值、最小值或步长,详情接口中的完整规则见 editable_parameter_manifest 说明。响应参数
integer
响应码,
0 表示成功string
响应信息
object
错误响应
当提交阶段调用执行引擎失败时,接口会返回一个简单原因和详细错误信息,便于定位输入参数、文件获取、实例调度或工作流执行器问题。integer
非
0 表示失败string
简单失败原因
object
代码示例
import uuid
import requests
url = "https://www.chenyu.cn/api/open/v2/workflow/run/submit"
headers = {
"Authorization": "Bearer your_api_key",
"Content-Type": "application/json"
}
payload = {
"workflow_id": "wf_861ef31e94dcfb10e6e7",
"revision_id": "wfr_f9f2a2dcb99d73b0c3aa",
"inputs": {
"n6_text": "一只橘猫坐在窗边,电影感光线",
"n4_sampler_name": "euler",
"n3_seed": 156680208700286,
"n10_image": "asset://asset_38d2ff7769fb3b7267039941547e6a78"
},
"idempotency_key": str(uuid.uuid4()),
"accept_external_cost_risk": False
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
const axios = require('axios');
const crypto = require('crypto');
axios.post('https://www.chenyu.cn/api/open/v2/workflow/run/submit', {
workflow_id: 'wf_861ef31e94dcfb10e6e7',
revision_id: 'wfr_f9f2a2dcb99d73b0c3aa',
inputs: {
n6_text: '一只橘猫坐在窗边,电影感光线',
n4_sampler_name: 'euler',
n3_seed: 156680208700286,
n10_image: 'asset://asset_38d2ff7769fb3b7267039941547e6a78'
},
idempotency_key: crypto.randomUUID(),
accept_external_cost_risk: false
}, {
headers: {
Authorization: 'Bearer your_api_key',
'Content-Type': 'application/json'
}
}).then((response) => {
console.log(response.data);
});
curl -X POST "https://www.chenyu.cn/api/open/v2/workflow/run/submit" \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"workflow_id": "wf_861ef31e94dcfb10e6e7",
"revision_id": "wfr_f9f2a2dcb99d73b0c3aa",
"inputs": {
"n6_text": "一只橘猫坐在窗边,电影感光线",
"n4_sampler_name": "euler",
"n3_seed": 156680208700286,
"n10_image": "asset://asset_38d2ff7769fb3b7267039941547e6a78"
},
"idempotency_key": "run_20260508_001",
"accept_external_cost_risk": false
}'
响应示例
{
"code": 0,
"msg": "提交成功",
"data": {
"run_order_id": "wfrun_314ff7d8b7a5beff1388",
"workflow_id": "wf_861ef31e94dcfb10e6e7",
"revision_id": "wfr_f9f2a2dcb99d73b0c3aa",
"quote_currency": "CNY",
"quote_amount": "0.03000000",
"freeze_status": "frozen",
"run_status": "queued",
"task_id": "task_1778147626528703038_eb84d292e0851c08",
"prompt_id": "prompt_1778147626528707364_b0c0687e49d1f72f",
"billing_run_id": "wfbill_1778147626528703038",
"idempotent_replay": false
}
}
错误示例
{
"code": 1,
"msg": "工作流输入参数无效",
"data": {
"error": {
"reason": "工作流输入参数无效",
"detail": "input parameter \"unknown_field\" is not declared by workflow manifest",
"engine_code": "INVALID_INPUT_PARAMETER",
"status_code": 400
}
}
}