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 則無須輪詢等待。