Skip to content

Kling Image

Generate and expand images with Kling asynchronously: parameters, responses, and caveats.

ItemValue
Base URLhttps://api.hop-base.com/v1
Submit an image taskPOST /v1/images/generations
Poll a taskGET /v1/video/tasks/{task_id}
GroupKling Official

Every Kling image model runs as an asynchronous task: submission returns 202 with a task id, you poll the query endpoint, and a finished task lists image URLs in outputs[].

Available models

ModelModel IDquality tiersReference imagesOfficial price
Kling Image 3.0kling-image-v31k / 2k0–1$0.0294/ image
Kling Image 3.0 Omnikling-image-v3-omni1k / 2k / 4k0–10$0.0294from/ image
Kling Image O1kling-image-o11k / 2k / 4k0–10$0.0294from/ image
Kling Image 2.1 (text-to-image)kling-image-v2-11k / 2kNone$0.0147/ image
Kling Image 2.1 (image-to-image)kling-image-v2-1-i2i1k / 2kExactly 1$0.0294/ image
Kling Image 2.1 (multi-reference)kling-image-v2-1-multi-ref1k / 2k2–4$0.0588from/ image
Kling Image Expandkling-image-expand1kExactly 1$0.0294/ image

Choosing: use 2.1 (text-to-image) for plain text prompts, 3.0 Omni or O1 for 4k or many reference images, and Image Expand to extend an existing image outward.

Request parameters

ParameterRequiredType and limitsDefaultDescription
modelRequiredstring—An image model ID from the table above
promptRequired without imagesstring—Send it, a non-empty images, or both
qualityOptional1k / 2k / 4k1kQuality tier; allowed values vary by model
nOptionalinteger 1–91Number of images
imagesPer modelarray of url / file_id items—Reference images, or the image to expand
extraExpansion onlyobject with the four expansion ratios—See Image expansion
  • Only these fields are accepted; others such as size, aspect_ratio, or response_format return 400.
  • A video model ID in model returns 400.
  • quality is case-insensitive; OpenAI values such as high or standard are rejected.
  • n is billed per output image.
  • A non-empty extra on any other image model returns 400.

Reference images

Each images[] item carries exactly one of url or file_id, and no usage:

{
  "model": "kling-image-v3-omni",
  "prompt": "Place the cups from both images on one wooden table",
  "quality": "2k",
  "images": [
    { "url": "https://cdn.example.com/cup-a.png" },
    { "file_id": "your-file-id" }
  ]
}
  • url must be an absolute, publicly reachable http:// or https:// URL.
  • Empty strings, relative paths, non-HTTP(S) schemes such as file://, private or loopback addresses, and URLs with credentials are rejected synchronously.
  • A file_id must be a Kling asset available to your key, not a Seedance asset ID.
  • The number of reference images is limited per model; see Available models.

Image expansion

kling-image-expand extends one image outward; the ratios go in extra:

{
  "model": "kling-image-expand",
  "images": [{ "url": "https://example.com/input.png" }],
  "extra": {
    "left_expansion_ratio": 0.5,
    "right_expansion_ratio": 0.5,
    "up_expansion_ratio": 0,
    "down_expansion_ratio": 0
  }
}
  • Each of the 4 ratios is a number from 0–2; an omitted ratio is 0.
  • The four ratios cannot all be 0.
  • The expanded area may not exceed 3× the original: (1+left+right) × (1+up+down) ≤ 3.

Response

A successful submit returns HTTP 202 with the task ID in the top-level id, shaped like kt57x<task-id>:

{
  "id": "ktEXAMPLE",
  "object": "image.generation.task",
  "model": "kling-image-v3",
  "status": "queued",
  "created": 1790000000,
  "billing_bucket": "img_1k",
  "requested_images": 1
}

Poll GET /v1/video/tasks/{task_id} with that id. A finished task looks like this:

{
  "id": "ktEXAMPLE",
  "object": "video.generation.task",
  "model": "kling-image-v3",
  "status": "completed",
  "progress": 100,
  "created": 1790000000,
  "outputs": [
    "https://api.hop-base.com/example-signed-image.png"
  ],
  "usage": { "bucket": "img_1k", "billed_images": 1 }
}
FieldTypeDescription
idstringHopBase task ID, the same at submit and poll
objectstringimage.generation.task on submit, video.generation.task on poll
statusstringqueued → processing → completed or failed
progressintegerProgress percentage; poll only
requested_imagesintegerNumber of images requested; submit only
billing_bucketstringBilling tier for the quality; submit only
outputsstring[]Image URLs; only when completed
usage.billed_imagesintegerImages billed, equal to the images produced
error.code / error.messagestringOnly when failed; see Failed tasks

Only completed and failed are terminal, so treat any other value as still running.

Once the task finishes, the query's top-level usage also carries cost — the amount actually deducted from your balance for this task, 0 for an uncharged failure — and the currency.

Examples

Submit a text-to-image task, poll until it ends, then download the first image:

# 1. Submit
curl https://api.hop-base.com/v1/images/generations \
  -H "Authorization: Bearer sk-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-image-v3",
    "prompt": "A ceramic teapot on a sunlit wooden table",
    "quality": "1k",
    "n": 1
  }'

# 2. Poll with the returned id until status is completed or failed
curl https://api.hop-base.com/v1/video/tasks/ktYOUR_TASK_ID \
  -H "Authorization: Bearer sk-your-key"

Caveats

  • Image URLs are served from api.hop-base.com and stay valid for 6 hours from task completion, so download them promptly.
  • Querying again returns the same URL without extending it, and an expired link returns 410.
  • A task still unfinished 2 hours after creation is marked failed and not billed, and tasks cannot be cancelled.
  • Kling image generation reserves no balance and is only blocked once your balance is at or below zero.
  • Before sending paid work, confirm the exact model IDs your key returns with GET /v1/models.

Common errors

A submission error creates no task and bills nothing; error.message explains the cause:

ErrorFix
request body does not match the JSON contract: json: unknown field "size"Remove the extra field; set the tier with quality
prompt and input images cannot both be emptyAdd a prompt or reference images
images[0] must provide exactly one of url or file_idKeep only url or file_id in each item
images[0].url must be a publicly accessible absolute http(s) URLUse a public HTTP(S) URL
model "kling-image-v3" does not support quality tier "4k"Pick a tier the model supports
model "kling-image-v2-1-multi-ref" requires 2 to 4 input imagesMatch the model's reference image count
model "<model ID>" is not an image model in this catalogCheck the ID with GET /v1/models (404)

Failed tasks

A failed task still answers the query with HTTP 200 and status failed. Branch on the stable code in error.code and show the error explanation to your user. Older failed tasks may have no code.

Caseerror.code
Prompt or reference image refused by moderationinput_sensitive
Output blocked by moderationsafety_rejected
Concurrency ceiling reachedrate_limited
Model version retiredunsupported_model
Prompt too long, or parameters or media rejectedinvalid_request
Reference image unreadablereference_input_invalid
Generation failed or stopped before finishinggeneration_failed
Still unfinished 2 hours after creationtimeout
Task ended with no outputno_output

Billing

Kling images are billed per output image, at the rate for the model and quality tier; failed tasks and polling are never billed. Each model's price is on its model card linked above, and your own rate is the one shown in the signed-in model catalog.

Next steps