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 License | link ↗ |
| More information | link ↗ |
| Pricing |
|
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"
}
}'
{
"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"
]
}
}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.▶images[]
arraymaxItems: 10Reference images for image-to-image: https URLs, data URIs or raw base64 (JPG or PNG, up to 30 MB, at least 300 px per side, aspect ratio between 2:5 and 5:2)n
integerrequireddefault: 1minimum: 1maximum: 9Number of images to generateresolution
stringrequireddefault: 2kenum: 2kOutput resolutionaspect_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 inputimage
stringURL to the first generated image▶images[]
arrayURLs to all generated images