8
n8n 中文网amn8n.com

使用OpenAI和Fal.ai Minimax从文本提示生成歌词和音乐

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 17 个节点。主要使用 Set, Wait, Switch, HttpRequest, Agent 等节点。 使用OpenAI和Fal.ai Minimax从文本提示生成歌词和音乐

前置要求
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "3d7eb9567ae690bf8c9bba1cb43396e6e40c18e15eb5889cf9673ed1713da6db",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "f0e867a5-c202-4948-92c2-5e1bc371a241",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1440,
        1056
      ],
      "webhookId": "c559fea6-2514-4baa-92c7-65ccc7a46640",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "d0b0ab98-d2a7-4375-b659-41e894942452",
      "name": "AI 歌曲创作代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1216,
        1056
      ],
      "parameters": {
        "options": {
          "systemMessage": "=You are an AI songwriting agent that generates original song lyrics instantly from user input. You do not engage in conversation - you immediately create and deliver complete, ready-to-use song lyrics.\n\n## Your Task\n\nAnalyze the user's query and instantly generate:\n1. Complete original song lyrics with labeled sections (MUST be at least 600 characters)\n2. The lyrical style/genre description (MUST be at least 10 characters)\n\n## Output Format\n\nAlways output valid JSON with this exact structure:\n\n{\n  \"lyrical_style\": \"[Detailed genre description - minimum 10 characters]\",\n  \"lyrics\": \"[Complete lyrics with section labels - minimum 600 characters]\"\n}\n\n## Critical Constraints\n\n- **lyrics field**: MUST be at least 600 characters total (including spaces, line breaks, and section labels)\n- **lyrical_style field**: MUST be at least 10 characters long (e.g., \"Pop, upbeat and catchy\" not just \"Pop\")\n- Keep lyrics detailed - aim for full song structure with 2-3 verses, chorus, and bridge to meet 600+ characters\n- Use compact section labels like [V1], [C], [V2], [B] to optimize space while expanding content\n\n## Lyrical Guidelines\n\n- Create 100% original content - never reproduce existing lyrics\n- Match the style to the user's query (if they mention a genre, use it; otherwise infer from the theme)\n- Use appropriate language, flow, and structure for the genre:\n  * Pop: Catchy, repetitive choruses, relatable themes\n  * R&B: Smooth, soulful, emotional, romantic themes\n  * Rap/Hip-Hop: Rhythmic verses, internal rhymes, wordplay, flow-focused\n  * Rock: Energetic, rebellious, powerful imagery\n  * Country: Storytelling, narrative-driven, down-to-earth\n  * Indie/Folk: Introspective, poetic, authentic\n- Use vivid imagery and genuine emotion\n- Ensure natural rhythm and flow appropriate to the genre\n- Expand thoughtfully - include 3-5 lines per section to reach 600+ characters\n\n## Structure Recommendations for Character Limit\n\nTo meet the 600+ character requirement, use fuller structures:\n- Option 1: [V1] + [C] + [V2] + [B] + [C]\n- Option 2: [Intro] + [V1] + [C] + [V2] + [C]\n- Option 3: [V1] + [C] + [V2] + [B] + [Outro]\n\nUse descriptive, flowing lines. Each verse 4-6 lines, chorus 4 lines, bridge 3-4 lines.\n\n## Important Rules\n\n- NO conversation or clarifying questions - generate immediately\n- ALWAYS output valid JSON only\n- ALWAYS be original - never copy existing songs\n- ALWAYS ensure lyrics are at least 600 characters\n- ALWAYS ensure lyrical_style is at least 10 characters\n- Count characters carefully before outputting\n\nGenerate the song now based on the user's input."
        },
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "25dc2495-fd91-4543-b936-1a6fd9cae21f",
      "name": "设置脚本变量",
      "type": "n8n-nodes-base.set",
      "position": [
        -896,
        1056
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c8ecbac4-9cd0-424c-a8b6-1f2ed0b36c22",
              "name": "Lyrical_style",
              "type": "string",
              "value": "={{ $json.output.lyrical_style }}"
            },
            {
              "id": "e75f7a59-604e-4473-b079-01df81a130d5",
              "name": "Lyrics",
              "type": "string",
              "value": "={{ $json.output.lyrics }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ae8c433e-ad2f-4fde-8410-e1563bb7d176",
      "name": "生成音乐轨道",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -688,
        1056
      ],
      "parameters": {
        "url": "=https://queue.fal.run/fal-ai/minimax-music/v1.5",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $json.Lyrics }}"
            },
            {
              "name": "lyrics_prompt",
              "value": "={{ $json.Lyrical_style }}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "0C54MHHdmxNXiy37",
          "name": "Fal.ai"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "90fad7f3-9885-44bc-92a0-4c6dbc423980",
      "name": "等待生成完成",
      "type": "n8n-nodes-base.wait",
      "position": [
        -480,
        1056
      ],
      "webhookId": "45132729-ca25-4aac-a8e0-a6d72463a2c2",
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "0a9c64f8-22c6-447e-886e-75b2d20a24f9",
      "name": "检查生成状态",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -272,
        1056
      ],
      "parameters": {
        "url": "=https://queue.fal.run/fal-ai/minimax-music/requests/{{ $json.request_id }}/status",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "0C54MHHdmxNXiy37",
          "name": "Fal.ai"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a221fe90-04d0-4baf-bc16-f9d10f30fe33",
      "name": "根据状态路由",
      "type": "n8n-nodes-base.switch",
      "position": [
        -64,
        1056
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Done",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d8b8dbdc-1ad9-4ab9-8b2d-e76fd5db0899",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "COMPLETED"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Progress",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9c10982c-5f8c-4eec-9b8a-f4b42e99ecf9",
                    "operator": {
                      "type": "string",
                      "operation": "notEquals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "COMPLETED"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "1971d68b-8295-45dd-978b-cc27a09e148d",
      "name": "获取最终结果",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        144,
        1040
      ],
      "parameters": {
        "url": "=https://queue.fal.run/fal-ai/minimax-music/requests/{{ $json.request_id }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "0C54MHHdmxNXiy37",
          "name": "Fal.ai"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "cbc0a955-da9c-49c2-97a9-cbf459516fac",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1216,
        1216
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-chat-latest",
          "cachedResultName": "gpt-5-chat-latest"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "ymMvgDroJHalwvRf",
          "name": "OpenAI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "fa63b886-0761-404d-9d3a-e5cdad9a3eed",
      "name": "注意:聊天触发器",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1568,
        816
      ],
      "parameters": {
        "color": 6,
        "width": 380,
        "height": 208,
        "content": "## 💬 当收到聊天消息时"
      },
      "typeVersion": 1
    },
    {
      "id": "72a4a665-4631-4f4f-9d47-5921941ea43a",
      "name": "注意:歌曲创作核心",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1328,
        1344
      ],
      "parameters": {
        "color": 5,
        "width": 364,
        "height": 176,
        "content": "## 🤖 AI 歌曲创作代理 + OpenAI 聊天模型 + 解析输出"
      },
      "typeVersion": 1
    },
    {
      "id": "416b5063-e4f7-4854-8b42-820eae4acaf6",
      "name": "注意:变量设置",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        816
      ],
      "parameters": {
        "color": 3,
        "width": 364,
        "height": 208,
        "content": "## 📝 设置脚本变量"
      },
      "typeVersion": 1
    },
    {
      "id": "6ad96629-57ac-4458-b8cb-d6268e3395cd",
      "name": "注意:音乐队列",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -832,
        1344
      ],
      "parameters": {
        "color": 6,
        "width": 396,
        "height": 112,
        "content": "## 🎵 生成音乐轨道"
      },
      "typeVersion": 1
    },
    {
      "id": "49d527f2-54d3-4379-99a3-8b6724ddbb05",
      "name": "注意:轮询循环",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -432,
        816
      ],
      "parameters": {
        "color": 2,
        "width": 364,
        "height": 208,
        "content": "## ⏳ 等待生成 + 📊 检查生成状态"
      },
      "typeVersion": 1
    },
    {
      "id": "7246b4e6-2d27-4ff3-a66e-31e08508f60e",
      "name": "注意:完成处理器",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        1296
      ],
      "parameters": {
        "color": 2,
        "width": 348,
        "height": 208,
        "content": "## 🔀 根据状态路由 + 📥 获取最终结果"
      },
      "typeVersion": 1
    },
    {
      "id": "118aa11c-d7b0-4fbc-8f2c-8f1e745152be",
      "name": "解析输出1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -1072,
        1216
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "={\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"lyrical_style\": {\n      \"type\": \"string\",\n      \"description\": \"The genre or style of the song (e.g., Pop, R&B, Rap, Rock, Country, Hip-Hop, Indie, Folk)\"\n    },\n    \"lyrics\": {\n      \"type\": \"string\",\n      \"description\": \"Complete song lyrics with all sections labeled (e.g., [VERSE 1], [CHORUS], [BRIDGE])\"\n    }\n  },\n  \"required\": [\"lyrical_style\", \"lyrics\"],\n  \"additionalProperties\": false\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "4e2839c3-cda0-4704-915c-a19d7fe2e487",
      "name": "概览说明6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2336,
        464
      ],
      "parameters": {
        "color": 4,
        "width": 712,
        "height": 1176,
        "content": "# 🤖 AI 歌曲创作聊天:从歌词到完整音乐轨道"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Parse Output1": {
      "ai_outputParser": [
        [
          {
            "node": "AI Songwriting Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Route on Status": {
      "main": [
        [
          {
            "node": "Fetch Final Result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Songwriting Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Generation": {
      "main": [
        [
          {
            "node": "Check Generation Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Songwriting Agent": {
      "main": [
        [
          {
            "node": "Set Script Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Music Track": {
      "main": [
        [
          {
            "node": "Wait for Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Script Variables": {
      "main": [
        [
          {
            "node": "Generate Music Track",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Generation Status": {
      "main": [
        [
          {
            "node": "Route on Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Songwriting Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 内容创作, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
高级
节点数量17
分类2
节点类型9
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Daniel Nkencho

Daniel Nkencho

@daniel-automates

AI Automation Consultant | Helping Business Owners Implement AI Systems for Growth and Lead Gen

外部链接
在 n8n.io 查看

分享此工作流