ChatGPT创意设计AI 评分 · 待评分AI 辅助编辑·未发现明显提示词注入风险n8n.io

用 n8n + Google Nano Banana + Kie.ai 搭建一致角色 AI 图像生成与增强工作流

手动触发 → 在 Google Drive 创建时间戳文件夹与追踪表 → GPT-4 生成场景提示词 → Kie.ai NanoBanana 生成图像 → 轮询状态 → 4 倍超分与人脸增强 → 归档到 Drive 并更新 Sheets

有一点经验步骤流程提示词贴士
给谁
需要在社交媒体或营销素材中保持角色一致性的内容创作者、自动化工程师
你会得到
一键生成带统一风格的 AI 角色图像,自动完成 4 倍超分增强,并按时间戳归档到 Google Drive,同时在 Google Sheets 中记录进度
你需要
n8n · google-drive · google-sheets

硬约束

前置条件:n8n 实例;Kie.ai 账号与 API Token;OpenAI API Key;Google Drive 与 Google Sheets OAuth2 凭证。费用:Kie.ai 按调用计费,OpenAI 按 token 计费,Google 服务一般免费额度内。注意:模板中硬编码了 Google Drive 文件夹 ID 与 5 张参考图 URL,使用前必须替换为自己的值。

他们做了什么

作者 mfarooqone 在 n8n.io 发布了模板 #8492,展示如何组合 OpenAI GPT-4(gpt-4.1-mini)与 Kie.ai 的 google/nano-banana-edit 和 nano-banana-upscale 模型,构建端到端的 AI 角色图像生成与增强工作流。工作流包含 33 个节点,分为 7 个阶段:项目初始化、故事/提示词生成、图像生成、状态轮询、4 倍超分增强、文件归档、进度追踪。核心机制是用 5 张参考图约束 NanoBanana 模型保持角色一致性,再用结构化输出解析器确保 prompt 格式可控。

效果如何

作者报告该模板已被下载 500+ 次(author_report)。模板在 n8n.io 上状态为 published。本站未实际导入运行,未验证 Kie.ai 调用成功率、图像质量或超分效果。

值得知道

1. 硬编码参数必须替换:Google Drive 文件夹 ID(1GND1exvlAXTzESNvWmFs6FFMx90KLzlC)和 5 张 i.ibb.co 参考图 URL 是模板作者的示例值,不替换会导致失败或生成无关图像。 2. 模型选择:节点保存值为 gpt-4.1-mini,但 OpenAI Chat Model 节点支持切换为 gpt-4.1 或 gpt-4;切换后费用与延迟会变化。 3. 异步轮询无回调:Kie.ai 任务采用轮询(Wait + Poll Task + Switch)而非 webhook 回调,适合无公网地址的 n8n 实例,但会增加总执行时间。 4. 人脸增强仅在 upscaling 阶段:face_enhance: true 只对 nano-banana-upscale 生效,不对原始生成生效。 5. 代码节点依赖:Code1 做了多层转义清理,若 Kie.ai 或 OpenAI 返回格式变化,可能需要调整解析逻辑。 6. 凭证类型:需 googleDriveOAuth2Api、googleSheetsOAuth2Api、openAiApi 三种凭证,均在 n8n 凭证管理器中配置。

n8n 工作流模板

结构已检查 · 未实际运行

下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。

配置与测试清单

需要绑定的凭证

  • Create folder 节点:绑定Google Drive OAuth2 凭证。
  • Add Fields 节点:绑定Google Sheets OAuth2 凭证。
  • Create spreadsheet 节点:绑定Google Sheets OAuth2 凭证。
  • Move Sheet 节点:绑定Google Drive OAuth2 凭证。
  • Update Image Status 节点:绑定Google Sheets OAuth2 凭证。
  • Story Status Update 节点:绑定Google Sheets OAuth2 凭证。
  • OpenAI Chat Model3 节点:绑定OpenAI API 凭证。
  • Upload file 节点:绑定Google Drive OAuth2 凭证。
  • Move Images 节点:绑定Google Drive OAuth2 凭证。
  • 将 __UKH_BEARER_0__ 替换为实际密钥/令牌(原路径 /nodes/0/parameters/headerParameters/parameters/0/value;literal auth header)。
  • 将 __UKH_BEARER_2__ 替换为实际密钥/令牌(原路径 /nodes/2/parameters/headerParameters/parameters/0/value;literal auth header)。
  • 将 __UKH_BEARER_21__ 替换为实际密钥/令牌(原路径 /nodes/21/parameters/headerParameters/parameters/0/value;literal auth header)。
  • 将 __UKH_BEARER_25__ 替换为实际密钥/令牌(原路径 /nodes/25/parameters/headerParameters/parameters/0/value;literal auth header)。

需要替换的配置

  • 源模板来自 n8n 公开库 #8492(约 33 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
  • Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。

测试输入与预期结果

  • 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
  • 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。

模板处理说明

  • 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
  • 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。 另将 4 处字面量密钥替换为 __UKH_…__ 占位符。

模板获取日期: 2026-10-24

步骤

  1. 项目初始化:创建文件夹与追踪表

    在 n8n 中导入模板后,首先检查凭证配置。工作流以手动触发节点(When clicking 'Execute workflow')开始。Folder Name 节点用 JavaScript 生成当前时间戳文件夹名(格式:Post HH:MM AM/PM DD Month YYYY)。随后 Create folder 在指定 Google Drive 父文件夹下创建该文件夹;Create spreadsheet 创建同名 Google Sheet;Move Sheet 将表格移入新建文件夹;Edit Fields 初始化 Prompt、Temp Image Url、Status 三个字段;Add Fields 向表格追加首行数据。

  2. 生成场景提示词

    Story Creator Agent 节点是一个 Basic LLM Chain,连接 OpenAI Chat Model(默认 gpt-4.1-mini)与 Structured Output Parser。系统消息中定义了统一的角色肖像风格模板:'A highly realistic modern cinematic portrait of the same girl, always facing the camera...',并保留 Styling Keywords(Photorealism, cinematic photography 等)。LLM 根据此模板生成具体场景的 prompt,经 Json parser4 约束为 {"prompt": "..."} 格式。Code1 节点对输出做转义清理与空白规范化,提取纯文本 prompt。Story Status Update 将生成的 prompt 和状态 'prompt created' 写回 Google Sheets 第 2 行。

    运行提示词 · 来源原文。Story Creator Agent 节点的 messages.messageValues[0].message 字段;作为 LLM Chain 的系统/风格指令

    A highly realistic modern cinematic portrait of the same girl, always facing the camera with a natural, expressive look. She is in [location/setting] wearing [modern, stylish outfit/clothing style], engaged in [action/mood]. Lighting and atmosphere are contemporary and cinematic, matching the environment with sleek tones and realistic detail. Ultra-detailed skin, expressive eyes, lifelike textures, cinematic depth of field, modern color grading, immersive realism.
    
    Styling Keywords (keep for all scenes):
    
    Photorealism, cinematic photography, modern fashion styling, expressive emotion, natural face, immersive lighting, dynamic depth, editorial aesthetic, storytelling tone.
  3. 调用 Kie.ai 生成图像

    Create Task (no callback) 节点向 https://api.kie.ai/api/v1/jobs/createTask 发送 POST 请求。请求体中 model 设为 'google/nano-banana-edit',input 包含上一步生成的 prompt 和 5 张参考图像 URL(image_urls 数组)、output_format: 'png'、image_size: 'auto'。Header 需携带 Authorization: Bearer YOUR_TOKEN_HERE。随后 Set TaskId 从响应中提取 data.taskId 供后续轮询使用。

    运行提示词 · 来源原文。Create Task (no callback) 节点的 jsonBody 字段;需将 image_urls 替换为实际参考图

    ={
      "model": "google/nano-banana-edit",
      "input": {
        "prompt": "{{ $json.Prompt }}",
        "image_urls": [
                  "https://i.ibb.co/q332LXHf/Whats-App-Image-2025-09-11-at-15-54-09.jpg",
                  "https://i.ibb.co/rPRzBdK/Whats-App-Image-2025-09-11-at-15-54-11-1.jpg",
                  "https://i.ibb.co/Zz9HPfZ9/Whats-App-Image-2025-09-11-at-15-54-12-1.jpg",
                  "https://i.ibb.co/tp7rhyK7/Whats-App-Image-2025-09-11-at-15-54-12-2.jpg",
                  "https://i.ibb.co/N2wDdJpJ/Whats-App-Image-2025-09-11-at-15-54-12-3.jpg"
        ],
        "output_format": "png",
        "image_size": "auto"
      }
    }
  4. 轮询任务状态并提取结果

    Wait 1 Min 节点等待 1 分钟后,Poll Task 向 https://api.kie.ai/api/v1/jobs/recordInfo 发送 GET 请求,查询参数 taskId 取自 Set TaskId 节点。Switch 节点根据 data.state 和 data.resultJson 判断:若 state='fail' 走失败分支;若 resultJson 为空则返回 Wait 1 Min 重新等待;若 resultJson 非空则进入成功分支。成功时 Get ResultUrls 用 JavaScript 解析 resultJson,提取 resultUrls 数组。

    运行提示词 · 来源原文。Get ResultUrls 节点的 jsCode 字段;用于从轮询响应中提取图像 URL

    // n8n Function node
    const items = $input.all();
    const out = [];
    
    for (const item of items) {
      // Your HTTP node sometimes returns an array at top-level
      const payload = item.json;
      const first = Array.isArray(payload) ? payload[0] : payload;
    
      // Get the stringified resultJson safely
      const resultJsonStr = first?.data?.resultJson ?? '';
    
      // Parse and extract
      let resultUrls = [];
      try {
        const parsed = JSON.parse(resultJsonStr);
        resultUrls = parsed?.resultUrls ?? [];
      } catch (e) {
        // leave resultUrls as []
      }
    
      out.push({ json: { resultUrls } });
    }
    
    return out;
  5. 4 倍超分与人脸增强

    Get ResultUrls 输出的 resultUrls[0] 传入 Upscale Image 节点。该节点向 https://api.kie.ai/api/v1/jobs/createTask 发送 POST,model 设为 'nano-banana-upscale',input 包含 image: resultUrls[0]、scale: 4、face_enhance: true。随后 Set TaskId for upscale 提取新 taskId,Wait 1 Min1 等待,Get Upscaled Image 轮询,Switch1 判断状态,Get ResultUrls from UpScale 解析最终结果 URL。

    运行提示词 · 来源原文。Upscale Image 节点的 jsonBody 字段

    ={
      "model": "nano-banana-upscale",
      "input": {
        "image": "{{ $json.resultUrls[0] }}",
        "scale": 4,
        "face_enhance": true
      }
    }

    运行提示词 · 来源原文。Get ResultUrls from UpScale 节点的 jsCode 字段

    // Build a new array of JSON objects with only resultUrls
    return $input.all().map(item => {
      const result = JSON.parse(item.json.data.resultJson);
      return {
        resultUrls: result.resultUrls
      };
    });
  6. 归档到 Google Drive

    Get Binary 节点以 resultUrls 为 URL 下载图像二进制。Upload file 将文件上传到 Google Drive(默认上传到硬编码的 prompt 文件夹,文件名使用 upscale taskId)。Move Images 将上传的文件移入第 1 步创建的时间戳文件夹中。

  7. 更新追踪表状态

    Update Image Status 节点更新 Google Sheets 第 2 行,将 Status 设为 'image created',Temp Image Url 设为 Get Binary 获取的 resultUrls[0]。至此完整流程结束,可在 Google Drive 时间戳文件夹中查看最终图像,在 Sheets 中查看全程状态记录。

可复制提示词

搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限,再按步骤替换硬编码参数

这一段是提示词,页面不会在这里插入广告。

你正在复现一个 n8n 工作流模板:用 Kie.ai 的 NanoBanana 模型生成一致角色图像并自动 4 倍超分。请先确认你已具备以下凭证:Kie.ai API Token、OpenAI API Key、Google Drive OAuth2、Google Sheets OAuth2。然后导入模板,替换硬编码的 Google Drive 文件夹 ID 和 5 张参考图像 URL,再执行手动触发。

替换 YOUR_TOKEN_HERE、文件夹 ID、参考图 URL 后再运行

来源

Create consistent AI characters with Google Nano Banana & upscaling via Kie.ai · mfarooqone · n8n.io · 2025-09-12

留言与反馈

试过这个方法吗?分享效果、遇到的问题或改进建议。留言审核后公开,请勿填写敏感信息。

正在加载…

    相关用例