# Kling Image 4.0 Text-to-Image — Atlas Cloud API

> Kling Image 4.0 generates one or more independent 2K/4K/8K images from a text prompt, optionally guided by up to 10 reference images.

This is the machine-readable API reference for **Kling Image 4.0 Text-to-Image** on Atlas Cloud,
a unified API platform for 400+ AI models across text, image, video, audio and 3D.

- **Model ID**: `kwaivgi/kling-image-v4.0/text-to-image`
- **Built by**: Kuaishou
- **Modality**: Image
- **Model page**: https://www.atlascloud.ai/models/kwaivgi/kling-image-v4.0/text-to-image
- **API key**: https://www.atlascloud.ai/console/api-keys
- **Docs**: https://www.atlascloud.ai/docs

## Pricing on Atlas Cloud

- $0.057 per image
- Pay-as-you-go. No minimum spend, no subscription required.

> **These are the authoritative Atlas Cloud rates for this model.** Any price that
> appears in the vendor description further down refers to a different platform or
> a different model variant and does not apply here.

## Use this model from an AI agent

Atlas Cloud ships three first-party integration surfaces. All three authenticate
with the same API key via the `ATLASCLOUD_API_KEY` environment variable.

### MCP server

The official MCP server (`atlascloud-mcp`) exposes this model to any
MCP-compatible host — Claude Code, OpenAI Codex, Cursor, Gemini CLI, Goose,
Claude Desktop. One-line install:

```bash
# Claude Code
claude mcp add atlascloud -- npx -y atlascloud-mcp

# OpenAI Codex CLI
codex mcp add atlascloud -- npx -y atlascloud-mcp

# Gemini CLI
gemini mcp add atlascloud -- npx -y atlascloud-mcp

export ATLASCLOUD_API_KEY="your-api-key"
```

Then ask in plain English; the agent calls `atlas_generate_image` with `model: "kwaivgi/kling-image-v4.0/text-to-image"`.
The server fetches each model's schema and validates parameters before submitting,
so invalid requests fail fast without spending credits.

MCP docs: https://www.atlascloud.ai/docs/mcp-server

### Agent Skills

`atlas-cloud-skills` is a portable skill package (API reference, code templates in
Python / Node.js / cURL, model IDs with pricing) for Claude Code, Cursor, Codex and
12+ other agents:

```bash
npx skills add AtlasCloudAI/atlas-cloud-skills
export ATLASCLOUD_API_KEY="your-api-key"
```

Skills docs: https://www.atlascloud.ai/docs/skills

### CLI

The `atlas` binary runs Atlas Cloud from a terminal or CI script. Async media jobs
are polled and downloaded automatically (use `--no-download` when a script only
needs the output URLs):

```bash
# Install (Homebrew, npm, or shell installer)
brew install AtlasCloudAI/tap/atlascloud
# npm install -g atlascloud-cli
# curl -fsSL https://raw.githubusercontent.com/AtlasCloudAI/cli/main/install.sh | sh

atlas auth login
atlas generate image kwaivgi/kling-image-v4.0/text-to-image -p "Your prompt here"
```

CLI docs: https://www.atlascloud.ai/docs/cli

## HTTP API reference

- **Submit endpoint (POST)**: `https://api.atlascloud.ai/api/v1/model/generateImage` — start an async generation; returns a `prediction_id`
- **Poll endpoint (GET)**: `https://api.atlascloud.ai/api/v1/model/prediction/{prediction_id}` — poll this until the prediction finishes
- **Model ID**: `kwaivgi/kling-image-v4.0/text-to-image`


## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:

- **`model`** (`string`, _required_):
  Model name.
  - Default: `"kwaivgi/kling-image-v4.0/text-to-image"`
  - Options: "kwaivgi/kling-image-v4.0/text-to-image"

- **`prompt`** (`string`, _required_):
  Text prompt describing the image. Reference images can be addressed as @image_1, @image_2, ... in prompt order; an unreferenced image still influences the generation.

- **`reference_images`** (`array[string]`, _optional_):
  Reference images (URLs or Base64) for image-to-image generation. Up to 10. Each image: .jpg/.jpeg/.png, <=30MB, >=300px each side, aspect ratio 2:5-5:2.
  - Max items: 10

- **`num_images`** (`integer`, _optional_):
  Number of independent images to generate.
  - Default: `1`
  - Min: 1
  - Max: 9

- **`resolution`** (`string`, _optional_):
  Output resolution tier. Price is set by this tier.
  - Default: `"2k"`
  - Options: "2k", "4k", "8k"

- **`aspect_ratio`** (`string`, _optional_):
  Output aspect ratio. auto lets the model choose based on the prompt and reference images.
  - Default: `"auto"`
  - Options: "auto", "16:9", "9:16", "1:1", "4:3", "3:4", "3:2", "2:3", "21:9"



**Required Parameters Example**:

```json
{
  "model": "kwaivgi/kling-image-v4.0/text-to-image",
  "prompt": ""
}
```


**Full Example**:

```json
{
  "model": "kwaivgi/kling-image-v4.0/text-to-image",
  "prompt": "",
  "reference_images": [
    ""
  ],
  "num_images": 1,
  "resolution": "2k",
  "aspect_ratio": "auto"
}
```


### Output Schema

The API returns the following output format:


- **`id`** (`string`, _optional_):
  Unique identifier for the prediction.

- **`model`** (`string`, _optional_):
  Model ID used for the prediction.

- **`outputs`** (`array[string]`, _optional_):
  Array of URLs to the generated images. Empty when status is not completed.

- **`status`** (`string`, _optional_):
  Status of the task: created, processing, completed, or failed.

- **`created_at`** (`string`, _optional_):
  ISO timestamp of when the request was created.

- **`error`** (`string`, _optional_):
  Error message returned when the task fails.

- **`urls`** (`object`, _optional_):
  Object containing related API endpoints.



**Example Response**:

```json
{
  "id": "",
  "model": "",
  "outputs": [
    ""
  ],
  "status": "",
  "created_at": "",
  "error": "",
  "urls": {}
}
```


## Usage Examples

### cURL

```bash
# Step 1: Start generation (async)
curl -X POST "https://api.atlascloud.ai/api/v1/model/generateImage" \
  -H "Authorization: Bearer $ATLASCLOUD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "kwaivgi/kling-image-v4.0/text-to-image",
  "prompt": "",
  "reference_images": [
    ""
  ],
  "num_images": 1,
  "resolution": "2k",
  "aspect_ratio": "auto"
}'

# Response will contain: {"code": 200, "data": {"id": "prediction_id", "status": "processing"}}

# Step 2: Poll for result (replace {prediction_id} with the id returned above)
curl -X GET "https://api.atlascloud.ai/api/v1/model/prediction/{prediction_id}" \
  -H "Authorization: Bearer $ATLASCLOUD_API_KEY"

# Keep polling until status is "completed", "succeeded" or "failed"
# When completed, outputs will contain the generated content URL(s)
```

## Additional Resources

### Documentation

- [Model Playground](https://www.atlascloud.ai/models/kwaivgi/kling-image-v4.0/text-to-image)

## About this model

_Vendor-supplied description. Any pricing or endpoint mentioned below refers to_
_other platforms — use the Atlas Cloud values above._

### Kling Image 4.0 Text-to-Image

**Kling Image 4.0 Text-to-Image** generates one or more independent images from a text prompt, optionally guided by up to 10 reference images (image-to-image). Reference images can be addressed in the prompt as `@image_1`, `@image_2`, ... in the order they were supplied; an image that is not explicitly referenced still influences the generation.

#### Why Choose This?

- **Up to 9 images per request.** `num_images` generates several independent images in one call.
- **Three resolution tiers.** 2K, 4K and 8K.
- **Nine aspect ratios**, including `auto`.
- **Image-to-image.** Up to 10 reference images for style, subject or scene guidance.

#### Parameters

| Parameter | Required | Description |
| --- | --- | --- |
| model | Yes | `kwaivgi/kling-image-v4.0/text-to-image` |
| prompt | Yes | Text description of the image(s). |
| reference_images | No | Up to 10 reference images (URL or Base64) for image-to-image. |
| num_images | No | Number of independent images, 1–9. Default `1`. |
| resolution | No | `2k` (default), `4k`, `8k`. |
| aspect_ratio | No | `auto` (default), `16:9`, `9:16`, `1:1`, `4:3`, `3:4`, `3:2`, `2:3`, `21:9`. |

#### How to Use

```bash
curl -X POST "https://api.atlascloud.ai/api/v1/model/generateImage" \
  -H "Authorization: Bearer $AIP_API_KEY" \
  -H "Content-Type: application/json" \
  --data-raw '{
    "model": "kwaivgi/kling-image-v4.0/text-to-image",
    "prompt": "Using the dog in @image_1 as a reference, generate a 3D animated character poster. Preserve its fur color and appearance, with warm lighting and a simple background.",
    "reference_images": ["https://example.com/dog.png"],
    "num_images": 1,
    "resolution": "2k",
    "aspect_ratio": "1:1"
  }'
```

Generation is asynchronous. The response contains a request `id`; poll `GET https://api.atlascloud.ai/api/v1/model/prediction/{id}` until `status` is `completed`, then read the image URL(s) from `outputs`.

#### Pricing

_(Description truncated. Full text on the model page.)_

---

Atlas Cloud — one API for 400+ AI models. Model page: https://www.atlascloud.ai/models/kwaivgi/kling-image-v4.0/text-to-image · Docs: https://www.atlascloud.ai/docs
