APIMaster.ai

Kling Image 4.0 · Image API

Create individual images, coordinated image series, e-commerce detail pages, and webpage designs with Kling Image 4.0.

Kling Image 4.0

Create individual images, coordinated image series, e-commerce detail pages, and webpage designs with Kling Image 4.0.

Endpoints

  • POST https://apimaster.ai/v1/kling/kling-image-4.0/image-generation · single, series
  • POST https://apimaster.ai/v1/kling/kling-image-4.0/long-image-generation · ecommerce, webpage
  • GET https://apimaster.ai/v1/kling/kling-image-4.0/tasks/{task_id}

Request parameters

Field Value
contents JSON array. type → prompt, refer_image, element, style_refer_image, subject_refer_image.
contents[].text Required prompt text. Add one prompt entry and use @id to refer to individual assets.
contents[].id A unique identifier for each reference within the request.
contents[].url Public image URL or Base64. JPG, JPEG, and PNG, up to 30 MB each, both sides at least 300 px, aspect ratio 2:5 to 5:2.
contents[].element_id An image element handle owned by your account or a supported preset handle. Counts as one reference.
settings.result_type single, series. Default single.
settings.n single → 1–9. Default 1.
settings.series_amount series → 2–10 / auto (2–10). Default 4.
settings.resolution single / series → 2k, 4k, 8k. Default 2k. ecommerce / webpage → 1k, 2k. Default 1k.
settings.aspect_ratio single / series → auto, 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9. Default auto.
settings.skill long-image-generation → ecommerce, webpage.
settings.length ecommerce → short, medium, long. Default medium.
options.watermark_info.enabled boolean. Default false. true → outputs[].watermark_url.
options.callback_url Optional verified webhook URL. The URL must already be registered and verified on your APIMaster account.
options.external_task_id Your optional correlation ID, up to 128 bytes, returned with the task.

Regular images accept up to 10 reference images and elements combined. E-commerce requires 1–3 refer_image entries. Webpage accepts up to one style reference and one subject reference.

Regular prompts accept 50,000 English or 21,000 non-English characters. Long-image prompts accept 166,000 or 71,000 respectively. For mixed prompts, the sum of each count divided by its limit must be at most 1.

Single mode generates independent images. Series mode returns related images in order with a shared group_id. Long images return one complete image. Length applies only to e-commerce and controls approximately 2–5, 6–10, or 11–18 sections.

Examples

single

curl -sS "https://apimaster.ai/v1/kling/kling-image-4.0/image-generation" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: kling-image-example-001" \
  -d '{"contents":[{"type":"prompt","text":"A blue ceramic cup in soft daylight"}],"settings":{"resolution":"2k","aspect_ratio":"1:1"}}'

series

{
  "contents": [
    {
      "type": "prompt",
      "text": "Create two coordinated studio photographs of the blue ceramic cup in @cup. Show a front view and a detail close-up."
    },
    {
      "type": "refer_image",
      "id": "cup",
      "url": "https://example.com/cup.png"
    }
  ],
  "settings": {
    "result_type": "series",
    "series_amount": 2,
    "resolution": "4k",
    "aspect_ratio": "3:4"
  },
  "options": {
    "watermark_info": {
      "enabled": true
    },
    "external_task_id": "campaign-cup-001"
  }
}

ecommerce

{
  "contents": [
    {
      "type": "prompt",
      "text": "Design a product detail page for @cup. Include a hero image, material details, and care instructions."
    },
    {
      "type": "refer_image",
      "id": "cup",
      "url": "https://example.com/cup.png"
    }
  ],
  "settings": {
    "skill": "ecommerce",
    "length": "short",
    "resolution": "1k"
  }
}

webpage

{
  "contents": [
    {
      "type": "prompt",
      "text": "Design a long product landing page for a ceramic cup collection."
    }
  ],
  "settings": {
    "skill": "webpage",
    "resolution": "2k"
  }
}

Task results

Save the task_id and poll with the same account. On success, outputs lists each image URL plus its optional watermark_url and group_id. On failure, read error.

curl -sS "https://apimaster.ai/v1/kling/kling-image-4.0/tasks/TASK_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "task_id": "task_example",
  "object": "image",
  "model": "kling-image-4.0",
  "status": "completed",
  "outputs": [{"type": "image", "url": "https://example.com/generated.png"}]
}

Use a stable Idempotency-Key when retrying the same request. Query the existing task after a timeout.

Pricing

Pricing combines the number of delivered images at the selected output rate and the number of input references at the input rate. Current customer prices are shown in the marketplace. Kling Image 4.0