Explore/Kling Image 4.0
Image

Kling Image 4.0

Generate detailed images from text with Kling Image 4.0. Create realistic scenes, product visuals and text-rich designs 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/text-to-image",  {    input: {      "prompt": "A cinematic scene at sunset",      "resolution": "2k",      "aspect_ratio": "auto"    },    withPolling: true,  },);console.log(result);

Kling Image 4.0 uses the model ID kling-image/v4.0/text-to-image. Generate detailed images from text with Kling Image 4.0. Create realistic scenes, product visuals and text-rich designs at 2K, 4K or native 8K.

1. Calling the API

Send requests to https://api.higgsfield.ai/kling-image/v4.0/text-to-image 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.
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

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/text-to-image", { input: { "prompt": "A photorealistic seaside cafe in soft morning light", "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.

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.