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

    眠れる竜

4ステップで設定

  1. n8n で Header Auth の認証情報を追加します。Name は Authorization、Value は Bearer、半角スペース、続けて sk-popnow- で始まるキーです。
  2. 下のワークフローをコピーし、空のキャンバスに Ctrl + V(Mac は Cmd + V)で貼り付けます。
  3. Create task ノードを開いて認証情報を選び、モデルとプロンプトを変更します。
  4. 実行します。最後のノードがファイルの URL を返すので、後ろに 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 用のキーに 1 日の利用上限と使用できるモデルを設定できます。処理が繰り返されても上限で停止し、残高の使い切りを防ぎます。

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:// 参照を使います。

1回の実行でいくらかかりますか?

実際の使用量に応じて、PopNow 残高から米ドルでお支払いいただきます。 Nano Banana の画像単価や動画の秒単価はモデルページで確認できます。 POST /jobs/quote で実行前に想定料金と上限額を米ドルで確認できます。 タスクが失敗した場合、確保した米ドルの金額を解放し、支払いに使った残高に戻します。

1回の実行にどれくらいかかりますか?

画像は通常 1 分以内、動画は数分で完成します。ポーリングでは 5 秒ごとに状態を確認します。callBackUrl を使うと、生成の完了時に結果が自動送信されるため、ポーリングは不要です。