OpenAI GPT-Image-1で画像生成し、Telegram経由で共有

上級

これはDesign, AI, Marketing分野の自動化ワークフローで、18個のノードを含みます。主にSet, Switch, Telegram, FormTrigger, GoogleDriveなどのノードを使用、AI技術を活用したスマート自動化を実現。 OpenAIのGPT-Image-1を使って画像の生成と編集を行い、Telegramで共有する

前提条件
  • Telegram Bot Token
  • Google Drive API認証情報
  • ターゲットAPIの認証情報が必要な場合あり
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "meta": {
    "instanceId": "2fa7acc0cd134988fb8b40b8d8b56c9f29ee37789503fef505450e2733dc2bdf",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "0b66ad6f-d216-41f3-a6dc-61cf15a2044a",
      "name": "アクセス権限の設定",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -2220,
        -1000
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "share",
        "permissionsUi": {
          "permissionsValues": {
            "role": "reader",
            "type": "anyone"
          }
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "vM5RNejQ9XDoP6Ld",
          "name": "Google Sheets n8n dev service account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "724b14c0-6763-47f5-87a1-ed0dde7e8a9e",
      "name": "画像編集 (OpenAI)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -3060,
        -1000
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/images/edits",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "image",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "={{ $json[\"input image url\"].isEmpty()?\"input_image\":\"data\"}}"
            },
            {
              "name": "prompt",
              "value": "={{ $json.Promt }}"
            },
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "n",
              "value": "1"
            },
            {
              "name": "size",
              "value": "1024x1024"
            },
            {
              "name": "quality",
              "value": "={{ $json.quality }}"
            }
          ]
        },
        "nodeCredentialType": "openAiApi"
      },
      "credentials": {
        "openAiApi": {
          "id": "3ff0w5x5tfolokJ7",
          "name": "OpenAi account mingles new dev user"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "071f9711-3b73-411d-9962-b540f0b418c7",
      "name": "json バイナリをファイルに変換",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -2740,
        -620
      ],
      "parameters": {
        "options": {
          "fileName": "={{ $now.format('yyyy-MM-dd_HHmmss')+\".png\" }}",
          "mimeType": "image/png"
        },
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json"
      },
      "typeVersion": 1.1
    },
    {
      "id": "e22377ef-1bbf-4288-a625-d07a97d5667d",
      "name": "json バイナリをファイルに変換 (最終)",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -2740,
        -1000
      ],
      "parameters": {
        "options": {
          "fileName": "={{ $now.format('yyyy-MM-dd_HHmmss')+\".png\" }}",
          "mimeType": "image/png"
        },
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json"
      },
      "typeVersion": 1.1
    },
    {
      "id": "5aabd61e-5407-4be7-b6c9-ab77c7cadad7",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3140,
        -780
      ],
      "parameters": {
        "color": 3,
        "width": 280,
        "height": 340,
        "content": "### 🎨 Image Generation (OpenAI)\nSends a POST request to the OpenAI `/v1/images/generations` endpoint.\n\n- Uses `gpt-image-1` model"
      },
      "typeVersion": 1
    },
    {
      "id": "93be8801-7fb4-42d7-af2d-1047b8c60d6e",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2840,
        -1200
      ],
      "parameters": {
        "color": 5,
        "width": 300,
        "height": 760,
        "content": "### 🧾 Convert base64 to File\nConverts the `b64_json` field into a binary PNG file to use in the next step.\n\n📤 Output: Final binary image\n"
      },
      "typeVersion": 1
    },
    {
      "id": "aeafd971-28ad-4c5c-8d26-0d81f82fac01",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3140,
        -1200
      ],
      "parameters": {
        "color": 3,
        "width": 280,
        "height": 360,
        "content": "### ✏️ Image to image generation (OpenAI)\nSends the binary image to OpenAI’s `/v1/images/edits` endpoint with a descriptive prompt.\n\n- Model: `gpt-image-1`"
      },
      "typeVersion": 1
    },
    {
      "id": "930bba79-34c4-40da-b22f-4f42b9894705",
      "name": "フォーム送信時",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -3860,
        -840
      ],
      "webhookId": "e3e1e092-d5fb-4e15-911e-3bc98e916c9f",
      "parameters": {
        "options": {},
        "formTitle": "GPT image to image",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Promt",
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "quality",
              "fieldOptions": {
                "values": [
                  {
                    "option": "low"
                  },
                  {
                    "option": "medium"
                  },
                  {
                    "option": "high"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldType": "file",
              "fieldLabel": "input image",
              "multipleFiles": false,
              "acceptFileTypes": ".png,.jpg,.jpeg"
            },
            {
              "fieldLabel": "input image url"
            }
          ]
        },
        "responseMode": "lastNode",
        "authentication": "basicAuth"
      },
      "credentials": {
        "httpBasicAuth": {
          "id": "EzEYGeSYuNmHnrQn",
          "name": "reels maker auth"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "abb8a008-0dcb-427c-a00a-7c850790cf4f",
      "name": "結果画像をimgbbにアップロード",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2220,
        -640
      ],
      "parameters": {
        "url": "https://api.imgbb.com/1/upload",
        "method": "POST",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "image",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            },
            {
              "name": "key",
              "value": "={{ $json.IMGBB_API_KEY }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "ec0fc073-15f9-4cdf-a2f4-19de2c2b3261",
      "name": "結果画像をGoogle Driveにアップロード",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -2440,
        -1000
      ],
      "parameters": {
        "name": "={{ $input.item.binary.data.fileName }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultUrl": "https://drive.google.com/drive",
          "cachedResultName": "/ (Root folder)"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "vM5RNejQ9XDoP6Ld",
          "name": "Google Sheets n8n dev service account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "7487229b-5e94-48d4-b84c-a5725e529e23",
      "name": "ファイルリンク",
      "type": "n8n-nodes-base.set",
      "position": [
        -2020,
        -1000
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "df673a7d-7ff2-4c7e-835f-7c65e58c5ad4",
              "name": "ViewLink",
              "type": "string",
              "value": "={{ $('Upload Result Image to Google Drive').item.json.webViewLink }}"
            },
            {
              "id": "c3447718-d652-45d7-9c6f-6a1d4f29a68d",
              "name": "ContentLink",
              "type": "string",
              "value": "={{ $('Upload Result Image to Google Drive').item.json.webContentLink }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f4f2a07d-4a5e-45d9-96d6-0f5eb1359d6f",
      "name": "URLによる入力画像の取得",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -3360,
        -840
      ],
      "parameters": {
        "url": "={{ $json['input image url'] }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "613aa7b5-8f63-490f-9026-de4971619e41",
      "name": "API KEYの設定",
      "type": "n8n-nodes-base.set",
      "position": [
        -2440,
        -640
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f0df22ed-6c69-4204-8cfb-8dae51ea8fd4",
              "name": "IMGBB_API_KEY",
              "type": "string",
              "value": "IMGBB_API_KEY"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "5e276d4c-05c0-4aa2-9f3c-88669c2d259a",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2500,
        -1200
      ],
      "parameters": {
        "color": 6,
        "width": 640,
        "height": 760,
        "content": "## Upload result file to Google Drive OR to [imgbb](https://api.imgbb.com/)"
      },
      "typeVersion": 1
    },
    {
      "id": "38760191-c39a-4a62-a222-324e5cd83590",
      "name": "画像生成",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -3060,
        -620
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/images/generations",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "prompt",
              "value": "={{ $json.Promt }}"
            },
            {
              "name": "n",
              "value": "={{Number(1)}}"
            },
            {
              "name": "size",
              "value": "1024x1024"
            },
            {
              "name": "moderation",
              "value": "low"
            },
            {
              "name": "background",
              "value": "auto"
            },
            {
              "name": "quality",
              "value": "={{ $json.quality }}"
            }
          ]
        },
        "nodeCredentialType": "openAiApi"
      },
      "credentials": {
        "openAiApi": {
          "id": "3ff0w5x5tfolokJ7",
          "name": "OpenAi account mingles new dev user"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6abaccab-b49b-41ab-86cd-8bf562472f9d",
      "name": "ファイルリンク1",
      "type": "n8n-nodes-base.set",
      "position": [
        -2000,
        -640
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "df673a7d-7ff2-4c7e-835f-7c65e58c5ad4",
              "name": "ViewLink",
              "type": "string",
              "value": "={{ $json.data.url }}"
            },
            {
              "id": "c3447718-d652-45d7-9c6f-6a1d4f29a68d",
              "name": "ContentLink",
              "type": "string",
              "value": "={{ $json.data.image.url }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7443a6f2-3d0c-4fef-9dbe-56948ea8c17c",
      "name": "Telegramに送信",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -1740,
        -840
      ],
      "webhookId": "150d64ce-d278-4459-b9b9-5d0dfb3afbd1",
      "parameters": {
        "file": "={{ $json.ContentLink }}",
        "chatId": "YOUR_CHAT_ID",
        "operation": "sendPhoto",
        "additionalFields": {
          "caption": "={{ $('On form submission').item.json.Promt }}\n{{ $('On form submission').item.json.quality }}\n\n[Result]({{ $json.ViewLink }})",
          "parse_mode": "MarkdownV2"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "ar7qqwMS6eFB8SaY",
          "name": "NyroSikAIbot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "efe008a1-1dea-41f8-8778-1556cf0bbbea",
      "name": "モード切替",
      "type": "n8n-nodes-base.switch",
      "position": [
        -3640,
        -840
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "file",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6c2e2793-96f4-4d15-af76-926d1fdcee71",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json['input image'] !== null && $json['input image url'].isNotEmpty() }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "file_url",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9d464a07-f5fe-48af-b524-6ca60479fda6",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json['input image url'] !== null && $json['input image url'].isNotEmpty() }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.2
    }
  ],
  "pinData": {},
  "connections": {
    "7487229b-5e94-48d4-b84c-a5725e529e23": {
      "main": [
        [
          {
            "node": "7443a6f2-3d0c-4fef-9dbe-56948ea8c17c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6abaccab-b49b-41ab-86cd-8bf562472f9d": {
      "main": [
        [
          {
            "node": "7443a6f2-3d0c-4fef-9dbe-56948ea8c17c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "efe008a1-1dea-41f8-8778-1556cf0bbbea": {
      "main": [
        [
          {
            "node": "724b14c0-6763-47f5-87a1-ed0dde7e8a9e",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "f4f2a07d-4a5e-45d9-96d6-0f5eb1359d6f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "38760191-c39a-4a62-a222-324e5cd83590",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "613aa7b5-8f63-490f-9026-de4971619e41": {
      "main": [
        [
          {
            "node": "abb8a008-0dcb-427c-a00a-7c850790cf4f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "38760191-c39a-4a62-a222-324e5cd83590": {
      "main": [
        [
          {
            "node": "071f9711-3b73-411d-9962-b540f0b418c7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "930bba79-34c4-40da-b22f-4f42b9894705": {
      "main": [
        [
          {
            "node": "efe008a1-1dea-41f8-8778-1556cf0bbbea",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "724b14c0-6763-47f5-87a1-ed0dde7e8a9e": {
      "main": [
        [
          {
            "node": "e22377ef-1bbf-4288-a625-d07a97d5667d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f4f2a07d-4a5e-45d9-96d6-0f5eb1359d6f": {
      "main": [
        [
          {
            "node": "724b14c0-6763-47f5-87a1-ed0dde7e8a9e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0b66ad6f-d216-41f3-a6dc-61cf15a2044a": {
      "main": [
        [
          {
            "node": "7487229b-5e94-48d4-b84c-a5725e529e23",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "071f9711-3b73-411d-9962-b540f0b418c7": {
      "main": [
        [
          {
            "node": "613aa7b5-8f63-490f-9026-de4971619e41",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "abb8a008-0dcb-427c-a00a-7c850790cf4f": {
      "main": [
        [
          {
            "node": "6abaccab-b49b-41ab-86cd-8bf562472f9d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e22377ef-1bbf-4288-a625-d07a97d5667d": {
      "main": [
        [
          {
            "node": "ec0fc073-15f9-4cdf-a2f4-19de2c2b3261",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ec0fc073-15f9-4cdf-a2f4-19de2c2b3261": {
      "main": [
        [
          {
            "node": "0b66ad6f-d216-41f3-a6dc-61cf15a2044a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

上級 - デザイン, 人工知能, マーケティング

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
上級
ノード数18
カテゴリー3
ノードタイプ8
難易度説明

上級者向け、16ノード以上の複雑なワークフロー

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34