Skip to content
Kling AI logo

Kling Image 4.0

Text-to-Image • Kling AI

Model ID

Use with the Workers AI binding, the AI Gateway REST API, or the Unified API.

Calling the provider directly? Use the provider's model name instead, including with provider-native endpoints or the provider's own SDK. For example, Anthropic's name for anthropic/claude-opus-4.8 is claude-opus-4-8.

  • Third-party

Kling Image 4.0 is Kling AI's latest image model, generating 2K images from a text prompt and up to 10 reference images, in nine aspect ratios including auto.

Model Info
Terms and Licenselink ↗
More informationlink ↗
Pricing
  • Per image$0.063
  • Per input image$0.003

Usage

const response = await env.AI.run(
  'klingai/kling-v4-image',
  {
    prompt:
      'A photorealistic portrait of a fox in an autumn forest, golden hour lighting',
    resolution: '2k',
    aspect_ratio: '16:9',
  },
  {
    gateway: { id: 'default' },
  }
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "klingai/kling-v4-image",
  "input": {
    "aspect_ratio": "16:9",
    "prompt": "A photorealistic portrait of a fox in an autumn forest, golden hour lighting",
    "resolution": "2k"
  }
}'
Simple Generation
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/klingai/kling-v4-image/simple-generation.png",
    "images": [
      "https://examples.aig.cloudflare.com/klingai/kling-v4-image/simple-generation.png"
    ]
  }
}

Parameters

prompt
stringrequiredminLength: 1maxLength: 50000Text prompt describing the image, up to 50,000 English characters. Refer to reference images as @image_1, @image_2, and so on.
n
integerrequireddefault: 1minimum: 1maximum: 9Number of images to generate
resolution
stringrequireddefault: 2kenum: 2kOutput resolution
aspect_ratio
stringrequireddefault: autoenum: auto, 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9Aspect ratio of the generated image; auto picks one from the input
image
stringURL to the first generated image

API Schemas (Raw)

Input
Output

Was this helpful?