Mogu IO/Models/

Kling 4.0 Image to Video

Video

Model Information

Model IDkwaivgi/kling-v4.0/image-to-video
CategoryVideo
Endpoint/api/v1/videos
Input Modalitiestext, image
Output Modalitiesvideo, audio

Create Task

POST https://mogu.io/api/v1/videos

Authentication: Authorization: Bearer <api-key>

Request Parameters

ParameterTypeRequiredDefaultDescription
modelstring✓Model ID: kwaivgi/kling-v4.0/image-to-video
imageurl✓First-frame image URL
promptstringDescribe the scene, action, camera movement or requested edit
timeoutnumber (60..3600)1800Maximum wait time in seconds
durationnumber (3..30)5Duration in whole seconds (3-30)
keyframesarray<url>Ordered middle keyframe URLs; first, last and middle frames total at most 10
last_imageurlOptional last-frame image URL
resolutionenum: 720p | 1080p"720p"Output resolution
aspect_ratioenum: | 16:9 | 9:16 | 1:1 | 21:9""Leave blank to follow the first image

Multimodal Input

This model supports image input. Use the content array format:

{
  "role": "user",
  "content": [
    {
      "type": "text",
      "text": "Describe this"
    },
    {
      "type": "image_url",
      "image_url": {
        "url": "https://example.com/photo.jpg"
      }
    }
  ]
}

Multimodal Output

This model can output video, audio. Add modalities to your request:

{
  "model": "kwaivgi/kling-v4.0/image-to-video",
  "messages": [
    {
      "role": "user",
      "content": "Draw a cat"
    }
  ],
  "modalities": [
    "video",
    "audio"
  ]
}

Image output does not support streaming. Set stream: false.

Code Examples

# Step 1: Create task
curl -X POST https://mogu.io/api/v1/videos \
  -H "Authorization: Bearer <api-key>" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "kwaivgi/kling-v4.0/image-to-video",
  "image": "https://example.com/image.jpg",
  "timeout": 1800,
  "duration": 5,
  "resolution": "720p",
  "aspect_ratio": ""
}'

# Step 2: Poll for result
curl https://mogu.io/api/v1/videos/{task-id} \
  -H "Authorization: Bearer <api-key>"

Response

Create Response (202)

{
  "id": "task-uuid",
  "status": "pending",
  "polling_url": "/api/v1/videos/task-uuid"
}

Poll: GET https://mogu.io/api/v1/videos/:id — Completed

{
  "id": "task-uuid",
  "status": "completed",
  "output": {
    "urls": [
      "https://cdn.example.com/video.mp4"
    ]
  },
  "credit": 4000
}

Poll every 3-5 seconds. Status values: pending → in_progress → completed | failed

Error Codes

HTTPTypeDescription
400invalid_request_errorInvalid parameters
400content_moderationContent blocked by safety system
400input_too_largeInput exceeds model limit
401auth_errorInvalid API key
402insufficient_creditsNot enough credits
429rate_limit_errorToo many requests
502provider_errorUpstream error, retry later
504timeout_errorRequest timed out
Try in PlaygroundAPI ReferenceAll Models