> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unifically.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kling 2.1 Image

> Generate images with 4 reference modes: restyle, portrait, character, and elements

Generate high-quality AI images using Kling 2.1 Image with 4 reference modes for flexible image generation.

## Model

```
kuaishou/kling-2.1-image
```

## Parameters

| Parameter        | Type      | Required    | Default     | Description                                                                   |
| ---------------- | --------- | ----------- | ----------- | ----------------------------------------------------------------------------- |
| `prompt`         | string    | Yes         | -           | Text description of the image to generate                                     |
| `reference_mode` | string    | No          | `"restyle"` | Reference strategy: `"restyle"`, `"portrait"`, `"character"`, or `"elements"` |
| `image_url`      | string    | Conditional | -           | Source image URL. Required for restyle, portrait, and character modes         |
| `aspect_ratio`   | string    | No          | `"1:1"`     | `"21:9"`, `"16:9"`, `"3:2"`, `"4:3"`, `"1:1"`, `"3:4"`, `"2:3"`, `"9:16"`     |
| `fidelity`       | float     | No          | `0.5`       | How closely to follow the reference image (0.0–1.0)                           |
| `human_fidelity` | float     | No          | `0.65`      | Face similarity preservation strength (0.0–1.0, portrait mode only)           |
| `elements`       | string\[] | Conditional | -           | Element image/video URLs (2–4 required for elements mode)                     |
| `scene_url`      | string    | No          | -           | Background scene image URL (elements mode only)                               |
| `style_url`      | string    | No          | -           | Style reference image URL (elements mode only)                                |

## Mode Requirements

* **`restyle`** — requires `image_url`. Uses `fidelity` to control reference adherence
* **`portrait`** — requires `image_url`. Uses `fidelity` and `human_fidelity` for face control
* **`character`** — requires `image_url`. Uses `fidelity` only
* **`elements`** — requires 2–4 `elements` URLs. Optionally accepts `scene_url` and `style_url`

## Example - Restyle Mode

```bash theme={null}
curl -X POST https://api.unifically.com/v1/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "kuaishou/kling-2.1-image",
    "input": {
      "prompt": "Transform into an oil painting with vivid colors",
      "reference_mode": "restyle",
      "image_url": "https://example.com/photo.jpg",
      "fidelity": 0.7,
      "aspect_ratio": "16:9"
    }
  }'
```

## Example - Portrait Mode

```bash theme={null}
curl -X POST https://api.unifically.com/v1/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "kuaishou/kling-2.1-image",
    "input": {
      "prompt": "Professional headshot in a modern office setting",
      "reference_mode": "portrait",
      "image_url": "https://example.com/face.jpg",
      "fidelity": 0.5,
      "human_fidelity": 0.8,
      "aspect_ratio": "1:1"
    }
  }'
```

## Example - Elements Mode

```bash theme={null}
curl -X POST https://api.unifically.com/v1/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "kuaishou/kling-2.1-image",
    "input": {
      "prompt": "Two characters standing in a futuristic city",
      "reference_mode": "elements",
      "elements": [
        "https://example.com/character1.jpg",
        "https://example.com/character2.jpg"
      ],
      "scene_url": "https://example.com/city-bg.jpg",
      "style_url": "https://example.com/cyberpunk-style.jpg",
      "aspect_ratio": "16:9"
    }
  }'
```

## Response

```json theme={null}
{
  "code": 200,
  "success": true,
  "data": {
    "task_id": "abc123def456",
    "status": "processing"
  }
}
```
