Explore/Kling Image 4.0
Image

Kling Image 4.0

Edit images with Kling Image 4.0 using a prompt and up to 10 references. Adjust composition, subjects or visual style and generate one image at 2K, 4K or native 8K.

View docs
import { config, higgsfield } from "@higgsfield/client/v2";config({  credentials: process.env.HF_CREDENTIALS,});const result = await higgsfield.subscribe(  "kling-image/v4.0/edit",  {    input: {      "prompt": "A cinematic scene at sunset",      "image_urls": [        "https://example.com/input.jpg"      ],      "resolution": "2k",      "aspect_ratio": "auto"    },    withPolling: true,  },);console.log(result);

Kling Image 4.0 uses the model ID kling-image/v4.0/edit. Edit images with Kling Image 4.0 using a prompt and up to 10 references. Adjust composition, subjects or visual style and generate one image at 2K, 4K or native 8K.

1. Calling the API

Send requests to https://api.higgsfield.ai/kling-image/v4.0/edit with a JSON body matching the parameters below.

Install

Install an official server-side SDK. cURL needs no package.

npm install @higgsfield/client

Setup

Keep credentials in server-side environment variables. The SDKs accept the same KEY_ID:KEY_SECRET value under their documented variable names.

export HF_CREDENTIALS="YOUR_KEY_ID:YOUR_KEY_SECRET" # TypeScript export HF_KEY="YOUR_KEY_ID:YOUR_KEY_SECRET" # Python and cURL

Request parameters

ParameterTypeRequiredDefaultDescription
promptstringYes—Prompt. Minimum length: 1. Maximum length: 50000.
image_urlsarray[string]Yes—JPG/PNG, up to 30 MB, dimensions at least 300 px and aspect ratio 2:5 to 5:2. Reference as @image_1, @image_2, etc.
resolutionstringNo"2k"Options: 2k, 4k, 8k.
aspect_ratiostringNo"auto"Options: 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9, auto.

2. Authentication

The official SDKs read credentials from the server environment and send the required Authorization: Key KEY_ID:KEY_SECRET header.

API Key

Never expose the secret in browser-side code or commit it to source control. The TypeScript SDK is server-side only. For direct HTTP calls, use:

Authorization: Key $HF_KEY

3. Queue

subscribe submits the asynchronous request and waits for a terminal result. The TypeScript SDK polls automatically when withPolling: true; the Python SDK's synchronous subscribe call also waits. A completed request returns generated files in the images array.

Submit and wait

Replace placeholder media URLs with accessible URLs for your own files.

import { config, higgsfield } from "@higgsfield/client/v2"; config({ credentials: process.env.HF_CREDENTIALS, baseURL: "https://api.higgsfield.ai", }); const result = await higgsfield.subscribe( "kling-image/v4.0/edit", { input: { "prompt": "Place the product from @image_1 on pale stone, keeping its shape and label", "image_urls": [ "https://example.com/reference.png" ], "resolution": "2k", "aspect_ratio": "16:9" }, withPolling: true, }, ); console.log(result);

Custom polling

For direct HTTP integration, submit the request and poll the returned status_url using the same API credentials until it reaches a terminal status. Use the returned cancel_url to request cancellation while the request is still queued. See the request lifecycle guide for response states.

4. Using this model

Use a non-empty prompt of at most 50,000 characters. resolution accepts 2k, 4k or 8k and defaults to 2k. aspect_ratio defaults to auto; supported values are listed above.

Supply 1–10 JPG or PNG URLs in image_urls. Each image must be at most 30 MB, at least 300 pixels on each side, with an aspect ratio between 2:5 and 5:2. Refer to images in the prompt as @image_1, @image_2, and so on.

This endpoint generates one image. Use the separate Series variant for 2–10 related images; this endpoint has no series-count parameter.

5. Pricing

ResolutionPrice per image
2k$0.063
4k$0.094
8k$0.157

Each request generates one image. A default 2K request costs $0.063. Reference images do not add a separate charge.