Skip to content

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)

ParameterTypeRequiredDescription
promptstringYesPositive text prompt, max 500 characters
negative_promptstringNoNegative text prompt, max 200 characters
imagestringNoReference image (Base64 or URL), supports .jpg/.jpeg/.png, <=10MB, resolution >=300x300
image_fidelitynumberNoReference image strength, range [0,1]
nintegerNoNumber of generations, range [1,9]
aspect_ratiostringNoAspect ratio, enum: 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3
callback_urlstringNoCallback URL for asynchronous task result notifications
model_namestringNoModel name, enum: kling-v1, kling-v1-5, kling-v2
image_referencestringNoImage reference type, enum: subject, face (face requires only one face)
human_fidelitynumberNoSubject fidelity, range [0,1]

Note: When using kling-v1-5 and image is provided, image_reference is 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

FieldTypeDescription
codeintegerReturn code, 0 indicates success
messagestringReturn message
request_idstringUnique request ID
data.task_idstringTask ID
data.task_statusstringTask status, e.g. submitted
data.created_atintegerTask creation timestamp in milliseconds
data.updated_atintegerTask 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
  }
}