零成本搭建 AI 视频自动化流水线:VPS 编排 + Kie AI 生成 + Telegram 推送

起因

我想验证一件事:没有 GPU 的 VPS,能不能做 AI 视频自动化?

手头资源有限:

  • VPS 没有 GPU,5.8Gi 内存
  • 不想花钱订阅视频生成 SaaS
  • 想跑通”定时触发 → 视频生成 → 自动推送”的完整闭环

结论:可以。 核心思路是把 VPS 当作”编排中枢”,把重度的视频生成交给外部 API。

整体架构

text

VPS(编排层)
├── n8n(Schedule Trigger 定时触发)
│       ↓
│   One API → 生成视频描述 prompt
│       ↓
│   Kie AI → 提交视频生成任务
│       ↓
│   轮询任务状态
│       ↓
│   下载视频
│       ↓
│   Telegram Bot → 推送到手机

VPS 只负责编排(调用 API、轮询状态、下载文件),视频生成在云端完成,不占 VPS 任何 GPU 或内存资源。

技术栈

组件作用
n8n工作流编排
One APILLM 网关,生成视频描述
Kie AI云端视频生成 API
Telegram Bot接收生成的视频

第一步:n8n 里搭建工作流

在 n8n 里创建以下节点链:

text

Schedule Trigger
    ↓
HTTP Request(调 One API 生成 prompt)
    ↓
HTTP Request(提交 Kie AI 任务)
    ↓
Wait 30s
    ↓
HTTP Request(轮询状态)
    ↓
IF(判断是否完成)
    ↓ 是
HTTP Request(下载视频)
    ↓
Telegram(推送视频)

节点 1:Schedule Trigger

  • Interval: Days
  • Trigger at Hour: 9

节点 2:HTTP Request(生成视频 prompt)

  • Method: POST
  • URL: http://172.17.0.1:3000/v1/chat/completions
  • Headers:
    • Authorization: Bearer sk-你的OneAPI令牌
    • Content-Type: application/json
  • Body:

json

{
  "model": "gemma4:31b",
  "messages": [{"role": "user", "content": "Generate a short video prompt for a nature scene, 5 seconds, cinematic. Output only the prompt."}],
  "max_tokens": 200,
  "stream": false
}

生成的 prompt 示例

text

Cinematic slow-motion drone shot sweeping over a misty pine forest at sunrise, golden light filtering through towering trees, 4k, highly detailed, ethereal atmosphere.

节点 3:HTTP Request(提交 Kie AI 任务)

  • Method: POST
  • URL: https://api.kie.ai/api/v1/jobs/createTask
  • Headers:
    • Authorization: Bearer 你的KieAI密钥
    • Content-Type: application/json
  • Body:

json

{
  "model": "grok-imagine/text-to-video",
  "input": {
    "prompt": "{{ $('Generate Video Prompt').item.json.choices[0].message.content }}",
    "duration": "6",
    "aspect_ratio": "9:16"
  },
  "callBackUrl": "https://example.com/callback"
}

返回

json

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "45ceba0aeb0a40508e70a021c785b017",
    "recordId": "45ceba0aeb0a40508e70a021c785b017"
  }
}

节点 4:Wait

  • Amount: 30 seconds

节点 5:HTTP Request(轮询状态)

  • Method: GET
  • URL: https://api.kie.ai/api/v1/jobs/recordInfo?taskId={{ $('Submit Video Task').item.json.data.taskId }}
  • Headers:
    • Authorization: Bearer 你的KieAI密钥

返回

json

{
  "code": 200,
  "data": {
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://.../generated_video.mp4\"]}",
    "response": {
      "resultUrls": ["https://.../generated_video.mp4"]
    },
    "costTime": 28,
    "creditsConsumed": 14.4
  }
}

节点 6:IF(判断是否完成)

  • 左值:{{ $json.data.state }}
  • 运算符:equals
  • 右值:success
  • True → 下载视频
  • False → 回到 Wait 30s 继续轮询

节点 7:HTTP Request(下载视频)

  • Method: GET
  • URL: {{ $json.data.response.resultUrls[0] }}
  • Options → Response → Response Format: File

节点 8:Telegram(推送视频)

  • Credential: Telegram Bot Token
  • Resource: Message
  • Operation: Send Video
  • Chat ID: 你的个人Chat ID
  • Binary Data: 开启
  • Binary Property: data

第二步:创建 Telegram Bot

1. 创建 Bot

在 Telegram 搜索 @BotFather,发送 /newbot,按提示设置名称和用户名。它会返回一个 Token,形如:

text

8610027919:AAGgQUdZc1KoNU14MJaHHc13IigMwKyDbyA

2. 获取你的 Chat ID

在 Telegram 搜索 @userinfobot,点 Start。它会返回你的个人信息,其中 Id 就是你的个人 Chat ID。

或者,给刚创建的 Bot 发一条消息,然后在浏览器访问:

text

https://api.telegram.org/bot<你的Token>/getUpdates

返回的 JSON 里,message.chat.id 就是你的个人 Chat ID。

3. 配置 n8n 凭据

在 n8n 的 Credentials 里创建 Telegram 凭据,填入 Bot Token。

实测结果

输入:定时触发,自动生成一段森林航拍的视频 prompt

输出

字段
模型grok-imagine/text-to-video
视频时长6 秒
分辨率416 × 752(竖版 9:16)
文件大小1.7 MB
生成耗时28 秒
消耗积分14.4

从触发到视频出现在 Telegram,全程约 1 分钟,零人工干预。

踩坑记录

1. Kie AI 的 callBackUrl 是必填

即使你不用回调,也必须传这个字段,否则报 This field is required。随便填一个 URL 即可。

2. 模型名必须精确匹配

kling-1.6/text-to-video 返回 422 The model name you specified is not supported。Kie AI 的模型名有固定格式,用之前先确认。

3. 积分不足

code: 402 Credits insufficient 说明余额不够跑当前模型。Seedance 2.5 需要 100+ 积分,Grok Imagine 只要 14.4。

4. Telegram Chat ID 填错

填入 Bot 自己的 ID 会报 Forbidden: the bot can't send messages to the bot。必须填你的个人 Chat IDmessage.chat.id),不是 Bot 的 ID(message.from.id)。

5. Telegram 凭据配置

先在 Telegram 里给 Bot 发一条消息(/starthi),否则 Bot 无法主动给你发消息,会报 chat not found

6. 轮询 URL 里的字段路径

taskIdSubmit Video Task 节点的 data 对象里,引用时要写 {{ $('Submit Video Task').item.json.data.taskId }},不能漏掉 .data

成本分析

项目成本
VPS 编排已有,零额外成本
One API(prompt 生成)Ollama Cloud 免费额度
Kie AI(视频生成)14.4 积分/次
Telegram 推送免费

Kie AI 新用户送约 80 积分,能跑 5-6 次。之后需要充值或换更便宜的模型。

可优化的方向

  1. 加日语配音:结合 edge-tts,给视频配上日语旁白
  2. 批量生成:改触发频率,每天生成多条视频
  3. 换更便宜的模型:Grok Imagine 每次 14.4 积分,可以试试更低价的选项
  4. 用免费平台替代fal.ai 的 MiniMax H3 每天免费 5 条,Agnes Video 每天 200 积分

一句话总结

没有 GPU 不代表不能做 AI 视频。 把链路拆成”编排”和”生成”两段,VPS 负责编排(n8n + One API),云端 API 负责生成(Kie AI)。整条流水线全自动运行,每次成本约 14 积分。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注