kling-pro-cli 2026.6.30.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kling_pro_cli-2026.6.30.0/.env.example +4 -0
- kling_pro_cli-2026.6.30.0/.gitignore +32 -0
- kling_pro_cli-2026.6.30.0/CHANGELOG.md +18 -0
- kling_pro_cli-2026.6.30.0/LICENSE +21 -0
- kling_pro_cli-2026.6.30.0/PKG-INFO +109 -0
- kling_pro_cli-2026.6.30.0/README.md +63 -0
- kling_pro_cli-2026.6.30.0/kling_cli/__init__.py +1 -0
- kling_pro_cli-2026.6.30.0/kling_cli/__main__.py +5 -0
- kling_pro_cli-2026.6.30.0/kling_cli/commands/__init__.py +1 -0
- kling_pro_cli-2026.6.30.0/kling_cli/commands/info.py +53 -0
- kling_pro_cli-2026.6.30.0/kling_cli/commands/lipsync.py +176 -0
- kling_pro_cli-2026.6.30.0/kling_cli/commands/motion.py +103 -0
- kling_pro_cli-2026.6.30.0/kling_cli/commands/task.py +142 -0
- kling_pro_cli-2026.6.30.0/kling_cli/commands/video.py +416 -0
- kling_pro_cli-2026.6.30.0/kling_cli/core/__init__.py +1 -0
- kling_pro_cli-2026.6.30.0/kling_cli/core/client.py +119 -0
- kling_pro_cli-2026.6.30.0/kling_cli/core/config.py +39 -0
- kling_pro_cli-2026.6.30.0/kling_cli/core/exceptions.py +37 -0
- kling_pro_cli-2026.6.30.0/kling_cli/core/output.py +150 -0
- kling_pro_cli-2026.6.30.0/kling_cli/main.py +77 -0
- kling_pro_cli-2026.6.30.0/pyproject.toml +118 -0
- kling_pro_cli-2026.6.30.0/tests/__init__.py +1 -0
- kling_pro_cli-2026.6.30.0/tests/conftest.py +92 -0
- kling_pro_cli-2026.6.30.0/tests/test_commands.py +723 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
*.egg
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
ENV/
|
|
16
|
+
|
|
17
|
+
# Environment variables
|
|
18
|
+
.env
|
|
19
|
+
|
|
20
|
+
# IDE
|
|
21
|
+
.vscode/
|
|
22
|
+
.idea/
|
|
23
|
+
*.swp
|
|
24
|
+
*.swo
|
|
25
|
+
|
|
26
|
+
# Testing
|
|
27
|
+
.coverage
|
|
28
|
+
htmlcov/
|
|
29
|
+
.pytest_cache/
|
|
30
|
+
|
|
31
|
+
# mypy
|
|
32
|
+
.mypy_cache/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2025-05-04
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Initial release of Kling CLI
|
|
9
|
+
- `kling generate` — Generate video from a text prompt (text2video)
|
|
10
|
+
- `kling image-to-video` — Generate video from reference image(s)
|
|
11
|
+
- `kling extend` — Extend an existing video
|
|
12
|
+
- `kling motion` — Generate motion video from image + reference video
|
|
13
|
+
- `kling task` — Query a single task status
|
|
14
|
+
- `kling tasks` — Query multiple tasks at once
|
|
15
|
+
- `kling wait` — Poll until a task completes
|
|
16
|
+
- `kling models` — List available Kling models
|
|
17
|
+
- `kling config` — Show current configuration
|
|
18
|
+
- `--json` flag on all commands for machine-readable output
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AceDataCloud
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: kling-pro-cli
|
|
3
|
+
Version: 2026.6.30.0
|
|
4
|
+
Summary: CLI tool for Kling AI Video Generation via AceDataCloud API
|
|
5
|
+
Project-URL: Homepage, https://github.com/AceDataCloud/KlingCli
|
|
6
|
+
Project-URL: Repository, https://github.com/AceDataCloud/KlingCli
|
|
7
|
+
Project-URL: Issues, https://github.com/AceDataCloud/KlingCli/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/AceDataCloud/KlingCli/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: AceDataCloud <support@acedata.cloud>
|
|
10
|
+
Maintainer-email: AceDataCloud <support@acedata.cloud>
|
|
11
|
+
License: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: acedata,ai,cli,command-line,generation,kling,video
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Multimedia :: Video
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: click>=8.1.0
|
|
27
|
+
Requires-Dist: httpx>=0.27.0
|
|
28
|
+
Requires-Dist: pydantic>=2.0.0
|
|
29
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
30
|
+
Requires-Dist: rich>=13.0.0
|
|
31
|
+
Provides-Extra: all
|
|
32
|
+
Requires-Dist: kling-cli[dev,release,test]; extra == 'all'
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: mypy>=1.10.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pre-commit>=3.7.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.4.0; extra == 'dev'
|
|
37
|
+
Provides-Extra: release
|
|
38
|
+
Requires-Dist: build>=1.2.0; extra == 'release'
|
|
39
|
+
Requires-Dist: twine>=6.1.0; extra == 'release'
|
|
40
|
+
Provides-Extra: test
|
|
41
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'test'
|
|
42
|
+
Requires-Dist: pytest-cov>=5.0.0; extra == 'test'
|
|
43
|
+
Requires-Dist: pytest>=8.0.0; extra == 'test'
|
|
44
|
+
Requires-Dist: respx>=0.21.0; extra == 'test'
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# Kling CLI
|
|
48
|
+
|
|
49
|
+
A command-line tool for Kling AI Video Generation via [AceDataCloud](https://platform.acedata.cloud).
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install kling-pro-cli
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Set your API token
|
|
61
|
+
export ACEDATACLOUD_API_TOKEN=your_token
|
|
62
|
+
|
|
63
|
+
# Generate a video from a text prompt
|
|
64
|
+
kling generate "A cinematic scene of a sunset over the ocean"
|
|
65
|
+
|
|
66
|
+
# Generate a video from a reference image
|
|
67
|
+
kling image-to-video "Animate this scene" --start-image-url https://example.com/photo.jpg
|
|
68
|
+
|
|
69
|
+
# Extend an existing video
|
|
70
|
+
kling extend --video-id abc123
|
|
71
|
+
|
|
72
|
+
# Generate a motion video from image + reference video
|
|
73
|
+
kling motion --image-url https://example.com/img.jpg --video-url https://example.com/ref.mp4
|
|
74
|
+
|
|
75
|
+
# Check task status
|
|
76
|
+
kling task abc123-def456
|
|
77
|
+
|
|
78
|
+
# Wait for a task to complete
|
|
79
|
+
kling wait abc123 --interval 5
|
|
80
|
+
|
|
81
|
+
# List available models
|
|
82
|
+
kling models
|
|
83
|
+
|
|
84
|
+
# Show configuration
|
|
85
|
+
kling config
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Options
|
|
89
|
+
|
|
90
|
+
- `--token` / `ACEDATACLOUD_API_TOKEN` — API token
|
|
91
|
+
- `--json` — Output raw JSON
|
|
92
|
+
|
|
93
|
+
## Models
|
|
94
|
+
|
|
95
|
+
| Model | Notes |
|
|
96
|
+
|-------|-------|
|
|
97
|
+
| kling-v1 | Default model |
|
|
98
|
+
| kling-v1-6 | Version 1.6 |
|
|
99
|
+
| kling-v2-5-turbo | Version 2.5 Turbo |
|
|
100
|
+
| kling-v2-6 | Version 2.6 |
|
|
101
|
+
| kling-v3 | Version 3 (supports 4K mode) |
|
|
102
|
+
| kling-v3-omni | Version 3 Omni (supports 4K mode) |
|
|
103
|
+
| kling-video-o1 | Video O1 |
|
|
104
|
+
| kling-v2-master | Version 2 Master |
|
|
105
|
+
| kling-v2-1-master | Version 2.1 Master |
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
MIT
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Kling CLI
|
|
2
|
+
|
|
3
|
+
A command-line tool for Kling AI Video Generation via [AceDataCloud](https://platform.acedata.cloud).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install kling-pro-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Set your API token
|
|
15
|
+
export ACEDATACLOUD_API_TOKEN=your_token
|
|
16
|
+
|
|
17
|
+
# Generate a video from a text prompt
|
|
18
|
+
kling generate "A cinematic scene of a sunset over the ocean"
|
|
19
|
+
|
|
20
|
+
# Generate a video from a reference image
|
|
21
|
+
kling image-to-video "Animate this scene" --start-image-url https://example.com/photo.jpg
|
|
22
|
+
|
|
23
|
+
# Extend an existing video
|
|
24
|
+
kling extend --video-id abc123
|
|
25
|
+
|
|
26
|
+
# Generate a motion video from image + reference video
|
|
27
|
+
kling motion --image-url https://example.com/img.jpg --video-url https://example.com/ref.mp4
|
|
28
|
+
|
|
29
|
+
# Check task status
|
|
30
|
+
kling task abc123-def456
|
|
31
|
+
|
|
32
|
+
# Wait for a task to complete
|
|
33
|
+
kling wait abc123 --interval 5
|
|
34
|
+
|
|
35
|
+
# List available models
|
|
36
|
+
kling models
|
|
37
|
+
|
|
38
|
+
# Show configuration
|
|
39
|
+
kling config
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Options
|
|
43
|
+
|
|
44
|
+
- `--token` / `ACEDATACLOUD_API_TOKEN` — API token
|
|
45
|
+
- `--json` — Output raw JSON
|
|
46
|
+
|
|
47
|
+
## Models
|
|
48
|
+
|
|
49
|
+
| Model | Notes |
|
|
50
|
+
|-------|-------|
|
|
51
|
+
| kling-v1 | Default model |
|
|
52
|
+
| kling-v1-6 | Version 1.6 |
|
|
53
|
+
| kling-v2-5-turbo | Version 2.5 Turbo |
|
|
54
|
+
| kling-v2-6 | Version 2.6 |
|
|
55
|
+
| kling-v3 | Version 3 (supports 4K mode) |
|
|
56
|
+
| kling-v3-omni | Version 3 Omni (supports 4K mode) |
|
|
57
|
+
| kling-video-o1 | Video O1 |
|
|
58
|
+
| kling-v2-master | Version 2 Master |
|
|
59
|
+
| kling-v2-1-master | Version 2.1 Master |
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Kling CLI - AI Kling Video Generation via AceDataCloud API."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Kling CLI commands package."""
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""Info and utility commands."""
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from kling_cli.core.config import settings
|
|
6
|
+
from kling_cli.core.output import ASPECT_RATIOS, console, print_models
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@click.command()
|
|
10
|
+
def models() -> None:
|
|
11
|
+
"""List available Kling models."""
|
|
12
|
+
print_models()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@click.command("aspect-ratios")
|
|
16
|
+
def aspect_ratios() -> None:
|
|
17
|
+
"""List available aspect ratios."""
|
|
18
|
+
from rich.table import Table
|
|
19
|
+
|
|
20
|
+
table = Table(title="Available Aspect Ratios")
|
|
21
|
+
table.add_column("Ratio", style="bold cyan")
|
|
22
|
+
table.add_column("Orientation")
|
|
23
|
+
|
|
24
|
+
for ratio in ASPECT_RATIOS:
|
|
25
|
+
w, h = ratio.split(":")
|
|
26
|
+
if int(w) > int(h):
|
|
27
|
+
orientation = "Landscape"
|
|
28
|
+
elif int(w) < int(h):
|
|
29
|
+
orientation = "Portrait"
|
|
30
|
+
else:
|
|
31
|
+
orientation = "Square"
|
|
32
|
+
table.add_row(ratio, orientation)
|
|
33
|
+
|
|
34
|
+
console.print(table)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@click.command()
|
|
38
|
+
def config() -> None:
|
|
39
|
+
"""Show current configuration."""
|
|
40
|
+
from rich.table import Table
|
|
41
|
+
|
|
42
|
+
table = Table(title="Kling CLI Configuration")
|
|
43
|
+
table.add_column("Setting", style="bold cyan")
|
|
44
|
+
table.add_column("Value")
|
|
45
|
+
|
|
46
|
+
table.add_row("API Base URL", settings.api_base_url)
|
|
47
|
+
table.add_row(
|
|
48
|
+
"API Token",
|
|
49
|
+
f"{settings.api_token[:8]}..." if settings.api_token else "[red]Not set[/red]",
|
|
50
|
+
)
|
|
51
|
+
table.add_row("Request Timeout", f"{settings.request_timeout}s")
|
|
52
|
+
|
|
53
|
+
console.print(table)
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"""Lip-sync and talking-photo generation commands."""
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from kling_cli.core.client import get_client
|
|
6
|
+
from kling_cli.core.exceptions import KlingError
|
|
7
|
+
from kling_cli.core.output import print_error, print_json, print_video_result
|
|
8
|
+
|
|
9
|
+
TALKING_PHOTO_MODELS = [
|
|
10
|
+
"kling-v1",
|
|
11
|
+
"kling-v1-6",
|
|
12
|
+
"kling-v2-master",
|
|
13
|
+
"kling-v2-1-master",
|
|
14
|
+
"kling-v2-5-turbo",
|
|
15
|
+
"kling-v2-6",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _validate_duration(
|
|
20
|
+
_ctx: click.Context, _param: click.Parameter, value: int | None
|
|
21
|
+
) -> int | None:
|
|
22
|
+
"""Validate talking-photo duration."""
|
|
23
|
+
if value is None or value in {5, 10}:
|
|
24
|
+
return value
|
|
25
|
+
raise click.BadParameter("Must be 5 or 10.")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@click.command("lip-sync")
|
|
29
|
+
@click.option("--video-id", default=None, help="Kling source video ID.")
|
|
30
|
+
@click.option("--video-url", default=None, help="Kling source video URL.")
|
|
31
|
+
@click.option(
|
|
32
|
+
"--mode",
|
|
33
|
+
required=True,
|
|
34
|
+
type=click.Choice(["audio2video", "text2video"]),
|
|
35
|
+
help="Lip-sync mode.",
|
|
36
|
+
)
|
|
37
|
+
@click.option("--audio-url", default=None, help="Audio URL for audio2video mode.")
|
|
38
|
+
@click.option(
|
|
39
|
+
"--audio-type",
|
|
40
|
+
type=click.Choice(["url", "file"]),
|
|
41
|
+
default=None,
|
|
42
|
+
help="Audio source type.",
|
|
43
|
+
)
|
|
44
|
+
@click.option("--audio-file", default=None, help="Path or content string for audio2video mode.")
|
|
45
|
+
@click.option("--text", default=None, help="Text for text2video mode.")
|
|
46
|
+
@click.option("--voice-id", default=None, help="Voice ID for text2video mode.")
|
|
47
|
+
@click.option(
|
|
48
|
+
"--voice-language",
|
|
49
|
+
type=click.Choice(["zh", "en"]),
|
|
50
|
+
default=None,
|
|
51
|
+
help="Voice language for text2video mode.",
|
|
52
|
+
)
|
|
53
|
+
@click.option(
|
|
54
|
+
"--voice-speed",
|
|
55
|
+
default=None,
|
|
56
|
+
type=float,
|
|
57
|
+
help="Voice speed multiplier for text2video mode (1.0 = normal).",
|
|
58
|
+
)
|
|
59
|
+
@click.option("--callback-url", default=None, help="Webhook callback URL.")
|
|
60
|
+
@click.option(
|
|
61
|
+
"--async",
|
|
62
|
+
"async_mode",
|
|
63
|
+
is_flag=True,
|
|
64
|
+
default=False,
|
|
65
|
+
help="Submit asynchronously; returns a task_id to poll instead of waiting.",
|
|
66
|
+
)
|
|
67
|
+
@click.option("--json", "output_json", is_flag=True, help="Output raw JSON.")
|
|
68
|
+
@click.pass_context
|
|
69
|
+
def lip_sync(
|
|
70
|
+
ctx: click.Context,
|
|
71
|
+
video_id: str | None,
|
|
72
|
+
video_url: str | None,
|
|
73
|
+
mode: str,
|
|
74
|
+
audio_url: str | None,
|
|
75
|
+
audio_type: str | None,
|
|
76
|
+
audio_file: str | None,
|
|
77
|
+
text: str | None,
|
|
78
|
+
voice_id: str | None,
|
|
79
|
+
voice_language: str | None,
|
|
80
|
+
voice_speed: float | None,
|
|
81
|
+
callback_url: str | None,
|
|
82
|
+
async_mode: bool,
|
|
83
|
+
output_json: bool,
|
|
84
|
+
) -> None:
|
|
85
|
+
"""Generate a lip-sync video."""
|
|
86
|
+
client = get_client(ctx.obj.get("token"))
|
|
87
|
+
try:
|
|
88
|
+
result = client.lip_sync(
|
|
89
|
+
video_id=video_id,
|
|
90
|
+
video_url=video_url,
|
|
91
|
+
mode=mode,
|
|
92
|
+
audio_url=audio_url,
|
|
93
|
+
audio_type=audio_type,
|
|
94
|
+
audio_file=audio_file,
|
|
95
|
+
text=text,
|
|
96
|
+
voice_id=voice_id,
|
|
97
|
+
voice_language=voice_language,
|
|
98
|
+
voice_speed=voice_speed,
|
|
99
|
+
callback_url=callback_url,
|
|
100
|
+
**({"async": True} if async_mode else {}),
|
|
101
|
+
)
|
|
102
|
+
if output_json:
|
|
103
|
+
print_json(result)
|
|
104
|
+
else:
|
|
105
|
+
print_video_result(result)
|
|
106
|
+
except KlingError as e:
|
|
107
|
+
print_error(e.message)
|
|
108
|
+
raise SystemExit(1) from e
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@click.command("talking-photo")
|
|
112
|
+
@click.option("--image-url", required=True, help="Source image URL.")
|
|
113
|
+
@click.option("--audio-url", required=True, help="Source audio URL.")
|
|
114
|
+
@click.option("--prompt", default=None, help="Prompt for talking photo generation.")
|
|
115
|
+
@click.option(
|
|
116
|
+
"-m",
|
|
117
|
+
"--model",
|
|
118
|
+
type=click.Choice(TALKING_PHOTO_MODELS),
|
|
119
|
+
default=None,
|
|
120
|
+
help="Model to use for generation.",
|
|
121
|
+
)
|
|
122
|
+
@click.option(
|
|
123
|
+
"--duration",
|
|
124
|
+
type=int,
|
|
125
|
+
callback=_validate_duration,
|
|
126
|
+
default=None,
|
|
127
|
+
help="Video duration in seconds.",
|
|
128
|
+
)
|
|
129
|
+
@click.option(
|
|
130
|
+
"--mode",
|
|
131
|
+
type=click.Choice(["std", "pro"]),
|
|
132
|
+
default=None,
|
|
133
|
+
help="Generation mode: std or pro.",
|
|
134
|
+
)
|
|
135
|
+
@click.option("--callback-url", default=None, help="Webhook callback URL.")
|
|
136
|
+
@click.option(
|
|
137
|
+
"--async",
|
|
138
|
+
"async_mode",
|
|
139
|
+
is_flag=True,
|
|
140
|
+
default=False,
|
|
141
|
+
help="Submit asynchronously; returns a task_id to poll instead of waiting.",
|
|
142
|
+
)
|
|
143
|
+
@click.option("--json", "output_json", is_flag=True, help="Output raw JSON.")
|
|
144
|
+
@click.pass_context
|
|
145
|
+
def talking_photo(
|
|
146
|
+
ctx: click.Context,
|
|
147
|
+
image_url: str,
|
|
148
|
+
audio_url: str,
|
|
149
|
+
prompt: str | None,
|
|
150
|
+
model: str | None,
|
|
151
|
+
duration: int | None,
|
|
152
|
+
mode: str | None,
|
|
153
|
+
callback_url: str | None,
|
|
154
|
+
async_mode: bool,
|
|
155
|
+
output_json: bool,
|
|
156
|
+
) -> None:
|
|
157
|
+
"""Generate a talking-photo video."""
|
|
158
|
+
client = get_client(ctx.obj.get("token"))
|
|
159
|
+
try:
|
|
160
|
+
result = client.talking_photo(
|
|
161
|
+
image_url=image_url,
|
|
162
|
+
audio_url=audio_url,
|
|
163
|
+
prompt=prompt,
|
|
164
|
+
model=model,
|
|
165
|
+
duration=duration,
|
|
166
|
+
mode=mode,
|
|
167
|
+
callback_url=callback_url,
|
|
168
|
+
**({"async": True} if async_mode else {}),
|
|
169
|
+
)
|
|
170
|
+
if output_json:
|
|
171
|
+
print_json(result)
|
|
172
|
+
else:
|
|
173
|
+
print_video_result(result)
|
|
174
|
+
except KlingError as e:
|
|
175
|
+
print_error(e.message)
|
|
176
|
+
raise SystemExit(1) from e
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""Motion generation command."""
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from kling_cli.core.client import get_client
|
|
6
|
+
from kling_cli.core.exceptions import KlingError
|
|
7
|
+
from kling_cli.core.output import (
|
|
8
|
+
DEFAULT_MODE,
|
|
9
|
+
KLING_MODES,
|
|
10
|
+
print_error,
|
|
11
|
+
print_json,
|
|
12
|
+
print_video_result,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@click.command()
|
|
17
|
+
@click.option(
|
|
18
|
+
"--image-url",
|
|
19
|
+
required=True,
|
|
20
|
+
help="Reference image URL. Characters, backgrounds and elements in the generated video "
|
|
21
|
+
"are based on this image.",
|
|
22
|
+
)
|
|
23
|
+
@click.option(
|
|
24
|
+
"--video-url",
|
|
25
|
+
required=True,
|
|
26
|
+
help="Reference video URL. Character movements in the generated video are consistent "
|
|
27
|
+
"with those in this reference video.",
|
|
28
|
+
)
|
|
29
|
+
@click.option(
|
|
30
|
+
"--character-orientation",
|
|
31
|
+
default=None,
|
|
32
|
+
type=click.Choice(["image", "video"]),
|
|
33
|
+
help="Orientation of characters in the generated video: consistent with the image or video.",
|
|
34
|
+
)
|
|
35
|
+
@click.option(
|
|
36
|
+
"--mode",
|
|
37
|
+
type=click.Choice(KLING_MODES),
|
|
38
|
+
default=DEFAULT_MODE,
|
|
39
|
+
help="Generation mode: std (High performance) or pro (High quality).",
|
|
40
|
+
)
|
|
41
|
+
@click.option(
|
|
42
|
+
"--keep-original-sound/--no-keep-original-sound",
|
|
43
|
+
default=True,
|
|
44
|
+
help="Whether to keep the original sound from the reference video (default: keep).",
|
|
45
|
+
)
|
|
46
|
+
@click.option("--prompt", default=None, help="Text prompt (positive and/or negative descriptions).")
|
|
47
|
+
@click.option("--callback-url", default=None, help="Webhook callback URL.")
|
|
48
|
+
@click.option(
|
|
49
|
+
"--async",
|
|
50
|
+
"async_mode",
|
|
51
|
+
is_flag=True,
|
|
52
|
+
default=False,
|
|
53
|
+
help="Submit asynchronously; returns a task_id to poll instead of waiting.",
|
|
54
|
+
)
|
|
55
|
+
@click.option(
|
|
56
|
+
"--timeout", default=None, type=int, help="Timeout in seconds for the API to return data."
|
|
57
|
+
)
|
|
58
|
+
@click.option("--json", "output_json", is_flag=True, help="Output raw JSON.")
|
|
59
|
+
@click.pass_context
|
|
60
|
+
def motion(
|
|
61
|
+
ctx: click.Context,
|
|
62
|
+
image_url: str,
|
|
63
|
+
video_url: str,
|
|
64
|
+
character_orientation: str | None,
|
|
65
|
+
mode: str,
|
|
66
|
+
keep_original_sound: bool,
|
|
67
|
+
prompt: str | None,
|
|
68
|
+
callback_url: str | None,
|
|
69
|
+
async_mode: bool,
|
|
70
|
+
timeout: int | None,
|
|
71
|
+
output_json: bool,
|
|
72
|
+
) -> None:
|
|
73
|
+
"""Generate a motion video from a reference image and reference video.
|
|
74
|
+
|
|
75
|
+
The generated video's characters and elements are based on the reference image,
|
|
76
|
+
while the movements are based on the reference video.
|
|
77
|
+
|
|
78
|
+
Examples:
|
|
79
|
+
|
|
80
|
+
kling motion --image-url https://example.com/img.jpg --video-url https://example.com/ref.mp4
|
|
81
|
+
|
|
82
|
+
kling motion --image-url img.jpg --video-url ref.mp4 --prompt "A dancer performing"
|
|
83
|
+
"""
|
|
84
|
+
client = get_client(ctx.obj.get("token"))
|
|
85
|
+
try:
|
|
86
|
+
result = client.generate_motion(
|
|
87
|
+
image_url=image_url,
|
|
88
|
+
video_url=video_url,
|
|
89
|
+
character_orientation=character_orientation,
|
|
90
|
+
mode=mode,
|
|
91
|
+
keep_original_sound="yes" if keep_original_sound else "no",
|
|
92
|
+
prompt=prompt,
|
|
93
|
+
callback_url=callback_url,
|
|
94
|
+
**({"async": True} if async_mode else {}),
|
|
95
|
+
timeout=timeout,
|
|
96
|
+
)
|
|
97
|
+
if output_json:
|
|
98
|
+
print_json(result)
|
|
99
|
+
else:
|
|
100
|
+
print_video_result(result)
|
|
101
|
+
except KlingError as e:
|
|
102
|
+
print_error(e.message)
|
|
103
|
+
raise SystemExit(1) from e
|