fix: correct per-model video API field names and remove non-existent models
Each video model uses a different image input field: - kling-o1-pro/std: first_frame (not image) - kling-elements-pro/std: images (array) - minimax-hailuo: image, duration fixed at "6" Also: - kling-elements requires slug aspect ratios (square_1_1, etc.) - Remove wan-2.5 and runway-gen4 which return 404 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,10 +8,13 @@ from freepik_cli.api.client import FreepikClient
|
||||
from freepik_cli.api.models import (
|
||||
VIDEO_POST_ENDPOINTS,
|
||||
VIDEO_STATUS_ENDPOINTS,
|
||||
VIDEO_IMAGE_FIELDS,
|
||||
VIDEO_SLUG_ASPECT_RATIO_MODELS,
|
||||
VideoModel,
|
||||
get_output_urls,
|
||||
get_status,
|
||||
get_task_id,
|
||||
normalize_aspect_ratio_video,
|
||||
)
|
||||
|
||||
|
||||
@@ -29,15 +32,26 @@ class VideoAPI:
|
||||
seed: Optional[int] = None,
|
||||
) -> str:
|
||||
"""Submit an image-to-video task. Returns task_id."""
|
||||
payload: dict[str, Any] = {
|
||||
"image": image_b64,
|
||||
}
|
||||
image_field = VIDEO_IMAGE_FIELDS[model]
|
||||
|
||||
# kling-elements uses an array; all others use a scalar
|
||||
if image_field == "images":
|
||||
payload: dict[str, Any] = {"images": [image_b64]}
|
||||
else:
|
||||
payload = {image_field: image_b64}
|
||||
|
||||
if prompt:
|
||||
payload["prompt"] = prompt
|
||||
if duration:
|
||||
payload["duration"] = str(duration)
|
||||
|
||||
# minimax only supports duration=6; clamp silently
|
||||
effective_duration = duration
|
||||
if model == VideoModel.MINIMAX_HAILUO:
|
||||
effective_duration = 6
|
||||
payload["duration"] = str(effective_duration)
|
||||
|
||||
if aspect_ratio:
|
||||
payload["aspect_ratio"] = aspect_ratio
|
||||
payload["aspect_ratio"] = normalize_aspect_ratio_video(aspect_ratio, model)
|
||||
|
||||
if seed is not None:
|
||||
payload["seed"] = seed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user