# Kling Image 4.0 Long Image

Submit a JSON request to `POST /v1/images/generations` with the model ID `kling-image-4-0-long-image`. Save the returned task ID, then poll `GET /v1/tasks/{id}` until the single tall PNG finishes.

## Quick example

This request creates a 1K webpage layout from a text brief. Store your API key in `SEEDROUTER_API_KEY`.

```bash
curl https://api.seedrouter.ai/v1/images/generations \
  -H "Authorization: Bearer $SEEDROUTER_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "kling-image-4-0-long-image",
    "contents": [
      {"type": "prompt", "text": "Design a tall landing page for a specialty coffee roastery with a hero banner, three single-origin bean cards, roasting notes, and store hours."}
    ],
    "settings": {"skill": "webpage", "resolution": "1k"}
  }'
```

```python
import os
import requests

response = requests.post(
    "https://api.seedrouter.ai/v1/images/generations",
    headers={"Authorization": "Bearer " + os.environ["SEEDROUTER_API_KEY"]},
    json={
        "model": "kling-image-4-0-long-image",
        "contents": [
            {
                "type": "prompt",
                "text": "Design a tall landing page for a specialty coffee roastery with a hero banner, three single-origin bean cards, roasting notes, and store hours.",
            }
        ],
        "settings": {"skill": "webpage", "resolution": "1k"},
    },
    timeout=60,
)
response.raise_for_status()
print(response.json()["id"])
```

```javascript
const response = await fetch("https://api.seedrouter.ai/v1/images/generations", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SEEDROUTER_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "kling-image-4-0-long-image",
    contents: [
      {
        type: "prompt",
        text: "Design a tall landing page for a specialty coffee roastery with a hero banner, three single-origin bean cards, roasting notes, and store hours.",
      },
    ],
    settings: { skill: "webpage", resolution: "1k" },
  }),
});
if (!response.ok) throw new Error(await response.text());
console.log((await response.json()).id);
```

```go
package main

import (
    "fmt"
    "io"
    "net/http"
    "os"
    "strings"
    "time"
)

func main() {
    body := `{"model":"kling-image-4-0-long-image","contents":[{"type":"prompt","text":"Design a tall landing page for a specialty coffee roastery with a hero banner, three single-origin bean cards, roasting notes, and store hours."}],"settings":{"skill":"webpage","resolution":"1k"}}`
    req, err := http.NewRequest("POST", "https://api.seedrouter.ai/v1/images/generations", strings.NewReader(body))
    if err != nil { panic(err) }
    req.Header.Set("Authorization", "Bearer "+os.Getenv("SEEDROUTER_API_KEY"))
    req.Header.Set("Content-Type", "application/json")
    client := &http.Client{Timeout: 60 * time.Second}
    resp, err := client.Do(req)
    if err != nil { panic(err) }
    defer resp.Body.Close()
    result, err := io.ReadAll(resp.Body)
    if err != nil { panic(err) }
    if resp.StatusCode != http.StatusOK { panic(string(result)) }
    fmt.Println(string(result))
}
```

## Endpoint and headers

Send JSON to `POST https://api.seedrouter.ai/v1/images/generations` with `Content-Type: application/json` and `Authorization: Bearer YOUR_API_KEY`. Keep the key on your server.

## Parameters

| Field                            | Type             | Values and defaults                                                                                                                                                                    |
| -------------------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model`                          | string, required | `kling-image-4-0-long-image`                                                                                                                                                           |
| `contents`                       | array, required  | One `prompt` item plus mode-specific reference image items.                                                                                                                            |
| `contents[].type`                | string, required | `prompt`, `refer_image` (ecommerce only, 1–3 required), `style_refer_image` (webpage only, at most 1), or `subject_refer_image` (webpage only, at most 1). `element` is not supported. |
| `contents[].text`                | string           | Required for `prompt`. English-only limit 166,000 characters, non-English limit 71,000. Mixed text must satisfy `english / 166000 + non_english / 71000 <= 1`.                         |
| `contents[].url`                 | string           | Required for each image item. Public HTTP(S) URL for a JPEG or PNG up to 30 MB, at least 300 px per side, aspect ratio from 2:5 to 5:2.                                                |
| `contents[].id`                  | string           | Optional unique reference ID across all image items in the request. Mention it as `@id` in the prompt.                                                                                 |
| `settings.skill`                 | string, required | `ecommerce` for product detail pages or `webpage` for webpage designs.                                                                                                                 |
| `settings.length`                | string           | `short` (\~2–5 sections), `medium` (default, \~6–10 sections), or `long` (\~11–18 sections). Applies to `ecommerce` only; ignored for `webpage`.                                       |
| `settings.resolution`            | string           | `1k` (default, 1024 px wide) or `2k` (2048 px wide). Height adapts to content. `4k` is not supported.                                                                                  |
| `options.watermark_info.enabled` | boolean          | Optional. Only `false` is supported.                                                                                                                                                   |

## Ecommerce product detail page

Ecommerce mode requires 1 to 3 `refer_image` entries. Reference each photo by its `id` in the prompt.

```json
{
  "model": "kling-image-4-0-long-image",
  "contents": [
    {"type": "refer_image", "url": "https://example.com/kettle-front.png", "id": "front"},
    {"type": "refer_image", "url": "https://example.com/kettle-spout.jpg", "id": "spout"},
    {"type": "prompt", "text": "Build an ecommerce product detail page for the gooseneck kettle in @front with a close-up section highlighting @spout. Include hero visual, temperature control callouts, brewing scenes, and care notes."}
  ],
  "settings": {"skill": "ecommerce", "length": "medium", "resolution": "2k"}
}
```

## Webpage design with style and subject references

Webpage mode accepts optional `style_refer_image` (at most 1) and `subject_refer_image` (at most 1) entries. Omit `settings.length` in webpage mode.

```json
{
  "model": "kling-image-4-0-long-image",
  "contents": [
    {"type": "style_refer_image", "url": "https://example.com/editorial-grid.png", "id": "layout"},
    {"type": "subject_refer_image", "url": "https://example.com/watch.jpg", "id": "watch"},
    {"type": "prompt", "text": "Design a watch launch webpage matching the typography and grid rhythm of @layout while showcasing @watch across the hero, movement breakdown, and spec table."}
  ],
  "settings": {"skill": "webpage", "resolution": "2k"}
}
```

## Retrieve the long image

Copy `id` from the POST response into `TASK_ID` and poll until status is `completed` or `failed`. Long-image tasks typically take several minutes, especially for `long` + `2k` layouts.

```bash
curl "https://api.seedrouter.ai/v1/tasks/$TASK_ID" \
  -H "Authorization: Bearer $SEEDROUTER_API_KEY"
```

On completion, read `output.data[0].url`. Each request produces one complete tall PNG. At `2k`, tall pages can exceed 50 MB, so plan download timeouts and viewer scaling accordingly. See the [task reference](https://seedrouter.ai/docs/api/tasks) and [error directory](https://seedrouter.ai/docs/api/errors).

## Pricing

Each completed request bills one output tier rate (`ecommerce` by `resolution` × `length`, or `webpage` by `resolution`) plus one reference-image charge per input image (including the first). A failed request carries no charge. See the [current rates](https://seedrouter.ai/models/kling-image-4-0-long-image#pricing).

## Errors and tips

Invalid requests return HTTP 400 before billing. Common validation mistakes include omitting `settings.skill`, sending `ecommerce` without 1–3 `refer_image` URLs, mixing `refer_image` with `webpage` mode, requesting `4k`, or duplicating reference IDs.

State the exact section order in your prompt—from hero banner down to specifications or footer—and include only verified product facts so the layout stays accurate. See the [Kling Image 4.0 Long Image playground](https://seedrouter.ai/models/kling-image-4-0-long-image#playground) and [OpenAPI schema](https://seedrouter.ai/docs/kling-image-4-0-long-image.openapi.json).
