创建模板运行

启动 flows 模板运行。传入 `version_id` 以固定快照,或省略它/传入 `latest` 以运行最新发布版本。在 `inputs` 下设置输入值,并以输入端口 id 为键。响应返回初始状态的运行,其中每个输出已在 `outputs` 中列于对应端口 id 下。包含 `webhook` 可在运行 `status` 为 `completed` 或 `failed` 时接收携带已完成运行的 `flows_template_run` 事件;这是推荐的等待方式。若未提供,则以适当间隔获取 `GET /v1/flows/templates/{template_id}/runs/{run_id}`,直到 `status` 为终态。

路径参数

template_idstring必需

模板的 ID,如 ElevenLabs 应用中或通过 GET /v1/flows/templates 所示。

请求头

xi-api-keystring可选

请求

This endpoint expects an object.
inputsmap from strings to strings or booleans or integers or doubles or objects or lists of TemplateRunInput必需

以输入端口 ID 为键的输入值。必须提供正在运行版本的每个输入端口;缺少或未知 ID 将被拒绝。对于没有输入的模板,传入 {}。

version_idstring or null可选>=1 character

要运行的模板快照。传入特定版本 id 可固定该快照,或传入 latest(省略时的默认值)以运行模板最近发布的版本。仅可固定已发布版本;模板所有者也可固定未发布的已保存快照,以便在发布前试用。此 API 永远不会运行实时草稿。

webhookobject or null可选

包含此项后,当运行的 status 变为 completed 或 failed 时,会将运行结果发送到工作区配置的 flows webhook。整个运行仅发送一个事件:flows_template_run 事件的 data 与 GET /v1/flows/templates/{template_id}/runs/{run_id} 的最终响应一致。

响应

成功响应

idstring

运行的唯一标识符。

template_idstring

此次运行执行的模板,使运行多个模板的 webhook 使用方无需维护运行与模板的映射即可区分各次运行。

version_idstring

此次运行执行的模板版本。创建运行时即会解析,因此使用 latest 启动的运行会记录实际执行的具体版本。

statusenum

运行状态由各输出状态汇总而成:输出开始前为 pending,任一输出未完成时为 generating,所有输出完成后为 completed,所有输出结束且至少一项失败时为 failed。completed 和 failed 为终态:运行达到其中任一状态时,将触发 flows_template_run webhook。

允许的值:
outputsmap from strings to objects

The run’s outputs, keyed by output port id. Each is a TemplateOutput discriminated on type, the type of its port’s content_schema.

错误

422
Unprocessable Entity Error