APIMaster.ai

Kling Image 4.0 · API immagini

Kling Image 4.0 genera immagini indipendenti, serie coerenti, schede prodotto e progetti di pagine web lunghe.

Kling Image 4.0

Kling Image 4.0 genera immagini indipendenti, serie coerenti, schede prodotto e progetti di pagine web lunghe.

Endpoint

  • 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}

Parametri della richiesta

Campo Valore
contents JSON · type → prompt, refer_image, element, style_refer_image, subject_refer_image.
contents[].text Inserisci un solo prompt non vuoto. Usa @id per indicare un riferimento specifico.
contents[].id Identificatore univoco per ogni riferimento nella richiesta.
contents[].url URL pubblico o Base64. JPG, JPEG e PNG fino a 30 MB ciascuno, lati di almeno 300 px e rapporto da 2:5 a 5:2.
contents[].element_id Identificatore di un elemento immagine del tuo account o di un preset supportato. Conta come un riferimento.
settings.result_type single, series. Predefinito single.
settings.n single → 1–9. Predefinito 1.
settings.series_amount series → 2–10 / auto (2–10). Predefinito 4.
settings.resolution single / series → 2k, 4k, 8k. Predefinito 2k. ecommerce / webpage → 1k, 2k. Predefinito 1k.
settings.aspect_ratio single / series → auto, 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9. Predefinito auto.
settings.skill long-image-generation → ecommerce, webpage.
settings.length ecommerce → short, medium, long. Predefinito medium.
options.watermark_info.enabled boolean. Predefinito false. true → outputs[].watermark_url.
options.callback_url URL webhook facoltativo, già registrato e verificato sul tuo account APIMaster.
options.external_task_id ID di correlazione facoltativo fino a 128 byte, restituito con l’attività.

Immagini standard e serie accettano fino a 10 riferimenti ed elementi complessivi. E-commerce richiede 1–3 refer_image. Web accetta un riferimento di stile e uno di soggetto.

Prompt standard: 50.000 caratteri inglesi o 21.000 non inglesi. Immagini lunghe: 166.000 o 71.000. Nei prompt misti la somma delle quote rispetto ai limiti non supera 1.

La modalità singola genera immagini indipendenti. La serie restituisce immagini ordinate con lo stesso group_id. Ogni immagine lunga è un output completo. length vale per l’e-commerce e indica circa 2–5, 6–10 o 11–18 sezioni.

Esempi

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"
  }
}

Risultati dell’attività

Salva task_id e interroga con lo stesso account. Se riesce, outputs contiene gli URL e i campi facoltativi watermark_url e group_id. Se fallisce, leggi 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"}]
}

Riutilizza Idempotency-Key per ripetere la stessa richiesta. Dopo un timeout, interroga l’attività originale.

Tariffe

Si sommano il costo delle immagini consegnate alla tariffa di output e dei riferimenti alla tariffa di input. I prezzi correnti sono nel marketplace. Kling Image 4.0