8
n8n 中文网amn8n.com

简单 OpenAI 图像生成器

初级

这是一个自动化工作流,包含 5 个节点。主要使用 Form, FormTrigger, HttpRequest, ConvertToFile 等节点。 通过用户友好表单使用 OpenAI GPT-Image-1 模型生成图像

前置要求
  • 可能需要目标 API 的认证凭证

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "AqWXpCre4fsPEkAH",
  "meta": {
    "instanceId": "7dfa146768a036d27a67d125f90ea637bfb301bd4fd25d0086548016421d44bd"
  },
  "name": "简单OpenAI图像生成器",
  "tags": [],
  "nodes": [
    {
      "id": "526c24bc-3bc5-48c3-ae1e-5b0c0352d07f",
      "name": "转换为文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        440,
        0
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json"
      },
      "typeVersion": 1.1
    },
    {
      "id": "20fdcc11-5e8a-4788-b3a3-e556996b59f7",
      "name": "提示和选项",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        0
      ],
      "webhookId": "b749da3f-836f-4996-a8ee-bc26f8677582",
      "parameters": {
        "options": {},
        "formTitle": "OpenAI Image Generator",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Prompt",
              "placeholder": "Snow-covered mountain village in the Alps",
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Image size",
              "fieldOptions": {
                "values": [
                  {
                    "option": "1024x1024"
                  },
                  {
                    "option": "1024x1536"
                  },
                  {
                    "option": "1536x1024"
                  }
                ]
              },
              "requiredField": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "eb220b1f-2091-492a-931f-1f2e344b32a6",
      "name": "OpenAI图像生成",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        220,
        0
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/images/generations",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "prompt",
              "value": "={{ $json.Prompt }}"
            },
            {
              "name": "n",
              "value": "={{ 1 }}"
            },
            {
              "name": "size",
              "value": "={{ $json['Image size'] }}"
            }
          ]
        },
        "nodeCredentialType": "openAiApi"
      },
      "credentials": {
        "openAiApi": {
          "id": "x1byAha0t8ltLIeW",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "86718927-490e-4d97-9b0c-1118e2ccdcb6",
      "name": "返回表单",
      "type": "n8n-nodes-base.form",
      "position": [
        660,
        0
      ],
      "webhookId": "745af4a8-ab3c-4267-aa8d-a8998cc534e5",
      "parameters": {
        "options": {
          "formTitle": "Result"
        },
        "operation": "completion",
        "respondWith": "returnBinary",
        "completionTitle": "Result",
        "completionMessage": "Here is the created image:"
      },
      "typeVersion": 1
    },
    {
      "id": "a069f63f-139e-4157-a44a-448224f2c119",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        0
      ],
      "parameters": {
        "width": 500,
        "height": 620,
        "content": "# 欢迎使用我的简单OpenAI图像生成器工作流!"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d2376df0-9c26-4723-9e97-07fc226e7a53",
  "connections": {
    "Convert to File": {
      "main": [
        [
          {
            "node": "Return to form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prompt and options": {
      "main": [
        [
          {
            "node": "OpenAI Image Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Image Generation": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

初级

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
初级
节点数量5
分类-
节点类型5
难度说明

适合 n8n 新手,包含 1-5 个节点的简单工作流

外部链接
在 n8n.io 查看

分享此工作流