Skip to content

Commit 1cb7e22

Browse files
authored
[API Nodes] add Kling O1 model support (#11025)
* feat(api-nodes): add Kling O1 model support * fix: increase max allowed duration to 10.05 seconds * fix(VideoInput): respect "format" argument
1 parent 2640acb commit 1cb7e22

File tree

4 files changed

+499
-19
lines changed

4 files changed

+499
-19
lines changed

comfy_api/latest/_input_impl/video_types.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,10 @@ def save_to(
336336
raise ValueError("Only MP4 format is supported for now")
337337
if codec != VideoCodec.AUTO and codec != VideoCodec.H264:
338338
raise ValueError("Only H264 codec is supported for now")
339-
with av.open(path, mode='w', options={'movflags': 'use_metadata_tags'}) as output:
339+
extra_kwargs = {}
340+
if format != VideoContainer.AUTO:
341+
extra_kwargs["format"] = format.value
342+
with av.open(path, mode='w', options={'movflags': 'use_metadata_tags'}, **extra_kwargs) as output:
340343
# Add metadata before writing any streams
341344
if metadata is not None:
342345
for key, value in metadata.items():

comfy_api_nodes/apis/kling_api.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from pydantic import BaseModel, Field
2+
3+
4+
class OmniProText2VideoRequest(BaseModel):
5+
model_name: str = Field(..., description="kling-video-o1")
6+
aspect_ratio: str = Field(..., description="'16:9', '9:16' or '1:1'")
7+
duration: str = Field(..., description="'5' or '10'")
8+
prompt: str = Field(...)
9+
mode: str = Field("pro")
10+
11+
12+
class OmniParamImage(BaseModel):
13+
image_url: str = Field(...)
14+
type: str | None = Field(None, description="Can be 'first_frame' or 'end_frame'")
15+
16+
17+
class OmniParamVideo(BaseModel):
18+
video_url: str = Field(...)
19+
refer_type: str | None = Field(..., description="Can be 'base' or 'feature'")
20+
keep_original_sound: str = Field(..., description="'yes' or 'no'")
21+
22+
23+
class OmniProFirstLastFrameRequest(BaseModel):
24+
model_name: str = Field(..., description="kling-video-o1")
25+
image_list: list[OmniParamImage] = Field(..., min_length=1, max_length=7)
26+
duration: str = Field(..., description="'5' or '10'")
27+
prompt: str = Field(...)
28+
mode: str = Field("pro")
29+
30+
31+
class OmniProReferences2VideoRequest(BaseModel):
32+
model_name: str = Field(..., description="kling-video-o1")
33+
aspect_ratio: str | None = Field(..., description="'16:9', '9:16' or '1:1'")
34+
image_list: list[OmniParamImage] | None = Field(
35+
None, max_length=7, description="Max length 4 when video is present."
36+
)
37+
video_list: list[OmniParamVideo] | None = Field(None, max_length=1)
38+
duration: str | None = Field(..., description="From 3 to 10.")
39+
prompt: str = Field(...)
40+
mode: str = Field("pro")
41+
42+
43+
class TaskStatusVideoResult(BaseModel):
44+
duration: str | None = Field(None, description="Total video duration")
45+
id: str | None = Field(None, description="Generated video ID")
46+
url: str | None = Field(None, description="URL for generated video")
47+
48+
49+
class TaskStatusVideoResults(BaseModel):
50+
videos: list[TaskStatusVideoResult] | None = Field(None)
51+
52+
53+
class TaskStatusVideoResponseData(BaseModel):
54+
created_at: int | None = Field(None, description="Task creation time")
55+
updated_at: int | None = Field(None, description="Task update time")
56+
task_status: str | None = None
57+
task_status_msg: str | None = Field(None, description="Additional failure reason. Only for polling endpoint.")
58+
task_id: str | None = Field(None, description="Task ID")
59+
task_result: TaskStatusVideoResults | None = Field(None)
60+
61+
62+
class TaskStatusVideoResponse(BaseModel):
63+
code: int | None = Field(None, description="Error code")
64+
message: str | None = Field(None, description="Error message")
65+
request_id: str | None = Field(None, description="Request ID")
66+
data: TaskStatusVideoResponseData | None = Field(None)

0 commit comments

Comments
 (0)