
Text to Image
Create AI images from text prompts
Create videos with Kling 4.0 API by Kuaishou using optional image, video, and audio references through Flaq AI's unified workflow for creators and developers.
// Step 1: Submit generation request
const response = await fetch('https://api.flaq.ai/api/v1/video/task', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
model_name: 'kling-v4.0-reference-to-video',
prompt: 'Animate the character from the reference image walking through a sunlit garden',
images: ['https://example.com/character-reference.jpg'],
resolution: '720p',
duration: 8,
aspect_ratio: '16:9'
})
});
const { data } = await response.json();
const taskId = data.task_id;
// Step 2: Poll for results
const taskId = data.task_id;
const pollResult = async (taskId) => {
const res = await fetch(`https://api.flaq.ai/api/v1/video/${taskId}`, {
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});
return res.json();
};
while (true) {
const pollResultData = await pollResult(taskId);
const status = pollResultData.data.task_status;
if (status === 'succeed') {
console.log(pollResultData.data.task_result.videos[0].url);
break;
}
if (status === 'failed') {
console.error(pollResultData.data.task_status_msg);
break;
}
await new Promise(resolve => setTimeout(resolve, 10000));
}
# Step 1: Submit generation request
import requests
response = requests.post(
'https://api.flaq.ai/api/v1/video/task',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
json={
'model_name': 'kling-v4.0-reference-to-video',
'prompt': 'Animate the character from the reference image walking through a sunlit garden',
'images': ['https://example.com/character-reference.jpg'],
'resolution': '720p',
'duration': 8,
'aspect_ratio': '16:9'
}
)
result = response.json()
task_id = result['data']['task_id']
# Step 2: Poll for results
task_id = response.json()['data']['task_id']
poll_url = f"https://api.flaq.ai/api/v1/video/{task_id}"
while True:
poll_result = requests.get(poll_url, headers={'Authorization': 'Bearer YOUR_API_KEY'}).json()
status = poll_result['data']['task_status']
if status == 'succeed':
print(poll_result['data']['task_result']['videos'][0]['url'])
break
if status == 'failed':
print(poll_result['data']['task_status_msg'])
break
time.sleep(10)
# Step 1: Submit generation request
curl -X POST https://api.flaq.ai/api/v1/video/task \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model_name": "kling-v4.0-reference-to-video",
"prompt": "Animate the character from the reference image walking through a sunlit garden",
"images": ["https://example.com/character-reference.jpg"],
"resolution": "720p",
"duration": 8,
"aspect_ratio": "16:9"
}'
# Step 2: Poll for results
# Replace {task_id} with the task_id returned from the submit response
curl -X GET "https://api.flaq.ai/api/v1/video/{task_id}" \
-H "Authorization: Bearer YOUR_API_KEY"
| Parameters | Price | Original Price | Discount |
|---|
Kuaishou Kling 4.0 Reference-to-Video API brings multimodal video generation to developers and creative teams on Flaq AI. Combine written direction with optional image, video, and audio references to create content from existing creative assets. Flexible media inputs, output settings, and reference-video sound control support brand campaigns, product videos, and automated creative workflows through one Kling API integration.
Multimodal Reference Inputs: Guide a generation with multiple images, video clips, and audio references alongside a written description of the intended result.
Independent Media Choices: Use image-only, video-only, or audio-only references, combine media types, or submit a prompt without any reference material.
Reference Video Sound Control: Choose whether to preserve the original sound from reference videos as part of the generation request.
Prompt-Based Creative Direction: Combine a written brief with reference assets to guide the scene, subject, action, and visual style of a new video.
Selectable Output Resolution: Choose 720p or 1080p output according to the needs of previews, campaign assets, and publishing workflows.
Flexible Duration and Aspect Ratios: Adjust the generated clip length and choose from multiple supported formats for different creative briefs and placements.
Flexible API Integration: Support different combinations of creative assets through one integration for campaign tools, content platforms, and automated video production.
Input: A required text prompt with optional image, video, and audio URL collections. Each media type may be used on its own or omitted.
Output: A generated video guided by the prompt, supplied reference media, and selected output settings.
Reference Timing: Combined reference video duration must stay within 30 seconds, independently of the output length. Each reference audio clip must be from 5 to 30 seconds.
Sound Control: Explicitly enable original-sound retention when reference video audio should be kept in the result.
Resolution and Aspect Ratios: Select a supported resolution for each request and choose a suitable output format from the available aspect ratios.
Duration: Explicitly specify a generated video length from 3 to 30 seconds; this does not count toward the reference video duration allowance.
Billing: With reference video input, billing considers input and output video duration at the selected resolution. Reference images, audio, and the original-sound option add no separate charge to that video-input request. Without reference videos, billing follows Kling 4.0 Text-to-Video regardless of image or audio inputs.
Capabilities: Multimodal reference guidance, independent media inputs, prompt-based creative direction, reference-video sound retention, and flexible output settings.
Reference-Guided Brand Content: Combine campaign images, footage, and audio with written direction to create promotional videos and brand content for advertising and social media.
E-commerce Product Videos: Use product images and demonstration clips as references for product stories, promotional sequences, and lifestyle video content.
Audio-Guided Video Creation: Pair audio references with descriptions of the intended visuals for music-related content, campaign videos, and creative storytelling.
Creative Production & Iteration: Turn written briefs and reference assets into video variations for different campaign directions, product stories, and publishing placements.
Flexible Production Pipelines: Support projects with different asset combinations through one integration, including requests that have no reference material.
Note Please ensure prompts and reference media comply with Kuaishou and Flaq AI content safety requirements, and use media you have the right to use. Input billing rules do not replace reference-media upload limits.
Kling 4.0 vs. Veo 3.1 Reference Images
Veo 3.1 supports image references for video generation. Kling 4.0
Reference-to-Video accepts optional image, video, and audio collections, including requests that use only audio
references.
Kling 4.0 vs. Runway Gen-4.5
Runway Gen-4.5 supports text-based and image-based generation.
Kling 4.0 Reference-to-Video exposes optional media collections for teams whose creative briefs include image, video,
or audio references.
Kling 4.0 Reference-to-Video vs. Kling 4.0 Image-to-Video
Image-to-Video requires a starting image and can use ending and intermediate frames. Reference-to-Video accepts
optional media references without requiring an opening image to define the sequence.
Kling 4.0 Reference-to-Video vs. Kling 4.0 Video Edit
Video Edit requires footage to edit. Reference-to-Video creates a video guided by the available reference material,
with each reference type optional and the output duration set separately.
Kling 4.0 Reference-to-Video vs. Kling 4.0 Text-to-Video
Text-to-Video is a prompt-only workflow. Reference-to-Video adds optional media guidance; when reference videos are
absent, it uses the same billing basis as Text-to-Video even if images or audio are supplied.
Explore several AI creation tools for quick image and video workflows in your browser, then scale successful ideas with Flaq AI's production-ready model APIs. Flaq AI provides a unified API layer for all models, making it easy to use and scale your workflows.

Create AI images from text prompts

Create AI images from images and text prompts

Create AI videos from text prompts

Animate images into AI videos

Create AI images and videos in one unified workspace

Create consistent videos from reference media

Build visual AI image and video workflows on an infinite canvas