图像视频生成CLI工具

lingjing-cli是一个命令行工具和MCP服务器,用于访问京东云灵境的图像和视频生成API,支持预设模型管理、图像视频生成及任务管理。

  • by Algovate
  • TypeScript
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 Algovate/lingjing-cli

使用说明

凌景cli

用于JDCloud Lingjing图像和视频生成API的CLI和MCP服务器。

📦 安装

# Install globally
npm install -g lingjing-cli

# Or use directly via npx
npx lingjing-cli

如果您在本地从源代码运行,则可以使用 npm run build 然后跑 node dist/cli.js 而不是 lingjing.

⚙️ 配置

通过环境变量设置API密钥:

export LINGJING_API_KEY="your_api_key_here"
# Alternatively, you can use JDCLOUD_API_KEY

您还可以使用 .env 当前目录中的文件,或通过指定一个 --env-file <path>.

全局CLI选项

lingjing [global-options] <command> [options]
  • --env-file <path>:从特定文件加载环境变量
  • --skip-env:禁用自动加载 .env
  • --api-key <key>, -k:重写API密钥
  • --base-url <url>:覆盖API基本URL(默认值: https://model.jdcloud.com)
  • --request-id <id>:指定自定义 x-jdcloud-request-id 头球
  • --json:输出纯JSON(对管道和解析有用)

🚀 CLI命令

1.模型预设(preset)

查看可用的即用型预设:

# List all presets
lingjing preset list

# Filter by type (image | video)
lingjing preset list --type image

# Filter by provider (e.g., kling, doubao, vidu, hailuo)
lingjing preset list --provider kling --type video

# Find presets by supported parameter / input type
lingjing preset list --supports-param multi_shot --supports-input image_url

# Compact browsing output
lingjing preset list --compact

# Get a single preset with full capSpec
lingjing preset get kling-v3-ttv

1.1能力参考(机器可读优先)

每个预设现在都有一个 capSpec 结构稳定:

  • summary:简短的能力总结
  • inputs:支持的输入类型(text_prompt, image_url, image_list, ref_video)
  • params:参数规格(type, required, default, enum, range, description)
  • constraints:特定于模型的限制和条件支持
  • examples:最小示例有效载荷片段

2.图像生成(image)

提交图像生成任务并自动等待结果:

# Doubao SeedDream 4.0
lingjing image \
  --preset doubao-seedream-4-0 \
  --params '{"prompt":"一只戴墨镜的猫","size":"2048x2048","taskNum":1}'

# Kling Image Generation
lingjing image \
  --preset kling-v2-1-image \
  --params '{"prompt":"城市夜景,赛博朋克风格","aspect_ratio":"16:9"}'

# Submit only (without waiting/polling), returns genTaskId
lingjing image \
  --preset doubao-seedream-4-0 \
  --params '{"prompt":"山间晨雾"}' \
  --no-wait

3.视频生成(video)

提交视频生成任务并等待结果:

# Text-to-Video: Kling V3
lingjing video \
  --preset kling-v3-ttv \
  --params '{"prompt":"海边日落,海浪轻拍礁石","duration":"5","mode":"pro","aspect_ratio":"16:9"}'

# Text-to-Video: Doubao Seedance 1.5 Pro
lingjing video \
  --preset doubao-seedance-1-5-pro-ttv \
  --params '{"prompt":"雪山脚下奔跑的骏马","aspect_ratio":"16:9"}'

# Image-to-Video: Kling V3 (Requires a reference image)
lingjing video \
  --preset kling-v3-ptv \
  --params '{"prompt":"人物转身微笑","image_url":"https://example.com/ref.jpg","duration":"5"}'

# Custom polling interval and timeout
lingjing video \
  --preset vidu-q2-ttv \
  --params '{"prompt":"极光下的雪原"}' \
  --interval 10 --timeout 300

在线覆盖特定参数(--set): 你可以使用 --set key=value 覆盖 params 字段容易:

lingjing video \
  --preset kling-v3-ttv \
  --params '{"prompt":"星空延时摄影"}' \
  --set duration=10 \
  --set aspect_ratio=9:16

4.任务管理(task)

如果您使用以下方式提交任务 --no-wait,您可以稍后使用其查询或轮询其状态 genTaskId:

# Query the current status of a task
lingjing task get <genTaskId>

# Polling a task until it completes or times out
lingjing task wait <genTaskId> --interval 5 --timeout 600

任务状态参考:

  • taskStatus=4:成功
  • taskStatus=2:失败

🤖 MCP 服务器

lingjing-cli 可以作为 MCP(模型上下文协议) 服务器通过stdio。

启动MCP服务器

# Run globally installed version:
LINGJING_API_KEY=your_key lingjing-mcp

# Or via the CLI subcommand:
LINGJING_API_KEY=your_key lingjing mcp

# Load from an explicitly defined .env file:
LINGJING_ENV_FILE=/path/to/.env lingjing-mcp

Claude桌面集成

您可以轻松地将MCP服务器添加到Claude Code或Claude Desktop。

克劳德代码:

claude mcp add lingjing-cli -- npx -y lingjing-cli mcp

(请确保配置您的 LINGJING_API_KEY 在您的环境中或通过 LINGJING_ENV_FILE 变量)

适用于克劳德桌面 claude_desktop_config.json:

{
  "mcpServers": {
    "lingjing": {
      "command": "npx",
      "args": ["-y", "lingjing", "mcp"],
      "env": {
        "LINGJING_API_KEY": "your_api_key_here"
      }
    }
  }
}

可用的MCP工具

工具 说明
list_presets 列出具有完整功能规格的预设;支持能力/提供者/输入/参数过滤器 compact 模式。
get_preset_capability 获取一个预设的完整功能规格。
find_presets_by_capability 根据支持的输入/参数功能查找预设值(compact 可选)。
generate_image 提交图像生成任务并自动等待结果。
generate_video 提交视频生成任务并自动等待结果(默认超时600秒)。

list_presets

参数 类型 说明
capability image text-to-video
provider doubao hailuo
supportsParam string 按支持的参数名称筛选(可选)
supportsInput text_prompt image_url
compact boolean 紧凑输出模式(默认值: false)

get_preset_capability

参数 类型 说明
preset string 预设键。, kling-v3-ttv

find_presets_by_capability

参数 类型 说明
capability image text-to-video
provider doubao hailuo
supportsParam string 按支持的参数名称筛选(可选)
supportsInput text_prompt image_url
compact boolean 紧凑输出模式(默认值: false)

generate_image / generate_video

参数 类型 默认值 说明
preset string -- 预设键。, doubao-seedream-4-0
params object -- 任务参数对象(例如prompt、aspect_ratio)
interval number 5 轮询间隔(秒)
timeout number 300/600 最大等待时间(秒)

退货: { submit, result, urls },在哪里 urls 轻松地将提取的直接链接提供给生成的媒体。

许可证

麻省理工学院