> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maxapi.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Kling 4.0

> Kling 4.0: model IDs, supported parameters, prices and request examples

Use the authenticated gateway at `https://maxapi.io`. [Authentication](https://docs.maxapi.io/api-reference/authentication.md) · [Shared request fields](https://docs.maxapi.io/api-reference/submit-task.md).

## Model IDs and parameter coverage

| Model ID | Accepted input fields |
| - | - |
| `kling-4.0` | `prompt`, `duration`, `resolution`, `ratio`, `mode`, `imageUrls` |

Send `model` and `input` in the JSON body. `input.prompt` is required. Image-to-image and image-to-video IDs require reference images. Use only the input fields listed for your selected ID; a family-wide table does not mean every variant accepts every field.

## Parameters

| Field | Type | Values / limits | Description |
| - | - | - | - |
| `model` | string | kling-4.0 | The model to run. |
| `input.prompt` | string | text | Required scene and motion instructions. |
| `input.duration` | integer | 3–30 | Output seconds. Defaults to 5. |
| `input.resolution` | string | 720p \| 1080p | Output resolution. Defaults to 720p. |
| `input.ratio` | string | 16:9 \| 9:16 \| 1:1 \| 21:9 | Output aspect ratio. |
| `input.mode` | string | text-to-video \| image-to-video \| reference-to-video \| first-last-frame | Optional. Inferred from image count when omitted: zero = text, one = first frame, multiple = references. |
| `input.imageUrls` | string\[] | 0–10 HTTP(S) URLs | One image for image-to-video; two for first-last-frame; up to ten for references. |
| `callBackUrl` | string | URL | Optional webhook called when the task finishes. |

Use public HTTP(S) media URLs that the generation service can fetch. Replace all example media URLs with your own files. Mode-specific requirements and provider limits below still apply after local validation.

## Supported scope and limits

* Output duration: 3–30 whole seconds. Default: 5 seconds.
* Only publicly accessible HTTP(S) image URLs are accepted.
* Video input, video editing, extension and audio input are not enabled.

## Pricing

The rate depends on the selected resolution and the requested output duration.

| Model ID | Setting | Unit price (USD) | With reference video |
| - | - | - | - |
| `kling-4.0` | 720p | \$0.155/s | — |
| `kling-4.0` | 1080p | \$0.233/s | — |

Prices are standard public rates in USD. Multiply per-second rates by the billed duration, per-image rates by the requested image count, and per-video rates by one generation. Reference-video rates replace the ordinary output rate where shown.

The final task total is rounded up to whole credits: `credits = ceil(total_USD × 100)`; one credit is \$0.01. Round once after adding all billable components. The following examples show the rounded debit.

| Example | Charged amount |
| - | - |
| 5 seconds at 1080p | \$1.17 |
| 5 seconds at 720p | \$0.78 |

## Submit and query

```bash theme={null}
curl https://maxapi.io/api/v1/task/submit \
  -H "Authorization: Bearer $MAXAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-4.0",
    "input": {
      "prompt": "A paper boat floats across a quiet pond at sunrise, slow camera movement, soft birdsong.",
      "resolution": "720p",
      "duration": 5,
      "ratio": "16:9"
    }
  }'

# -> { "code": 0, "data": { "taskId": "..." } }
curl https://maxapi.io/api/v1/task/$TASK_ID \
  -H "Authorization: Bearer $MAXAPI_API_KEY"
```

A successful submission returns `data.taskId`; it does not mean generation has completed. Poll [Query Task](https://docs.maxapi.io/api-reference/query-task.md) or use a [Webhook](https://docs.maxapi.io/api-reference/webhook.md). Stop polling on `SUCCESS`, `FAILURE`, `TIMEOUT` or `CANCELLED`. A pending or uncertain submission must not be blindly resubmitted.

## Minimal request bodies by model ID

### kling-4.0

```json theme={null}
{
  "model": "kling-4.0",
  "input": {
    "prompt": "A mountain lake at sunrise"
  }
}
```

## Billing and model notes

### How much does the Kling 4.0 API cost?

From $0.155/s. For example: 5 seconds at 1080p costs $1.17. See the pricing table above for every variant and resolution.

### What durations and resolutions does Kling 4.0 support?

Durations: 3–30s. Resolutions: 720p, 1080p.

### How is the final credit charge calculated?

Unit prices are shown in US dollars. The total task price is rounded up to whole credits; one credit is \$0.01. The Playground and cost examples show this rounded debit. Small tasks may therefore cost more than the unrounded unit-price calculation.

### Which generation modes are supported?

Text-to-video, image-to-video, image references, and first/last frames. Video input is not supported by this integration.

### Am I charged if a task fails?

Confirmed failures, including content moderation rejections, are refunded in full. For a pending submission or a request timeout, check the task status before retrying.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.