n8n × PopNow

在 n8n 里生成 AI 图片和视频

无需安装额外组件:使用 n8n 内置的 HTTP Request 节点即可调用 PopNow API,兼容 n8n Cloud 与自托管版本。粘贴工作流、填入密钥后即可运行。

  1. Start

    manualTrigger

  2. Create task

    POST /jobs/createTask

  3. Wait 5 seconds

    wait · 5 s

  1. Check task

    GET /jobs/recordInfo

  2. Done?

    if · state

    还没好:再等一会

  3. File URL

    set · url

    沉睡之龙

四步完成配置

  1. 在 n8n 里新建一个 Header Auth 凭据。Name 填 Authorization,Value 填 Bearer、一个空格,再加上你以 sk-popnow- 开头的密钥。
  2. 复制下面的工作流,在空白画布上按 Ctrl + V(Mac 上是 Cmd + V)粘贴。
  3. 打开 Create task 节点,选上刚建的凭据,再改模型和提示词。
  4. 运行。最后一个节点会给出文件地址;在后面接一个 Google Drive、Slack 或 S3 节点把文件存下来。

用自托管 n8n?也可以在 Settings > Community Nodes > Install 里安装 PopNow 社区节点: n8n-nodes-popnow · npm · GitHub

工作流

依次创建任务、等待并查询状态,循环至任务完成,再将文件链接传给下一个节点。

popnow-workflow.json
{
  "name": "PopNow: generate and get the file",
  "nodes": [
    {
      "id": "b1f0c1a2-0001-4c55-9a10-000000000001",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "b1f0c1a2-0002-4c55-9a10-000000000002",
      "name": "Create task",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        220,
        0
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.popnow.ai/api/v1/jobs/createTask",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Idempotency-Key",
              "value": "={{ $execution.id }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n  \"model\": \"google/nano-banana-2.1/text-to-image\",\n  \"input\": {\n    \"prompt\": \"A ceramic teapot on a linen cloth, soft window light, muted palette\",\n    \"aspect_ratio\": \"16:9\",\n    \"resolution\": \"1k\",\n    \"output_format\": \"png\"\n  }\n}",
        "options": {}
      }
    },
    {
      "id": "b1f0c1a2-0003-4c55-9a10-000000000003",
      "name": "Wait 5 seconds",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        440,
        0
      ],
      "parameters": {
        "amount": 5
      },
      "webhookId": "4d3c2b1a-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
    },
    {
      "id": "b1f0c1a2-0004-4c55-9a10-000000000004",
      "name": "Check task",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        0
      ],
      "parameters": {
        "url": "https://api.popnow.ai/api/v1/jobs/recordInfo",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "taskId",
              "value": "={{ $('Create task').item.json.data.taskId }}"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "b1f0c1a2-0005-4c55-9a10-000000000005",
      "name": "Done?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        880,
        0
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "c0ffee00-0000-4000-8000-000000000001",
              "leftValue": "={{ ['succeeded','failed','canceled','expired'].includes($json.data.state) && !($json.data.output?.assets ?? []).some(a => a.pending && !a.unavailable) }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "b1f0c1a2-0006-4c55-9a10-000000000006",
      "name": "File URL",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1100,
        -100
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c0ffee00-0000-4000-8000-000000000002",
              "name": "state",
              "value": "={{ $json.data.state }}",
              "type": "string"
            },
            {
              "id": "c0ffee00-0000-4000-8000-000000000003",
              "name": "fileUrl",
              "value": "={{ $json.data.output?.assets?.[0]?.url ?? '' }}",
              "type": "string"
            },
            {
              "id": "c0ffee00-0000-4000-8000-000000000004",
              "name": "error",
              "value": "={{ $json.data.errorMessage ?? '' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Create task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create task": {
      "main": [
        [
          {
            "node": "Wait 5 seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 5 seconds": {
      "main": [
        [
          {
            "node": "Check task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check task": {
      "main": [
        [
          {
            "node": "Done?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Done?": {
      "main": [
        [
          {
            "node": "File URL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 5 seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}

标准的 n8n JSON。模型和 input 都取自本页,原样就能通过校验。

需要调整的字段

控制花费. 在控制台为 n8n 使用的密钥单独设置每日用量上限与允许调用的模型。达到上限后会停止新任务,避免循环异常耗尽余额。

model
模型的调用名。API 版块里每个模型页都有,带复制按钮。
input
这个模型的提示词和选项。模型的 API 页列出了每个字段的范围和默认值。
callBackUrl
可选。指向一个 n8n Webhook 节点,就可以去掉等待循环:任务完成后我们会把结果发过去。
Idempotency-Key
已经设成执行 ID,节点重试时不会为同一次运行重复扣费。

适合起步的模型

速度快、价格合适,适合做自动化。点进去能看到调用名、参数和价格。

n8n 常见问题

需要装 PopNow 的社区节点吗?

这个工作流不需要。它只用 n8n 自带的节点(Manual Trigger、HTTP Request、Wait、If 和 Edit Fields),n8n Cloud 和自托管都能运行。在自托管 n8n 上,也可以从 Settings > Community Nodes 安装 PopNow 社区节点 n8n-nodes-popnow。它还没有通过 n8n 官方认证,所以 n8n Cloud 暂时装不了。

怎么用前面节点里的图片?

在图片字段里传一个公开的 https 链接。如果文件只在 n8n 里,先通过 API 上传,再用返回的 popnow:// 引用。

运行一次需要多少费用?

从 PopNow 余额中按实际用量以美元结算。 Nano Banana 图片单价和视频每秒费用可在模型页查看。 POST /jobs/quote 可在运行前给出预计费用和最高费用,单位为美元。 任务失败时,冻结的美元金额会释放回付款时用的那个余额。

运行一次需要多久?

图片通常在一分钟内完成,视频通常需要几分钟。等待循环每五秒查询一次状态;使用 callBackUrl 则无需轮询等待。