Skip to content

Text to Video

Create a Kling-compatible text-to-video task.

Create Task

Request

http
POST /v1/videos/text2video
FieldTypeRequiredSupported values and limitsDescription
model_namestringYeskling-v2-5-turbo, kling-v3Model name. kling-v2-5-turbo is suited for basic text-to-video, while kling-v3 supports longer durations and multi-shot generation.
promptstringNoUp to 2500 charsRequired for kling-v2-5-turbo. Under kling-v3, it is required when multi_shot=false and is used to describe subject, action, scene, camera language, and style; when multi_shot=true, this field is ignored.
multi_shotbooleanNoOnly kling-v3; true, falseEnables multi-shot generation. Default is false. When multi_shot=true, prompt is ignored; when multi_shot=false, shot_type and multi_prompt are ignored. kling-v2-5-turbo does not support this field.
shot_typestringNoOnly kling-v3; only customize is supportedRequired when multi_shot=true; ignored when multi_shot=false. Only custom storyboards are supported. intelligence is not supported.
multi_promptarrayNoOnly kling-v3; 1 to 6 itemsRequired when multi_shot=true and shot_type=customize; ignored when multi_shot=false. Used to define prompt and duration for each shot.
multi_prompt[].indexintegerYesOnly kling-v3Shot index. Using 1,2,3... in order is recommended.
multi_prompt[].promptstringYesOnly kling-v3; up to 512 charsPrompt for the current shot, including subject, action, scene, camera setup, or style.
multi_prompt[].durationstringYesOnly kling-v3; at least 1 secondDuration of the current shot. The sum of all shot durations must equal the total duration.
negative_promptstringNoUp to 2500 charsNegative prompt used to restrict unwanted content, style, or artifacts.
soundstringNoOnly kling-v3; on, offWhether to generate audio together with the video. Default is off. kling-v2-5-turbo does not support this field.
modestringNostd, proGeneration mode. std is the standard, more cost-effective mode. pro is the higher-quality mode. 4k is not supported.
aspect_ratiostringNo16:9, 9:16, 1:1Output frame aspect ratio. Default is 16:9.
durationstringNokling-v2-5-turbo: 5, 10; kling-v3: 3 to 15Total video duration in seconds. In multi-shot mode, the sum of all multi_prompt[].duration values must equal this value.
watermark_infoobjectNo{"enabled": boolean}Whether to return a watermarked result in parallel.
external_task_idstringNoCustom stringCustom task ID for later query use. It must be unique within the same account.

Response

json
{
  "code": 0,
  "message": "success",
  "request_id": "req_abc123",
  "data": {
    "task_id": "sg_vid_xxxxxxxx",
    "task_status": "submitted",
    "created_at": 1776209922,
    "updated_at": 1776209922
  }
}

Example

Basic Example

bash
curl -sS "https://api.exchangetoken.ai/v1/videos/text2video" \
  -H "Authorization: Bearer sk-xxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model_name": "kling-v3",
    "prompt": "A cinematic shot of a red tram crossing a rainy city street at night, reflections on the road",
    "negative_prompt": "blur, low quality",
    "mode": "pro",
    "sound": "off",
    "aspect_ratio": "16:9",
    "duration": "5",
    "watermark_info": {"enabled": false}
  }'

Multi-shot Example

bash
curl -sS "https://api.exchangetoken.ai/v1/videos/text2video" \
  -H "Authorization: Bearer sk-xxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model_name": "kling-v3",
    "multi_shot": true,
    "shot_type": "customize",
    "multi_prompt": [
      {"index": 1, "prompt": "A quiet cafe at sunrise, warm light through the window", "duration": "2"},
      {"index": 2, "prompt": "A close-up of coffee steam rising from a white cup", "duration": "3"}
    ],
    "mode": "pro",
    "sound": "on",
    "aspect_ratio": "16:9",
    "duration": "5"
  }'

Query Task

Request

http
GET /v1/videos/text2video/{task_id}

Use data.task_id for polling.

Response

json
{
  "code": 0,
  "message": "success",
  "request_id": "req_abc123",
  "data": {
    "task_id": "sg_vid_xxxxxxxx",
    "task_status": "succeed",
    "watermark_info": {
      "enabled": false
    },
    "task_result": {
      "videos": [
        {
          "url": "https://example.com/output.mp4"
        }
      ]
    },
    "created_at": 1776209922,
    "updated_at": 1776210072
  }
}

Status Values

task_statusMeaning
submittedTask accepted but not yet running.
processingTask is queued or running.
succeedTask completed and task_result.videos may be present.
failedTask failed or was cancelled. Check task_status_msg when present.

Example

bash
curl -sS "https://api.exchangetoken.ai/v1/videos/text2video/sg_vid_xxxxxxxx" \
  -H "Authorization: Bearer sk-xxxxxx"