Kling Image Generation

OpenAI compatible: POST /v1/images/generations. Native paths: /v1/images/generations, /v1/images/omni-image.


1. Submit Image Generation Task Examples (POST)

  • HTTP Method: POST
  • Request Path: https://www.tokenpad.ai/v1/images/generations
  • Auth Header: Authorization: Bearer sk-your_token

A. Classic Text-to-Image (with Aspect Ratio & Negative Prompt)

You can control generation results by specifying aspect ratio, resolution, and negative prompts.

curl -X POST https://www.tokenpad.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-v3-omni",
    "prompt": "Bustling city street on a rainy night with neon lights reflecting off wet pavement, realistic sci-fi style, cinematic low-light look, 4K resolution",
    "negative_prompt": "low quality, blurry, broken anatomy, distorted, ugly",
    "ratio": "16:9",
    "resolution": "1k",
    "n": 1,
    "response_format": "url"
  }'

B. Image-to-Image & Multi-Subject Reference (Image-to-Image / Subject Image)

Pass image / image_urls for image-to-image or subject reference (1 image for image-to-image, multiple for subject reference).

curl -X POST https://www.tokenpad.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-v3-omni",
    "prompt": "Redraw the cartoon character design from image 1 and blend it into the background while keeping the pose consistent",
    "image_urls": [
      "https://example.com/assets/cartoon_char.png",
      "https://example.com/assets/background_scene.png"
    ],
    "ratio": "3:4",
    "n": 1
  }'

2. Complete Parameter Dictionary

ParameterTypeRequiredDefaultDescription & Constraints
modelstringYes-Image generation model, e.g., kling-v3-omni.
promptstringYes-Image description prompt, up to 2,000 characters.
negative_promptstringNo-Negative prompt.
ratio / aspect_ratiostringNo"1:1"Aspect ratio. Options: "1:1", "16:9", "9:16", "4:3", "3:4".
resolution / sizestringNo"1k"Target resolution, e.g., "1k".
imagestring / arrayNo-Reference image URL (string or array).
image_urlsarrayNo-Array of reference image URLs.
nintegerNo1Number of images to generate, typically 1–4.
watermarkbooleanNofalseWhether to add a watermark.
response_formatstringNo"url""url" or "b64_json".

3. Response Example (200 OK)

{
  "created": 1719441600,
  "data": [
    {
      "url": "https://example.com/output/img_kling_city.png"
    }
  ]
}

5. Common Error Codes & Troubleshooting

HTTP codes, error body format, and troubleshooting are maintained in one dedicated page (not duplicated under each example).

👉 Gateway Error Codes & Troubleshooting

Quick reference:

CodeMeaning
400Invalid parameters / content moderation or copyright block
402Insufficient account balance (not 429)
429RPS/RPM limits or in-flight task cap (low balance)
403Token / IP / model permission (balance → 402; content filter → 400)
200 + status: failedAsync video/long-task business failure on poll

HTTP status matches call log status_code for traceability by log_id.

Maintenance: update the error-codes article only; this appendix links to it.

Raw Markdown (.md) · llms.txt