Text to Video
Generate a 720p video with sound from a prompt alone (Kling 4.0 Flash text_to_video).
Kling 4.0 Flash generates a video from a prompt alone, with no images or video.
Create a task
https://api.nanoapi.ai/v1/tasksUse the shared create endpoint with model: "kling-4.0-flash" and mode: "text_to_video".
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer <API key>, see Authentication. |
Content-Type | Yes | application/json |
Idempotency-Key | No | A unique string for every new task, ideally a UUID (1–255 characters). See Preventing duplicate tasks. |
Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | kling-4.0-flash |
mode | string | Yes | text_to_video |
prompt | string | Yes | What to generate, at most 8000 characters. |
aspect_ratio | string | Yes | auto, 21:9, 16:9, 9:16 or 1:1. auto gives 16:9. |
resolution | string | Yes | 720p. |
duration | integer | Yes | Output length in seconds, 3–20. Billed per second, see Pricing. |
webhook_url | string | No | Notified when the task succeeds or fails: https, up to 2048 characters, not a private, loopback or reserved address. See Webhooks. |
A 5-second 16:9 clip:
curl https://api.nanoapi.ai/v1/tasks \
-H "Authorization: Bearer $NANOAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-4.0-flash",
"mode": "text_to_video",
"prompt": "A red fox trotting through a snowy pine forest at dawn",
"aspect_ratio": "16:9",
"resolution": "720p",
"duration": 5
}'Response: 200 OK, the new task (fields). Keep data.id to get the result; the task can still fail, see Errors.
{
"code": 200,
"message": "success",
"data": {
"object": "task",
"id": "tk_01jbm3r8x5c2v9b6n4q7w1e3t5",
"model": "kling-4.0-flash",
"status": "queued",
"error": null,
"created_at": "2026-11-18T08:30:00Z"
}
}Pricing
cost = duration × price per secondLoading the current prices…
Billed seconds are the duration you ask for. All Kling 4.0 Flash prices: Kling 4.0 Flash → Pricing. Current prices: GET /v1/products (product kling_flash, the prices row whose mode is text_to_video). The task's billing.frozen is the amount that counts; freezing and charging: Billing.
Errors
See Kling 4.0 Flash → Errors. This mode's parameter rules are in the table above.