返回首页
Agent-Native CLI

AI Agent 集成指南

在 Claude Code、Cursor 等 AI Agent 中使用文镜画师 — 视频 / 图片 / 音频 / 文本生成能力一键接入

快速开始(2 条命令)

npm install -g @kanesong/wj
wj skills add --yes

概览

文镜画师(WenJing)是 AI 内容生成平台,提供视频、图片、音频、文本生成能力。

wj CLI 是该平台的 Agent-Native 命令行工具,专为 AI Agent(Claude Code、Cursor、OpenClaw 等)设计:

  • 所有命令默认输出 JSON,直接可被 Agent 解析
  • 内置 wj schema 命令,动态查询任意命令的参数 Schema
  • 6 个 SKILL.md 文件覆盖核心功能域,安装后 Agent 自动加载

第一步:注册账号

CLI 不提供注册命令,注册须通过 Web 平台完成。

  1. 前往 wenjing.art 注册账号(手机号)
  2. 注册即赠初始算力,用于体验 AI 生成功能

第二步:安装 CLI

npm install -g @kanesong/wj
# 验证安装
wj --version

第三步:登录

# 交互式登录(推荐)
wj login --username 13800138000
# → 提示输入密码(隐藏字符,不进 shell history)

# 验证登录状态和算力余额
wj whoami

返回示例:

{
  "service": "portal",
  "userId": "1765033672064047",
  "userName": "张三",
  "computeHours": 99.50,
  "memberType": "PRO"
}

computeHours = 当前算力余额,所有 AI 生成任务按算力计费。


第四步:安装 Skills 到 AI Agent

# 在项目根目录执行
wj skills add --yes

执行后,Skill 文件自动安装到 .claude/skills/.cursor/skills/.openclaw/skills/,Agent 工具重启后即可自动加载。


可用 Skills 一览

Skill 功能
wj-shared 必读基础 — 认证、安全规则、通用工作流
wj-video 视频生成(T2V / I2V),5 种模型
wj-image 图片生成,9 种模型
wj-image-edit 图片编辑(局部重绘 / 扩图 / 去水印 / 超分辨率)
wj-audio 文字转语音 + 声音克隆
wj-text 文本推理(DeepSeek / Gemini / Qwen3-VL)

核心使用模式

发现命令与参数

wj schema                              # 列出全部 79 个命令
wj schema video.create                 # 查看视频模型列表
wj schema video.create --model kling-omni  # 查看具体参数

异步任务流程(视频 / 图片 / 音频通用)

# 方式 A:一步到位(自动轮询直到完成)
wj video.create --model kling-omni --prompt "城市夜景延时摄影" --wait

# 方式 B:手动控制
wj video.create --model seedance15 --prompt "春天的樱花" --duration 8
# → {"id":"task-abc123","status":"1"}
wj video.query --id task-abc123 --poll
# → {"id":"task-abc123","status":"3","videoUrl":"https://..."}

任务状态码: "1" 排队 | "2" 生成中 | "3" 成功 | "4" 失败


各功能快速示例

视频生成

# 文生视频(5 种模型)
wj video.create --model kling-omni --prompt "极光下的雪山" --duration 10 --wait

# 图生视频
wj video.create --model seedance15 \
  --prompt "缓缓绽放的花朵" \
  --first-frame https://cdn.example.com/flower.jpg --wait

图片生成

# 高质量 4K 图片
wj image.create --model nano-banana-pro \
  --prompt "赛博朋克城市夜景" --ratio 16:9 --resolution 4K --wait

# MidJourney 艺术风格
wj image.create --model midjourney \
  --prompt "a cat in space, photorealistic" --ratio 1:1 --wait

图片编辑

wj image.edit --type outpaint --image-url https://... --ratio 16:9
wj image.edit --type super-resolution --image-url https://... --scale 4
wj image.edit --type remove-watermark --image-url https://...

文字转语音

wj audio.create --prompt "欢迎使用文镜 AI 平台" --wait
wj audio.create --prompt "今日新闻:..." \
  --voice male-qn-qingse --emotion professional --wait

# 声音克隆
wj audio.voice-clone --audio-url https://example.com/sample.mp3
# → {"voiceId":"custom-xxx"}
wj audio.create --prompt "你好世界" --voice custom-xxx --wait

文本推理

wj text.request --model deepseek --content "用 Python 写一个快速排序"
wj text.stream  --model deepseek-stream --content "写一篇关于量子计算的文章"
wj text.request --model qwen3-vl \
  --content "描述图片内容" \
  --images "https://example.com/image.png"

组合工作流:图生视频

# 1. 生成参考图片
wj image.create --model nano-banana-pro \
  --prompt "冰川极地风景,蓝色调,超写实" --ratio 16:9 --wait
# → {"images":["https://cdn.example.com/glacier.png"]}

# 2. 图片转视频
wj video.create --model kling-omni \
  --first-frame https://cdn.example.com/glacier.png \
  --prompt "缓缓漂移的冰川,镜头慢推" --duration 8 --wait
# → {"videoUrl":"https://cdn.example.com/glacier.mp4"}

安全规则(Agent 必读)

规则 说明
不要提取 Token JWT 由 CLI 内部管理,Agent 无法读取
删除操作需 --confirm 不加此标志会被 CLI 拦截
算力消耗不可逆 提交前确认参数,避免用错高费用模型

错误处理

错误 处理方式
未登录 / 401 运行 wj login --username <手机号>
算力不足 前往 wenjing.art 充值
未知模型 wj schema video.create 查看可用模型
任务失败(status=4) 读取 failReason,常见原因:提示词违规、图片格式错误

逃生舱:直接调用 API

当 CLI 命令不满足需求时,可直接调用底层 API:

wj api GET /api/auth/getUserInfo?userId=<userId>
wj api POST /api/video/kling-omni/create '{"prompt":"test","mode":"std"}'

服务地址配置

服务 生产环境地址 环境变量
Portal(AI 生成) https://api.wenjing.art WJ_PORTAL_URL
# 生产环境示例
WJ_PORTAL_URL=https://api.wenjing.art wj video.create --model kling-omni --prompt "..."
更新日期:2026-03-29·返回首页·wenjing.art