eachlabs-workflows

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

EachLabs Workflows

EachLabs Workflows

Build, manage, and execute multi-step AI workflows that chain multiple models together via the EachLabs Workflows API.
通过EachLabs Workflows API构建、管理并执行可串联多个模型的多步骤AI工作流。

Authentication

认证

Header: X-API-Key: <your-api-key>
Set the
EACHLABS_API_KEY
environment variable. Get your key at eachlabs.ai.
Header: X-API-Key: <your-api-key>
设置
EACHLABS_API_KEY
环境变量。可前往eachlabs.ai获取你的密钥。

Base URL

基础URL

https://workflows.eachlabs.run/api/v1
https://workflows.eachlabs.run/api/v1

Building a Workflow

构建工作流

To build a workflow, you must: (1) create the workflow, then (2) create a version with the steps.
要构建工作流,你需要:(1) 创建工作流,然后(2) 创建包含步骤的版本。

Step 1: Create the Workflow

步骤1:创建工作流

bash
curl -X POST https://workflows.eachlabs.run/api/v1/workflows \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "name": "Product Photo to Video",
    "description": "Generate a product video from a product photo"
  }'
This returns a
workflowID
. Use it in the next step.
bash
curl -X POST https://workflows.eachlabs.run/api/v1/workflows \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "name": "Product Photo to Video",
    "description": "Generate a product video from a product photo"
  }'
该请求会返回一个
workflowID
,请在下一步中使用它。

Step 2: Create a Version with Steps

步骤2:创建包含步骤的版本

bash
curl -X POST https://workflows.eachlabs.run/api/v1/workflows/{workflowID}/versions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "description": "Initial version",
    "steps": [
      {
        "name": "enhance_photo",
        "model": "gpt-image-v1-5-edit",
        "version": "0.0.1",
        "input": {
          "prompt": "Place this product on a clean white background with studio lighting",
          "image_urls": ["{{inputs.image_url}}"],
          "quality": "high"
        }
      },
      {
        "name": "create_video",
        "model": "pixverse-v5-6-image-to-video",
        "version": "0.0.1",
        "input": {
          "image_url": "{{steps.enhance_photo.output}}",
          "prompt": "Slow cinematic rotation around the product",
          "duration": "5",
          "resolution": "1080p"
        }
      }
    ]
  }'
Important: Before adding a model to a workflow step, check its schema with
GET https://api.eachlabs.ai/v1/model?slug=<slug>
to validate the correct input parameters.
bash
curl -X POST https://workflows.eachlabs.run/api/v1/workflows/{workflowID}/versions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "description": "Initial version",
    "steps": [
      {
        "name": "enhance_photo",
        "model": "gpt-image-v1-5-edit",
        "version": "0.0.1",
        "input": {
          "prompt": "Place this product on a clean white background with studio lighting",
          "image_urls": ["{{inputs.image_url}}"],
          "quality": "high"
        }
      },
      {
        "name": "create_video",
        "model": "pixverse-v5-6-image-to-video",
        "version": "0.0.1",
        "input": {
          "image_url": "{{steps.enhance_photo.output}}",
          "prompt": "Slow cinematic rotation around the product",
          "duration": "5",
          "resolution": "1080p"
        }
      }
    ]
  }'
重要提示: 在将模型添加到工作流步骤之前,请调用
GET https://api.eachlabs.ai/v1/model?slug=<slug>
检查其 schema,以验证输入参数是否正确。

Step 3: Trigger the Workflow

步骤3:触发工作流

bash
curl -X POST https://workflows.eachlabs.run/api/v1/{workflowID}/trigger \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "inputs": {
      "image_url": "https://example.com/product.jpg"
    }
  }'
bash
curl -X POST https://workflows.eachlabs.run/api/v1/{workflowID}/trigger \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "inputs": {
      "image_url": "https://example.com/product.jpg"
    }
  }'

Step 4: Poll for Result

步骤4:轮询获取结果

bash
curl https://workflows.eachlabs.run/api/v1/executions/{executionID} \
  -H "X-API-Key: $EACHLABS_API_KEY"
Poll until
status
is
"completed"
or
"failed"
. Extract output from
step_outputs
.
bash
curl https://workflows.eachlabs.run/api/v1/executions/{executionID} \
  -H "X-API-Key: $EACHLABS_API_KEY"
持续轮询直到
status
变为
"completed"
"failed"
。从
step_outputs
中提取输出结果。

Workflow Management

工作流管理

List Workflows

列出工作流

bash
curl https://workflows.eachlabs.run/api/v1/workflows \
  -H "X-API-Key: $EACHLABS_API_KEY"
bash
curl https://workflows.eachlabs.run/api/v1/workflows \
  -H "X-API-Key: $EACHLABS_API_KEY"

Get Workflow Details

获取工作流详情

bash
curl https://workflows.eachlabs.run/api/v1/workflows/{workflowID} \
  -H "X-API-Key: $EACHLABS_API_KEY"
bash
curl https://workflows.eachlabs.run/api/v1/workflows/{workflowID} \
  -H "X-API-Key: $EACHLABS_API_KEY"

Bulk Trigger

批量触发

Trigger the same workflow with multiple inputs:
bash
curl -X POST https://workflows.eachlabs.run/api/v1/{workflowID}/trigger/bulk \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "executions": [
      { "inputs": { "image_url": "https://example.com/product1.jpg" } },
      { "inputs": { "image_url": "https://example.com/product2.jpg" } },
      { "inputs": { "image_url": "https://example.com/product3.jpg" } }
    ]
  }'
使用多个输入触发同一个工作流:
bash
curl -X POST https://workflows.eachlabs.run/api/v1/{workflowID}/trigger/bulk \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "executions": [
      { "inputs": { "image_url": "https://example.com/product1.jpg" } },
      { "inputs": { "image_url": "https://example.com/product2.jpg" } },
      { "inputs": { "image_url": "https://example.com/product3.jpg" } }
    ]
  }'

Check Execution Status

检查执行状态

bash
curl https://workflows.eachlabs.run/api/v1/executions/{executionID} \
  -H "X-API-Key: $EACHLABS_API_KEY"
Response includes
status
(
pending
,
running
,
completed
,
failed
) and
step_outputs
with results from each step.
bash
curl https://workflows.eachlabs.run/api/v1/executions/{executionID} \
  -H "X-API-Key: $EACHLABS_API_KEY"
响应包含
status
pending
running
completed
failed
)和
step_outputs
,其中包含每个步骤的结果。

Webhooks

Webhook

Configure a webhook to receive results asynchronously:
bash
curl -X POST https://workflows.eachlabs.run/api/v1/{workflowID}/trigger \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "inputs": { "image_url": "https://example.com/photo.jpg" },
    "webhook_url": "https://your-server.com/webhook"
  }'
配置Webhook以异步接收结果:
bash
curl -X POST https://workflows.eachlabs.run/api/v1/{workflowID}/trigger \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "inputs": { "image_url": "https://example.com/photo.jpg" },
    "webhook_url": "https://your-server.com/webhook"
  }'

Version Management

版本管理

Workflow versions allow you to iterate on workflows while keeping previous versions intact. Steps are defined in versions, not in the workflow itself.
工作流版本允许你在迭代工作流的同时保留之前的版本。步骤定义在版本中,而非工作流本身。

Create a Version

创建版本

bash
curl -X POST https://workflows.eachlabs.run/api/v1/workflows/{workflowID}/versions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "description": "Added upscaling step",
    "steps": [
      {
        "name": "generate_image",
        "model": "gpt-image-v1-5-text-to-image",
        "version": "0.0.1",
        "input": {
          "prompt": "{{inputs.prompt}}",
          "quality": "high"
        }
      },
      {
        "name": "upscale",
        "model": "topaz-upscale-image",
        "version": "0.0.1",
        "input": {
          "image_url": "{{steps.generate_image.output}}"
        }
      }
    ]
  }'
bash
curl -X POST https://workflows.eachlabs.run/api/v1/workflows/{workflowID}/versions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "description": "Added upscaling step",
    "steps": [
      {
        "name": "generate_image",
        "model": "gpt-image-v1-5-text-to-image",
        "version": "0.0.1",
        "input": {
          "prompt": "{{inputs.prompt}}",
          "quality": "high"
        }
      },
      {
        "name": "upscale",
        "model": "topaz-upscale-image",
        "version": "0.0.1",
        "input": {
          "image_url": "{{steps.generate_image.output}}"
        }
      }
    ]
  }'

Get a Version

获取版本

bash
curl https://workflows.eachlabs.run/api/v1/workflows/{workflowID}/versions/{versionID} \
  -H "X-API-Key: $EACHLABS_API_KEY"
bash
curl https://workflows.eachlabs.run/api/v1/workflows/{workflowID}/versions/{versionID} \
  -H "X-API-Key: $EACHLABS_API_KEY"

Update a Version

更新版本

bash
curl -X PUT https://workflows.eachlabs.run/api/v1/workflows/{workflowID}/versions/{versionID} \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "description": "Updated prompt template",
    "steps": [
      {
        "name": "generate_image",
        "model": "gpt-image-v1-5-text-to-image",
        "version": "0.0.1",
        "input": {
          "prompt": "Professional photo: {{inputs.prompt}}",
          "quality": "high"
        }
      }
    ]
  }'
bash
curl -X PUT https://workflows.eachlabs.run/api/v1/workflows/{workflowID}/versions/{versionID} \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -d '{
    "description": "Updated prompt template",
    "steps": [
      {
        "name": "generate_image",
        "model": "gpt-image-v1-5-text-to-image",
        "version": "0.0.1",
        "input": {
          "prompt": "Professional photo: {{inputs.prompt}}",
          "quality": "high"
        }
      }
    ]
  }'

List Versions

列出版本

bash
curl https://workflows.eachlabs.run/api/v1/workflows/{workflowID}/versions \
  -H "X-API-Key: $EACHLABS_API_KEY"
bash
curl https://workflows.eachlabs.run/api/v1/workflows/{workflowID}/versions \
  -H "X-API-Key: $EACHLABS_API_KEY"

Workflow Features

工作流特性

  • Two-phase creation: Create workflow first, then add steps via versions
  • Step chaining: Reference previous step outputs with
    {{steps.step_name.output}}
  • Input variables: Use
    {{inputs.variable_name}}
    to pass dynamic inputs
  • Version management: Create, update, and retrieve workflow versions
  • Bulk execution: Process multiple inputs in a single API call
  • Webhook support: Get notified when executions complete
  • Public/unlisted sharing: Share workflows with others
  • 两阶段创建:先创建工作流,再通过版本添加步骤
  • 步骤串联:使用
    {{steps.step_name.output}}
    引用上一步的输出
  • 输入变量:使用
    {{inputs.variable_name}}
    传递动态输入
  • 版本管理:创建、更新和检索工作流版本
  • 批量执行:通过单次API调用处理多个输入
  • Webhook支持:工作流执行完成时接收通知
  • 公开/未公开共享:与他人共享工作流

Example Workflow References

示例工作流参考

See references/WORKFLOW-EXAMPLES.md for common workflow patterns.
常见工作流模式可查看references/WORKFLOW-EXAMPLES.md