Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: add image-to-video options to CLI generate video command (#13788)

Arvin Xu10914ff01571
diff --git a/apps/cli/man/man1/lh.1 b/apps/cli/man/man1/lh.1
index 64d4db586db..b173c8b09bb 100644
--- a/apps/cli/man/man1/lh.1
+++ b/apps/cli/man/man1/lh.1
@@ -1,6 +1,6 @@
.\" Code generated by `npm run man:generate`; DO NOT EDIT.
.\" Manual command details come from the Commander command tree.
-.TH LH 1 "" "@lobehub/cli 0.0.4" "User Commands"
+.TH LH 1 "" "@lobehub/cli 0.0.5" "User Commands"
.SH NAME
lh \- LobeHub CLI \- manage and connect to LobeHub services
.SH SYNOPSIS
diff --git a/apps/cli/package.json b/apps/cli/package.json
index 3fc2182fcb0..5f0e71d7ce4 100644
--- a/apps/cli/package.json
+++ b/apps/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@lobehub/cli",
- "version": "0.0.4",
+ "version": "0.0.5",
"type": "module",
"bin": {
"lh": "./dist/index.js",
diff --git a/apps/cli/src/commands/generate.test.ts b/apps/cli/src/commands/generate.test.ts
index 9bf4c1413cf..59778549366 100644
--- a/apps/cli/src/commands/generate.test.ts
+++ b/apps/cli/src/commands/generate.test.ts
@@ -270,6 +270,48 @@ describe('generate command', () => {
);
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Video generation started'));
});
+
+ it('should pass image-to-video params', async () => {
+ mockTrpcClient.generationTopic.createTopic.mutate.mockResolvedValue('topic-3');
+ mockTrpcClient.video.createVideo.mutate.mockResolvedValue({
+ data: { generationId: 'gen-v2' },
+ success: true,
+ });
+
+ const program = createProgram();
+ await program.parseAsync([
+ 'node',
+ 'test',
+ 'generate',
+ 'video',
+ 'a cat waving',
+ '--model',
+ 'cogvideox',
+ '--provider',
+ 'zhipu',
+ '--image',
+ 'https://example.com/first.png',
+ '--end-image',
+ 'https://example.com/last.png',
+ '--images',
+ 'https://example.com/a.png',
+ 'https://example.com/b.png',
+ ]);
+
+ expect(mockTrpcClient.video.createVideo.mutate).toHaveBeenCalledWith(
+ expect.objectContaining({
+ generationTopicId: 'topic-3',
+ model: 'cogvideox',
+ params: {
+ endImageUrl: 'https://example.com/last.png',
+ imageUrl: 'https://example.com/first.png',
+ imageUrls: ['https://example.com/a.png', 'https://example.com/b.png'],
+ prompt: 'a cat waving',
+ },
+ provider: 'zhipu',
+ }),
+ );
+ });
});
describe('tts', () => {
diff --git a/apps/cli/src/commands/generate/video.ts b/apps/cli/src/commands/generate/video.ts
index ea1f4c6c570..12a87947d8f 100644
--- a/apps/cli/src/commands/generate/video.ts
+++ b/apps/cli/src/commands/generate/video.ts
@@ -6,13 +6,16 @@ import { getTrpcClient } from '../../api/client';
export function registerVideoCommand(parent: Command) {
parent
.command('video <prompt>')
- .description('Generate a video from text')
+ .description('Generate a video from text or image(s)')
.requiredOption('-m, --model <model>', 'Model ID')
.requiredOption('-p, --provider <provider>', 'Provider name')
.option('--aspect-ratio <ratio>', 'Aspect ratio (e.g. 16:9)')
.option('--duration <sec>', 'Duration in seconds')
.option('--resolution <res>', 'Resolution (e.g. 720p, 1080p)')
.option('--seed <n>', 'Random seed')
+ .option('--image <url>', 'First-frame image URL (image-to-video)')
+ .option('--images <urls...>', 'Multiple reference image URLs')
+ .option('--end-image <url>', 'Last-frame image URL')
.option('--json', 'Output raw JSON')
.action(
async (
@@ -20,6 +23,9 @@ export function registerVideoCommand(parent: Command) {
options: {
aspectRatio?: string;
duration?: string;
+ endImage?: string;
+ image?: string;
+ images?: string[];
json?: boolean;
model: string;
provider: string;
@@ -35,6 +41,9 @@ export function registerVideoCommand(parent: Command) {
if (options.duration) params.duration = Number.parseInt(options.duration, 10);
if (options.resolution) params.resolution = options.resolution;
if (options.seed) params.seed = Number.parseInt(options.seed, 10);
+ if (options.image) params.imageUrl = options.image;
+ if (options.images && options.images.length > 0) params.imageUrls = options.images;
+ if (options.endImage) params.endImageUrl = options.endImage;
const result = await client.video.createVideo.mutate({
generationTopicId: topicId as string,