Task: Image Generation
Overview
- Method:
POST - Path:
/kling/v1/images/generations - Content-Type:
application/json
Authentication
- HTTP Bearer:
Authorization: Bearer <token>
Request Parameters
Body Parameters (JSON)
| Parameter | Type | Required | Description |
|---|---|---|---|
| prompt | string | Yes | Positive text prompt, max 500 characters |
| negative_prompt | string | No | Negative text prompt, max 200 characters |
| image | string | No | Reference image (Base64 or URL), supports .jpg/.jpeg/.png, <=10MB, resolution >=300x300 |
| image_fidelity | number | No | Reference image strength, range [0,1] |
| n | integer | No | Number of generations, range [1,9] |
| aspect_ratio | string | No | Aspect ratio, enum: 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3 |
| callback_url | string | No | Callback URL for asynchronous task result notifications |
| model_name | string | No | Model name, enum: kling-v1, kling-v1-5, kling-v2 |
| image_reference | string | No | Image reference type, enum: subject, face (face requires only one face) |
| human_fidelity | number | No | Subject fidelity, range [0,1] |
Note: When using
kling-v1-5andimageis provided,image_referenceis required.
Example Request
curl Example
bash
curl -X POST "https://api.gpt.ge/kling/v1/images/generations" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxx" \
-d '{
"prompt": "A girl with pink hair and blue hair, shiny/glossy style, stone forest yellow, light blue and light black, fairy tale core, cyan, Ron, soft shadows, anime style",
"model_name": "kling-v1",
"n": 1
}'JavaScript (fetch) Example
javascript
fetch('https://api.gpt.ge/kling/v1/images/generations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-xxxx'
},
body: JSON.stringify({
prompt: 'A girl with pink hair and blue hair, shiny/glossy style, stone forest yellow, light blue and light black, fairy tale core, cyan, Ron, soft shadows, anime style',
model_name: 'kling-v1',
n: 1
})
}).then(r => r.json()).then(console.log)Python Example (requests)
python
import requests
resp = requests.post(
'https://api.gpt.ge/kling/v1/images/generations',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-xxxx'
},
json={
'prompt': 'A girl with pink hair and blue hair, shiny/glossy style, stone forest yellow, light blue and light black, fairy tale core, cyan, Ron, soft shadows, anime style',
'model_name': 'kling-v1',
'n': 1
}
)
print(resp.json())Response Fields
200 Success
| Field | Type | Description |
|---|---|---|
| code | integer | Return code, 0 indicates success |
| message | string | Return message |
| request_id | string | Unique request ID |
| data.task_id | string | Task ID |
| data.task_status | string | Task status, e.g. submitted |
| data.created_at | integer | Task creation timestamp in milliseconds |
| data.updated_at | integer | Task update timestamp in milliseconds |
Response Example
json
{
"code": 0,
"message": "SUCCEED",
"request_id": "CjNQtmctxFMAAAAAAHH7hA",
"data": {
"task_id": "CjNQtmctxFMAAAAAAHH7hA",
"task_status": "submitted",
"created_at": 1731252406651,
"updated_at": 1731252406651
}
}