> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# Kling Image 4.0

POST https://api.beatapi.io/v1/images/tasks
Content-Type: application/json

Kling의 이미지 모델입니다. 텍스트, 최대 10장의 참조 이미지와 이름 있는 요소로 작업당 1\~9장의 이미지를 2K, 4K 또는 8K로 생성하거나 편집합니다.- 비동기 방식입니다. 생성 요청은 곧바로 작업 ID를 반환하며, 작업이 성공하면 이미지가 도착합니다.
- 작업 하나가 `n`으로 1\~9장의 이미지를 만들며, 각 이미지는 해당 `resolution` 등급 요금으로 과금됩니다.
- 텍스트로 이미지를 만들거나, 공개 HTTPS 링크로 전달한 참조 이미지와 이름 있는 `elements`를 합계 최대 10개까지 편집·합성합니다.
- 프롬프트에서 입력을 지칭하세요. `images`는 순서대로 `@image_1`, `@image_2` …, 요소는 `@` 뒤에 이름을 붙입니다.
- `resolution`(2K, 4K 또는 8K)에 따라 이미지당 가격이 정해지며, 참조 이미지와 요소마다 고정 요금이 더해집니다. 실패한 작업은 과금되지 않습니다.POST/v1/images/tasks실행해 보기API Explorer에서 이 모델을 엽니다. BeatAPI API 키를 입력해 작업을 만드세요. 실제 호출이며 본인 잔액에서 과금됩니다.## 엔드포인트와 인증`POST https://api.beatapi.io/v1/images/tasks`Authorization
string
필수BeatAPI API 키를 `Bearer <BEATAPI_API_KEY>`로 보내세요. 키는 [대시보드](https://beatapi.io/dashboard)에서 만듭니다. 키는 서버에 보관하고, 브라우저나 모바일 앱에 포함하지 마세요.본문은 `Content-Type: application/json`과 함께 JSON으로 보냅니다. `Idempotency-Key`는 선택 사항입니다. 논리적 요청마다 고유한 값(최대 255자)을 보내고, 완전히 같은 본문을 재시도할 때만 다시 사용하세요. 24시간 안에 같은 키와 본문으로 재시도하면 첫 응답을 `Idempotent-Replayed: true`와 함께 다시 반환하고, 같은 키에 다른 본문을 보내면 `409 idempotency_conflict`를 반환합니다. 2xx 이외의 응답은 저장되지 않으므로 400이나 402 이후의 재시도는 다시 실행됩니다.## 요청 처리 방식아래 파라미터를 엔드포인트로 `POST`하세요. `201`은 작업이 접수되었고 가격만큼 잔액이 보류되었다는 뜻이며, 작업은 백그라운드에서 실행됩니다. `data.id`를 저장하세요.`status`가 `succeeded` 또는 `failed`가 될 때까지 `GET /v1/tasks/{task_id}`를 호출하고, 호출 사이에 `data.poll_after_seconds`만큼 기다리세요(이미지 5초, 영상 8초). 또는 `task.succeeded`와 `task.failed`에 대한 [웹훅](/webhooks)을 등록하세요. 처리 시간 초과로 중단된 작업은 이벤트를 보내지 않으므로 폴링은 대비책으로 유지하세요.`succeeded`이면 모든 `data.output.media[].url`을 다운로드해 필요한 파일을 저장하세요. BeatAPI는 결과 URL을 얼마 동안 사용할 수 있는지 보장하지 않습니다. `failed`이면 `data.error_code`와 `data.error_message`를 확인하세요. 보류된 금액은 잔액으로 돌아왔으며, `data.retryable`은 같은 요청을 다시 보내면 성공할 수 있는지 알려 줍니다.## 입력 모드| 모드          | 필수 입력                                                   | 참고                                                                                         |
| ----------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| 텍스트로 이미지 생성 | `model`, `prompt`                                       | `images`와 `elements`를 보내지 마세요.                                                             |
| 이미지 편집·합성   | `model`, `prompt`, 그리고 `images` 또는 `elements` 중 하나나 둘 다 | 참조 이미지와 요소는 합계 최대 10개입니다. `prompt`에서 각각을 지칭하세요. 첫 번째 이미지는 `@image_1`, 요소는 `@` 뒤에 이름을 붙입니다. |## 요청 파라미터model
string
필수실행할 모델입니다.**값**: `kling-image-v4`**값이 잘못된 경우**- 누락: `"model" is required`
- 알 수 없는 모델 ID: `"model" kling-image-v9 is not catalogued`
- 이 엔드포인트로 영상 모델을 보낸 경우: `"model" kling-v4 is served by POST /v1/videos/tasks, not this endpoint`prompt
string
필수그릴 내용 또는 참조 이미지에서 바꿀 내용입니다. 피사체, 스타일, 조명, 구도, 이미지에 들어가야 할 문구를 쓰고, 각 입력을 `@` 멘션으로 지칭합니다.**길이**: 1–20000자- 길이는 문자 수로 계산합니다(한중일 문자 하나는 1자).
- 멘션: `images`는 목록 순서대로 `@image_1`, `@image_2` …이며, 요소는 `@` 뒤에 `name`을 붙입니다.
- 모든 `@image_N`은 같은 요청의 이미지를 가리켜야 합니다. 이미지가 두 장인데 `@image_3`을 쓰면 작업 생성 시 거부됩니다.**값이 잘못된 경우**- 누락: `"prompt" is required`
- 비어 있거나 한도보다 긴 경우: `"prompt" has an unsupported length`
- 요청에 없는 이미지를 멘션함: `the prompt names @image_3, which this request does not send`images
string[]
선택편집하거나 합성할 참조 이미지입니다. 프롬프트에서는 목록 순서대로 `@image_1`, `@image_2` …로 지칭합니다.**항목 수**: 1–10  \
각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요.- 각 항목은 JPEG 또는 PNG 파일을 가리키는 공개 `https://` 링크여야 합니다. 작업을 생성할 때 BeatAPI는 각 링크를 읽고, 그런 이미지가 아니거나 아래 제한을 벗어나는 링크를 위치와 함께 거부합니다(`images[0]`이 첫 번째 링크).
- `images`와 `elements`는 합계 최대 10개입니다.
- 링크마다 작업에 고정 요금이 추가됩니다(가격 참고).**값이 잘못된 경우**- 최대 개수를 넘은 경우: `"images" accepts at most 10 items`
- 빈 배열: `"images" requires at least 1 item`
- https\:// 링크가 아닌 경우: `"images[0]" must be a public HTTPS URL`
- JPEG 또는 PNG 파일이 아닌 링크(이 예에서는 WebP): `"images[0]" is not a PNG or JPEG image: the URL returned image/webp`
- 오류로 응답하는 링크: `"images[0]" could not be downloaded: the URL returned HTTP 404`
- 이미지와 요소가 합계 10개 초과: `Kling Image 4.0 takes at most 10 images and elements together`**예시**```json
"images": [
  "https://cdn.beatapi.io/samples/smart-bottle.png",
  "https://cdn.beatapi.io/samples/neon-singer.png"
]
```elements
object[]
선택캐릭터, 동물, 소품, 의상, 장면 같은 이름 있는 피사체입니다. 각각 2\~4장의 이미지로 보여 주며, 프롬프트에서는 `@` 뒤에 `name`을 붙여 지칭합니다.**항목 수**: 10개 이하- 객체 배열입니다. 각 객체는 다음 키만 받습니다.
- `elements[].name`(string, 필수): 영문자, 숫자, 밑줄 또는 한자 1\~20자이며, 요청 안에서 대소문자 구분 없이 고유해야 합니다. `image_N`, `video_N`, `voice_N`, `keyframe_N`, `object_N`, `audio_N`, `first_frame`, `last_frame`은 쓸 수 없습니다.
- `elements[].element_input_urls`(문자열 배열, 필수): 요소 이미지를 가리키는 공개 HTTPS 링크 2\~4개이며, 첫 번째가 메인 뷰입니다.
- `elements[].tag`(문자열, 선택): 요소의 종류입니다.
- `elements[].description`(string, 선택): 요소에 대한 설명, 최대 100자.
- 요소는 이미지로만 구성됩니다. 이 모델은 영상 요소와 음성 요소를 받지 않습니다.
- `images`와 `elements`는 합계 최대 10개입니다. 요소마다 포함한 이미지 수와 관계없이 작업에 고정 요금이 더해집니다.**값이 잘못된 경우**- 요소가 10개 초과: `"elements" accepts at most 10 items`
- 객체가 아닌 요소: `"elements[0]" must be an object`
- `name`이 없는 요소: `"name" is required in "elements[0]"`
- `element_input_urls`가 없는 요소: `"element_input_urls" is required in "elements[0]"`
- 비어 있거나 20자보다 긴 `name`: `"elements[0].name" has an unsupported length`
- 다른 문자가 들어 있거나 예약된 이름인 `name`: `elements[0].name "image_1" is not a name Kling V4 accepts`
- 대소문자를 무시하면 같은 `name`이 두 번: `elements[1].name "Hero" is used twice`
- 이미지가 두 장 미만: `"elements[0].element_input_urls" requires at least 2 item`
- 이미지가 네 장 초과: `"elements[0].element_input_urls" accepts at most 4 items`
- 목록에 없는 `tag`: `"elements[0].tag" must be one of: [character animal prop costume scene effect others]`
- 100자보다 긴 `description`: `"elements[0].description" has an unsupported length`
- 요소가 받지 않는 키(예: 영상): `field "element_input_video_urls" is not supported in "elements[0]"`**예시**```json
"elements": [
  {
    "name": "Bottle",
    "tag": "prop",
    "description": "A matte smart water bottle",
    "element_input_urls": [
      "https://your-cdn.example.com/bottle-front.png",
      "https://your-cdn.example.com/bottle-side.png"
    ]
  }
]
```aspect_ratio
string
선택기본값: auto이미지의 형태(너비:높이)입니다.**허용 값**: `auto`, `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `3:2`, `2:3`, `21:9`  \
**기본값**: `auto`- 생략하면 `auto`가 사용되며, 모델이 프롬프트와 입력 이미지를 보고 프레임을 정합니다. 형태가 중요하면 비율을 지정하세요.**값이 잘못된 경우**- 목록에 없는 값: `"aspect_ratio" must be one of: [auto 1:1 16:9 9:16 4:3 3:4 3:2 2:3 21:9]`resolution
string
선택기본값: 2K이미지의 크기 등급: `2K`, `4K` 또는 `8K`. 등급마다 이미지당 가격이 다릅니다.**허용 값**: `2K`, `4K`, `8K`  \
**기본값**: `2K`- 생략하면 `2K`가 사용되어 과금됩니다.
- 2K와 4K 이미지는 PNG로, 8K 이미지는 JPEG으로 반환됩니다.
- K는 대문자로 쓰세요. `2k`는 거부됩니다. 1K 등급은 없으며 `2048x2048` 같은 픽셀 크기도 받지 않습니다.**값이 잘못된 경우**- 목록에 없는 값(예: `1K` 또는 `2k`): `"resolution" must be one of: [2K 4K 8K]`n
integer
선택기본값: 1이 작업에서 생성할 이미지 수입니다. 모든 이미지에 같은 프롬프트, 입력, 비율, 등급이 사용됩니다.**기본값**: `1`  \
**범위**: 1–9- 생략하면 `1`이 사용됩니다.
- 각 이미지는 `resolution` 가격으로 과금되므로 `n`은 이미지 부분의 가격을 배로 늘립니다. 참조 이미지와 요소 요금은 이미지마다가 아니라 작업당 한 번만 계산됩니다.
- 이미지는 전달된 수만큼 과금됩니다.**값이 잘못된 경우**- 범위 밖, 정수가 아님, 또는 문자열로 보낸 경우: `"n" is outside its supported range`게이트웨이는 작업을 만들기 전에 다음 조합도 검사합니다.- n은 요청 하나로 1\~9장의 이미지를 만듭니다. 각 이미지는 해당 해상도 등급으로 과금되며, images의 각 이미지와 각 요소는 요청마다 한 번씩 추가로 과금됩니다
- 프롬프트에서 images는 순서대로 @image\_1, @image\_2 …, 요소는 @ 뒤에 이름을 붙여 지칭합니다. 모든 @image\_N은 같은 요청의 이미지를 가리켜야 합니다
- 요소는 element\_input\_urls에 넣은 한 피사체의 이미지 2\~4장이며 첫 번째가 메인 뷰입니다. images와 elements는 합계 최대 10개입니다
- 요소 이름은 영문자, 숫자, 밑줄 또는 한자 1-20자이며, 대소문자 구분 없이 고유해야 하고 image\_N, video\_N, voice\_N, keyframe\_N, object\_N, audio\_N, first\_frame, last\_frame은 쓸 수 없습니다
- images는 JPEG 또는 PNG, 최대 20 MB, 비율 2:5\~5:2, 각 변 최대 8192 px입니다
- 2K와 4K는 PNG로, 8K는 JPEG으로 반환됩니다. aspect\_ratio auto는 프롬프트와 입력 이미지를 보고 모델이 프레임을 정합니다## 입력 미디어 제한게이트웨이는 작업을 만들기 전에 모든 입력을 읽고, 아래 제한을 벗어난 입력은 해당 입력을 명시한 `400 bad_request`로 거부합니다. 과금되지 않습니다.| 미디어 | 작업 생성 전에 검사하는 제한                                              |
| --- | ------------------------------------------------------------- |
| 이미지 | 너비와 높이 각각 최대 8192 px, 가로세로 비율(너비 ÷ 높이) 0.4–2.5, 각 파일 최대 20 MB |- 게이트웨이는 작업 생성 전에 `images`의 모든 링크를 읽고, 이 제한을 벗어난 링크를 이름을 밝혀 거부합니다. 예: `images[0] has an aspect ratio of 3.10 (width/height); this model takes 0.4 to 2.5.` 과금되지 않습니다.
- 요소 이미지(`element_input_urls`)는 작업 생성 전에 공개 HTTPS 링크인지만 확인합니다. 같은 제한 안의 JPEG 또는 PNG 파일을 사용하세요.
- 로컬 파일이 있다면 `POST /v1/files`로 업로드하고 반환된 `data.url`을 전달하세요.## 프롬프트 멘션입력마다 멘션이 있습니다.| 멘션                       | 대상               | 사용 조건                 |
| ------------------------ | ---------------- | --------------------- |
| `@image_1`, `@image_2` … | `images`, 목록 순서  | 최소한 그만큼의 이미지를 보냄      |
| `@` + 요소 이름              | 해당 `name`을 가진 요소 | 요소가 `elements`에 있는 경우 |- 대응하는 이미지가 없는 `@image_N`은 작업 생성 시 거부됩니다. 예: `the prompt names @image_2, which this request does not send`.## 이 모델이 받지 않는 필드이미지 엔드포인트는 다른 이미지 모델이 사용하는 필드도 몇 가지 알고 있습니다. 이 모델에서 그런 필드를 보내면 무시하지 않고 거부하므로, 효과 없는 설정에 비용을 내는 일이 없습니다.- `output_format`, `quality`, `seed`, `background`, `size`, `enhance_prompt` → `field "output_format" is not supported by model kling-image-v4`(보낸 필드 포함).
- 그 밖의 알 수 없는 필드 → `unknown field: <name>`.요청에 잘못된 필드가 여러 개 있어도 메시지에는 하나만 표시됩니다. 고친 뒤 다시 보내세요.## 요청 예시```bash title="cURL"
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "kling-image-v4",
  "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}'
``````python title="Python"
import os
import requests

response = requests.post(
    "https://api.beatapi.io/v1/images/tasks",
    headers={"Authorization": f"Bearer {os.environ['BEATAPI_API_KEY']}"},
    json={
      "model": "kling-image-v4",
      "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
      "aspect_ratio": "16:9",
      "resolution": "2K"
    },
    timeout=60,
)
body = response.json()
if not response.ok:
    raise RuntimeError(f"{response.status_code} {body['error']['code']}: {body['error']['message']}")
task = body["data"]
print(task["id"], task["status"])
``````javascript title="JavaScript"
const response = await fetch('https://api.beatapi.io/v1/images/tasks', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.BEATAPI_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "model": "kling-image-v4",
    "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
    "aspect_ratio": "16:9",
    "resolution": "2K"
  }),
});
const body = await response.json();
if (!response.ok) throw new Error(`${response.status} ${body.error.code}: ${body.error.message}`);
console.log(body.data.id, body.data.status);
```### 텍스트로 이미지 생성프롬프트로 2K 이미지 한 장을 생성합니다.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "kling-image-v4",
  "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}'
```### 작업 하나로 변형 4장같은 프롬프트로 4K 이미지 4장을 생성하며, 각 이미지는 4K 가격으로 과금됩니다.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "kling-image-v4",
  "prompt": "A minimalist poster of a lighthouse on a cliff at dawn, soft pastel colours, generous empty sky",
  "aspect_ratio": "3:4",
  "resolution": "4K",
  "n": 4
}'
```### 이미지 한 장 편집제품 사진을 캠페인 이미지로 재구성합니다.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "kling-image-v4",
  "prompt": "Keep the bottle in @image_1 exactly as it is. Place it on a sunlit kitchen counter with a soft reflection under it.",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "resolution": "2K"
}'
```### 여러 이미지 합성프롬프트에서 각 참조를 멘션으로 지칭합니다.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "kling-image-v4",
  "prompt": "Place the bottle from @image_1 on a neon-lit stage like the one in @image_2. Keep the bottle label readable.",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ],
  "aspect_ratio": "16:9",
  "resolution": "2K"
}'
```### 이름 있는 요소한 피사체를 여러 각도에서 찍은 이미지를 요소로 만들고 이름으로 배치합니다.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "kling-image-v4",
  "prompt": "A product shot of @Bottle on a marble bathroom shelf beside folded towels, morning light",
  "elements": [
    {
      "name": "Bottle",
      "tag": "prop",
      "element_input_urls": [
        "https://your-cdn.example.com/bottle-front.png",
        "https://your-cdn.example.com/bottle-side.png"
      ]
    }
  ],
  "aspect_ratio": "1:1",
  "resolution": "2K"
}'
```## 응답### 작업 생성(201)작업 객체입니다. 작업이 성공할 때까지 `output`는 `null`입니다. '실행 중'으로 표시된 필드는 작업이 끝나면 사라집니다.```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "kling-image-v4",
    "capability_version": 1,
    "media_type": "image",
    "model": "kling-image-v4",
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "poll_after_seconds": 5,
    "output": null,
    "usage": {
      "credits_reserved": 0.0593,
      "credits_settled": 0,
      "credits_refunded": 0,
      "credits_charged": 0.0593
    },
    "request_id": "req_5f0c2a9e4b7d4e31",
    "error_code": null,
    "error_message": null
  }
}
```| 필드                                     | 타입                | 설명                                                                            |
| -------------------------------------- | ----------------- | ----------------------------------------------------------------------------- |
| `data.id`                              | `string`          | 작업 ID: `task_` 뒤에 영문자와 숫자 32자가 붙습니다. 폴링과 웹훅 이벤트 매칭에 사용합니다.                    |
| `data.object`                          | `string`          | 항상 `task`.                                                                    |
| `data.task_kind`                       | `string`          | `image` 또는 `video`.                                                           |
| `data.capability_id`                   | `string`          | 보낸 모델 ID입니다.                                                                  |
| `data.capability_version`              | `integer`         | 모델의 계약 버전으로, 현재 `1`입니다.                                                       |
| `data.media_type`                      | `string`          | `image` 또는 `video`.                                                           |
| `data.model`                           | `string`          | 보낸 모델 ID입니다(`capability_id`와 같음).                                             |
| `data.status`                          | `string`          | `queued`, `processing`, `succeeded` 또는 `failed`. 마지막 두 개만 최종 상태입니다.           |
| `data.stage`                           | `string`          | `status`와 같은 값으로, 오래된 클라이언트를 위해 유지합니다.                                        |
| `data.created_at`                      | `integer`         | 작업 생성 시각(Unix 초)입니다.                                                          |
| `data.updated_at`                      | `integer`         | 마지막 변경 시각(Unix 초)입니다.                                                         |
| `data.completed_at`                    | `integer \| null` | 작업 완료 시각(Unix 초)입니다. 실행 중에는 `null`입니다.                                        |
| `data.poll_after_seconds`              | `integer`         | 실행 중: 다음 폴링까지 기다릴 시간입니다(이미지 5, 영상 8).                                         |
| `data.typical_seconds`                 | `object`          | 실행 중이며 최근 작업이 충분할 때: 최근 `window` 동안 `samples`개 작업의 `p50` 및 `p90` 완료 시간(초)입니다. |
| `data.output`                          | `object \| null`  | 결과입니다. `status`가 `succeeded`가 될 때까지 `null`입니다. 아래 출력 필드를 참고하세요.               |
| `data.usage.credits_reserved`          | `number`          | 작업 생성 시 잔액에서 보류한 USD 금액입니다.                                                   |
| `data.usage.credits_charged`           | `number`          | 이 작업의 비용(USD)입니다. 실패한 작업에서는 `0`입니다.                                           |
| `data.usage.credits_settled`           | `number`          | 최종 청구 금액(USD)입니다. 작업이 성공하면 설정되고, 그렇지 않으면 `0`입니다.                              |
| `data.usage.credits_refunded`          | `number`          | 잔액으로 환불된 금액(USD)입니다. 실패한 작업에서는 환불이 기록되면 보류 금액과 같아집니다.                         |
| `data.usage.billable_duration_seconds` | `integer`         | 영상만 해당: 가격 산정의 기준이 되는 초입니다. 모델이 길이를 보고하지 않으면 없습니다.                            |
| `data.request_id`                      | `string`          | 요청 ID입니다. 지원팀에 문의할 때 함께 알려 주세요.                                               |
| `data.error_code`                      | `string \| null`  | 실패 코드입니다. 작업이 실패하지 않았다면 `null`입니다.                                            |
| `data.error_message`                   | `string \| null`  | 무엇이 잘못되었고 무엇을 바꿔야 하는지 설명합니다. 작업이 실패하지 않았다면 `null`입니다.                         |### 완료된 작업`GET /v1/tasks/{task_id}`는 HTTP 200과 함께 `status: "succeeded"`, 그리고 `data.output`에 결과를 반환합니다.```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "kling-image-v4",
    "capability_version": 1,
    "media_type": "image",
    "model": "kling-image-v4",
    "status": "succeeded",
    "stage": "succeeded",
    "created_at": 1791993600,
    "updated_at": 1791993690,
    "completed_at": 1791993690,
    "output": {
      "media": [
        {
          "type": "image",
          "url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/0.png",
          "mime_type": "image/png"
        }
      ],
      "r2_url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/0.png"
    },
    "usage": {
      "credits_reserved": 0.0593,
      "credits_settled": 0.0593,
      "credits_refunded": 0,
      "credits_charged": 0.0593
    },
    "request_id": "req_5f0c2a9e4b7d4e31",
    "error_code": null,
    "error_message": null
  }
}
```#### 출력 필드| 필드                         | 타입         | 설명                                                         |
| -------------------------- | ---------- | ---------------------------------------------------------- |
| `output.media`             | `object[]` | 생성된 파일입니다. 전달된 이미지마다 한 항목이며 최대 `n`개입니다.                    |
| `output.media[].type`      | `string`   | 항상 `image`.                                                |
| `output.media[].url`       | `string`   | 저장된 이미지의 HTTPS 링크입니다. 다운로드해 보관하세요. 보관 기간은 보장되지 않습니다.       |
| `output.media[].mime_type` | `string`   | 저장된 파일 형식: 2K와 4K는 `image/png`, 8K는 `image/jpeg`입니다.       |
| `output.r2_url`            | `string`   | 오래된 클라이언트를 위해 첫 번째 미디어 URL을 한 번 더 담습니다. 대신 `media`를 사용하세요. |### 실패한 작업실패한 작업도 `GET /v1/tasks/{task_id}`에서는 HTTP 200입니다. 실패 정보는 본문에 있습니다. 보류 금액이 전액 환불되므로 과금되지 않습니다.```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "kling-image-v4",
    "capability_version": 1,
    "media_type": "image",
    "model": "kling-image-v4",
    "status": "failed",
    "stage": "failed",
    "created_at": 1791993600,
    "updated_at": 1791993690,
    "completed_at": 1791993690,
    "output": null,
    "usage": {
      "credits_reserved": 0.0593,
      "credits_settled": 0,
      "credits_refunded": 0.0593,
      "credits_charged": 0
    },
    "retryable": true,
    "request_id": "req_5f0c2a9e4b7d4e31",
    "error_code": "processing_failed",
    "error_message": "The task failed during processing on our side. Retry; a failed task is refunded."
  }
}
```| 필드                   | 타입        | 설명                                                                                                                                                                                           |
| -------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `data.error_code`    | `string`  | `bad_request`, `content_policy_violation`(요청 수정 필요) 또는 `processing_unavailable`, `processing_timeout`, `processing_failed`, `result_transfer_failed`(나중에 재시도) 중 하나입니다. [오류](/errors)를 참고하세요. |
| `data.error_message` | `string`  | 문제와 해결 방법을 설명하는 문장입니다.                                                                                                                                                                       |
| `data.retryable`     | `boolean` | 실패한 작업에만 있습니다. 같은 요청을 다시 보내면 성공할 수 있을 때 `true`입니다.                                                                                                                                           |
| `data.usage`         | `object`  | 환불이 기록되면(보통 작업이 실패하는 시점): `credits_charged`와 `credits_settled`는 `0`이고, `credits_refunded`는 `credits_reserved`와 같습니다.                                                                         |## 전체 예시작업을 만들고, 서버의 폴링 안내에 따라 기다린 뒤 결과 URL을 출력합니다. 환경 변수에 `BEATAPI_API_KEY`를 설정하고 `requests`를 설치하세요.```python
import os
import time
import uuid

import requests

API = "https://api.beatapi.io"
HEADERS = {"Authorization": f"Bearer {os.environ['BEATAPI_API_KEY']}"}


def create_task(body: dict) -> dict:
    # One Idempotency-Key per logical request: a retry with the same key cannot create a second task.
    headers = {**HEADERS, "Idempotency-Key": str(uuid.uuid4())}
    for attempt in range(3):
        response = requests.post(f"{API}/v1/images/tasks", headers=headers, json=body, timeout=60)
        if response.status_code in (429, 503) and attempt < 2:
            time.sleep(int(response.headers.get("Retry-After", 10)))
            continue
        break
    try:
        payload = response.json()
    except ValueError:  # an edge error page is not JSON
        response.raise_for_status()
        raise
    if not response.ok:
        error = payload["error"]
        raise RuntimeError(f"{response.status_code} {error['code']}: {error['message']} (request_id={error.get('request_id')})")
    return payload["data"]


def wait_for_task(task_id: str, timeout_seconds: int = 1800) -> dict:
    deadline = time.monotonic() + timeout_seconds
    while time.monotonic() < deadline:
        response = requests.get(f"{API}/v1/tasks/{task_id}", headers=HEADERS, timeout=30)
        if response.status_code == 429 or response.status_code >= 500:
            time.sleep(int(response.headers.get("Retry-After", 10)))
            continue
        response.raise_for_status()
        task = response.json()["data"]
        if task["status"] in ("succeeded", "failed"):
            return task
        time.sleep(task.get("poll_after_seconds", 5))
    raise TimeoutError(f"task {task_id} is still running; keep polling later")


task = create_task({
  "model": "kling-image-v4",
  "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
  "aspect_ratio": "16:9",
  "resolution": "2K"
})
print("created", task["id"])
task = wait_for_task(task["id"])
if task["status"] == "failed":
    raise SystemExit(f"{task['error_code']}: {task['error_message']}")
for item in task["output"]["media"]:
    print(item["url"])
```## 과금- 각 이미지는 `resolution`(아래 표)에 따라 가격이 정해지고 `n`을 곱합니다. `images`의 각 링크와 `elements`의 각 요소는 작업당 한 번씩 고정 요금이 더해집니다.
- 가격은 작업 생성 시 잔액에서, 키에 한도가 있다면 키 한도에서도 보류됩니다. 작업이 생기기 전에 거부된 요청은 비용이 들지 않습니다.
- 성공한 작업은 전달된 이미지 수만큼 과금됩니다. 실패한 작업은 예약액을 전액 반환합니다. 이때 `credits_refunded`는 `credits_reserved`와 같고, `credits_charged`와 `credits_settled`는 0입니다.현재 정가이며 [가격](https://beatapi.io/pricing) 페이지와 같습니다. 별도 할인 계약이 있는 계정은 더 적게 지불하며, 실제 청구 금액은 항상 작업의 `data.usage`에서 확인할 수 있습니다.| 옵션                                            | 정가(USD)  |
| --------------------------------------------- | -------- |
| 이미지 1장 · 2K                                   | \$0.0593 |
| 이미지 1장 · 4K                                   | \$0.0893 |
| 이미지 1장 · 8K                                   | \$0.1486 |
| `images`의 각 참조 이미지와 `elements`의 각 요소, 작업당 한 번 | \$0.0026 |## 자주 발생하는 오류| 오류 또는 증상                                                                  | 원인                                                                                                | 해결 방법                                                              |
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| 400 `"resolution" must be one of: [2K 4K 8K]`                             | `1K`, 소문자 `2k` 또는 `2048x2048` 같은 픽셀 크기.                                                           | `2K`, `4K`, `8K` 중 하나를 보내거나 필드를 생략하세요.                             |
| 400 `"n" is outside its supported range`                                  | `n`이 9보다 크거나 1보다 작거나, 소수 또는 문자열인 경우.                                                              | 1\~9의 정수를 보내세요. 더 많은 이미지가 필요하면 작업을 하나 더 만드세요.                      |
| 400 `Kling Image 4.0 takes at most 10 images and elements together`       | `images`와 `elements` 항목이 합계 10개를 넘는 경우.                                                           | 합계 10개 이내로 보내세요. 한 피사체의 여러 이미지는 요소 하나로 묶을 수 있습니다.                  |
| 400 `the prompt names @image_3, which this request does not send`         | `images`의 마지막 링크보다 큰 번호의 멘션.                                                                      | 목록 순서대로 `@image_1`부터 번호를 매기거나, 빠진 이미지를 추가하세요.                      |
| 400 `elements[0].name "image_1" is not a name Kling V4 accepts`           | 예약된 이름이거나 공백, 하이픈 등 기호가 들어간 이름.                                                                   | `Bottle`처럼 영문자, 숫자, 밑줄 또는 한자 1\~20자를 사용하세요.                        |
| 400 `"images[0]" is not a PNG or JPEG image: the URL returned image/webp` | WebP, GIF, HEIC 파일이거나 웹 페이지를 반환하는 링크.                                                             | 파일을 JPEG 또는 PNG로 변환하거나, `POST /v1/files`로 업로드하고 `data.url`을 사용하세요. |
| 400 `field "output_format" is not supported by model kling-image-v4`      | 다른 이미지 모델의 필드(`output_format`, `seed`, `quality`, `size`, `background`, `enhance_prompt`)를 보냈습니다. | 해당 필드를 삭제하세요.                                                      |
| 작업이 `content_policy_violation`과 함께 `failed`                               | 프롬프트, 참조 이미지 또는 생성된 이미지가 콘텐츠 검수에서 거부되었습니다.                                                        | 프롬프트나 이미지를 바꾸세요. 그대로 재시도하면 다시 실패하며, 과금되지 않습니다.                     |
| 작업이 `processing_timeout`과 함께 `failed`                                     | 처리 시간 안에 이미지가 완성되지 않았습니다.                                                                         | 재시도하세요. 실패한 작업은 환불되었습니다.                                           |
| 한 번도 충전하지 않은 계정에서 403 `forbidden`                                         | 무료 크레딧은 일부 모델에서만 사용할 수 있습니다.                                                                      | 한 번 충전하거나, 무료 크레딧으로 사용할 수 있는 모델을 사용하세요.                            |## HTTP 오류 요약작업이 생성되기 전의 오류는 2xx가 아닌 응답으로 오며 과금되지 않습니다. `error.code` 또는 `error.retryable`로 분기하세요. `message`에 문제가 표시됩니다. 전체 목록과 재시도 정책은 [오류](/errors)에 있습니다.```json
{
  "error": {
    "code": "bad_request",
    "message": "\"prompt\" is required",
    "retryable": false,
    "request_id": "req_5f0c2a9e4b7d4e31"
  }
}
```| HTTP 상태 | `error.code`                                                                                  | 조치                                                                     |
| ------- | --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| 400     | `bad_request`, `content_policy_violation`                                                     | 요청을 수정하세요. 메시지에 해당 필드가 표시됩니다. 그대로 재시도하지 마세요.                           |
| 401     | `missing_api_key`, `invalid_api_key`(오래된 클라이언트에서는 `unauthorized`가 보일 수 있음)                    | 유효한 키를 `Authorization: Bearer <key>`로 보내세요.                            |
| 402     | `insufficient_credits`                                                                        | 충전하거나 키 한도를 올린 뒤 다시 보내세요.                                              |
| 403     | `forbidden`                                                                                   | 이 키나 계정으로는 이 모델을 사용할 수 없습니다(예: 무료 크레딧은 일부 모델만 지원). 그대로 재시도하지 마세요.      |
| 404     | `not_found`                                                                                   | `GET /v1/tasks/{task_id}`에서: 이 키의 계정에 해당 작업이 없습니다. ID를 확인하세요.          |
| 409     | `idempotency_conflict`                                                                        | 새 `Idempotency-Key`를 사용하거나, 이 키를 쓴 첫 요청이 끝날 때까지 기다리세요.                 |
| 429     | `rate_limit_exceeded`                                                                         | `Retry-After`에 표시된 시간(또는 `error.retry_after_seconds`초)만큼 기다린 뒤 재시도하세요. |
| 500     | `internal_error`                                                                              | 백오프를 적용해 재시도하고, 계속되면 `request_id`와 함께 지원팀에 문의하세요.                      |
| 503     | `processing_unavailable`, `processing_timeout`, `processing_failed`, `result_transfer_failed` | 과금되지 않았습니다. 지수 백오프를 적용해 재시도하세요.                                        |

Reference: https://docs.beatapi.io/api-reference/image-api/kling-image-v4

## Authentication

- `Authorization` header (bearer token, required) — API 키를 `Authorization: Bearer <BEATAPI_API_KEY>`로 보내세요.

## Servers

- `https://api.beatapi.io` (Direct, default)
- `https://api.beatapi.io` (API)

## Request

### Headers

- `Idempotency-Key` (string, optional) — 본문은 `Content-Type: application/json`과 함께 JSON으로 보냅니다. `Idempotency-Key`는 선택 사항입니다. 논리적 요청마다 고유한 값(최대 255자)을 보내고, 완전히 같은 본문을 재시도할 때만 다시 사용하세요. 24시간 안에 같은 키와 본문으로 재시도하면 첫 응답을 `Idempotent-Replayed: true`와 함께 다시 반환하고, 같은 키에 다른 본문을 보내면 `409 idempotency_conflict`를 반환합니다. 2xx 이외의 응답은 저장되지 않으므로 400이나 402 이후의 재시도는 다시 실행됩니다.

### Body (application/json)

This endpoint expects a KlingImageV4Request.

- `model` (enum, required) — 실행할 모델입니다. **값**: `kling-image-v4` **값이 잘못된 경우** - 누락: `"model" is required` - 알 수 없는 모델 ID: `"model" kling-image-v9 is not catalogued` - 이 엔드포인트로 영상 모델을 보낸 경우: `"model" kling-v4 is served by POST /v1/videos/tasks, not this endpoint`
  - Allowed values: `kling-image-v4`
- `prompt` (string, required) — 그릴 내용 또는 참조 이미지에서 바꿀 내용입니다. 피사체, 스타일, 조명, 구도, 이미지에 들어가야 할 문구를 쓰고, 각 입력을 `@` 멘션으로 지칭합니다. **길이**: 1–20000자 - 길이는 문자 수로 계산합니다(한중일 문자 하나는 1자). - 멘션: `images`는 목록 순서대로 `@image_1`, `@image_2` …이며, 요소는 `@` 뒤에 `name`을 붙입니다. - 모든 `@image_N`은 같은 요청의 이미지를 가리켜야 합니다. 이미지가 두 장인데 `@image_3`을 쓰면 작업 생성 시 거부됩니다. **값이 잘못된 경우** - 누락: `"prompt" is required` - 비어 있거나 한도보다 긴 경우: `"prompt" has an unsupported length` - 요청에 없는 이미지를 멘션함: `the prompt names @image_3, which this request does not send`
- `aspect_ratio` (enum, optional, default: auto) — 이미지의 형태(너비:높이)입니다. **허용 값**: `auto`, `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `3:2`, `2:3`, `21:9` **기본값**: `auto` - 생략하면 `auto`가 사용되며, 모델이 프롬프트와 입력 이미지를 보고 프레임을 정합니다. 형태가 중요하면 비율을 지정하세요. **값이 잘못된 경우** - 목록에 없는 값: `"aspect_ratio" must be one of: [auto 1:1 16:9 9:16 4:3 3:4 3:2 2:3 21:9]`
  - Allowed values: `auto`, `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `3:2`, `2:3`, `21:9`
- `elements` (list of KlingImageV4RequestElementsItems, optional) — 캐릭터, 동물, 소품, 의상, 장면 같은 이름 있는 피사체입니다. 각각 2\~4장의 이미지로 보여 주며, 프롬프트에서는 `@` 뒤에 `name`을 붙여 지칭합니다. **항목 수**: 10개 이하 * 객체 배열입니다. 각 객체는 다음 키만 받습니다. * `elements[].name`(string, 필수): 영문자, 숫자, 밑줄 또는 한자 1\~20자이며, 요청 안에서 대소문자 구분 없이 고유해야 합니다. `image_N`, `video_N`, `voice_N`, `keyframe_N`, `object_N`, `audio_N`, `first_frame`, `last_frame`은 쓸 수 없습니다. * `elements[].element_input_urls`(문자열 배열, 필수): 요소 이미지를 가리키는 공개 HTTPS 링크 2\~4개이며, 첫 번째가 메인 뷰입니다. * `elements[].tag`(문자열, 선택): 요소의 종류입니다. * `elements[].description`(string, 선택): 요소에 대한 설명, 최대 100자. * 요소는 이미지로만 구성됩니다. 이 모델은 영상 요소와 음성 요소를 받지 않습니다. * `images`와 `elements`는 합계 최대 10개입니다. 요소마다 포함한 이미지 수와 관계없이 작업에 고정 요금이 더해집니다. **값이 잘못된 경우** * 요소가 10개 초과: `"elements" accepts at most 10 items` * 객체가 아닌 요소: `"elements[0]" must be an object` * `name`이 없는 요소: `"name" is required in "elements[0]"` * `element_input_urls`가 없는 요소: `"element_input_urls" is required in "elements[0]"` * 비어 있거나 20자보다 긴 `name`: `"elements[0].name" has an unsupported length` * 다른 문자가 들어 있거나 예약된 이름인 `name`: `elements[0].name "image_1" is not a name Kling V4 accepts` * 대소문자를 무시하면 같은 `name`이 두 번: `elements[1].name "Hero" is used twice` * 이미지가 두 장 미만: `"elements[0].element_input_urls" requires at least 2 item` * 이미지가 네 장 초과: `"elements[0].element_input_urls" accepts at most 4 items` * 목록에 없는 `tag`: `"elements[0].tag" must be one of: [character animal prop costume scene effect others]` * 100자보다 긴 `description`: `"elements[0].description" has an unsupported length` * 요소가 받지 않는 키(예: 영상): `field "element_input_video_urls" is not supported in "elements[0]"` **예시** ```json "elements": [ { "name": "Bottle", "tag": "prop", "description": "A matte smart water bottle", "element_input_urls": [ "https://your-cdn.example.com/bottle-front.png", "https://your-cdn.example.com/bottle-side.png" ] } ] ```
- `images` (list of string, optional) — 편집하거나 합성할 참조 이미지입니다. 프롬프트에서는 목록 순서대로 `@image_1`, `@image_2` …로 지칭합니다. **항목 수**: 1–10 각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요. - 각 항목은 JPEG 또는 PNG 파일을 가리키는 공개 `https://` 링크여야 합니다. 작업을 생성할 때 BeatAPI는 각 링크를 읽고, 그런 이미지가 아니거나 아래 제한을 벗어나는 링크를 위치와 함께 거부합니다(`images[0]`이 첫 번째 링크). - `images`와 `elements`는 합계 최대 10개입니다. - 링크마다 작업에 고정 요금이 추가됩니다(가격 참고). **값이 잘못된 경우** - 최대 개수를 넘은 경우: `"images" accepts at most 10 items` - 빈 배열: `"images" requires at least 1 item` - https:// 링크가 아닌 경우: `"images[0]" must be a public HTTPS URL` - JPEG 또는 PNG 파일이 아닌 링크(이 예에서는 WebP): `"images[0]" is not a PNG or JPEG image: the URL returned image/webp` - 오류로 응답하는 링크: `"images[0]" could not be downloaded: the URL returned HTTP 404` - 이미지와 요소가 합계 10개 초과: `Kling Image 4.0 takes at most 10 images and elements together` **예시** ```json "images": [ "https://cdn.beatapi.io/samples/smart-bottle.png", "https://cdn.beatapi.io/samples/neon-singer.png" ] ```
- `n` (integer, optional, default: 1) — 이 작업에서 생성할 이미지 수입니다. 모든 이미지에 같은 프롬프트, 입력, 비율, 등급이 사용됩니다. **기본값**: `1` **범위**: 1–9 - 생략하면 `1`이 사용됩니다. - 각 이미지는 `resolution` 가격으로 과금되므로 `n`은 이미지 부분의 가격을 배로 늘립니다. 참조 이미지와 요소 요금은 이미지마다가 아니라 작업당 한 번만 계산됩니다. - 이미지는 전달된 수만큼 과금됩니다. **값이 잘못된 경우** - 범위 밖, 정수가 아님, 또는 문자열로 보낸 경우: `"n" is outside its supported range`
- `resolution` (enum, optional, default: 2K) — 이미지의 크기 등급: `2K`, `4K` 또는 `8K`. 등급마다 이미지당 가격이 다릅니다. **허용 값**: `2K`, `4K`, `8K` **기본값**: `2K` - 생략하면 `2K`가 사용되어 과금됩니다. - 2K와 4K 이미지는 PNG로, 8K 이미지는 JPEG으로 반환됩니다. - K는 대문자로 쓰세요. `2k`는 거부됩니다. 1K 등급은 없으며 `2048x2048` 같은 픽셀 크기도 받지 않습니다. **값이 잘못된 경우** - 목록에 없는 값(예: `1K` 또는 `2k`): `"resolution" must be one of: [2K 4K 8K]`
  - Allowed values: `2K`, `4K`, `8K`

## Response

### 201

작업 객체입니다. 작업이 성공할 때까지 `output`는 `null`입니다. '실행 중'으로 표시된 필드는 작업이 끝나면 사라집니다.

- `map from string to any`

## Errors

### 400 Bad Request Error

`bad_request`, `content_policy_violation` 요청을 수정하세요. 메시지에 해당 필드가 표시됩니다. 그대로 재시도하지 마세요.

- `map from string to any`

### 401 Unauthorized Error

`missing_api_key`, `invalid_api_key`(오래된 클라이언트에서는 `unauthorized`가 보일 수 있음) 유효한 키를 `Authorization: Bearer <key>`로 보내세요.

- `map from string to any`

### 402 Payment Required Error

`insufficient_credits` 충전하거나 키 한도를 올린 뒤 다시 보내세요.

- `map from string to any`

### 403 Forbidden Error

`forbidden` 이 키나 계정으로는 이 모델을 사용할 수 없습니다(예: 무료 크레딧은 일부 모델만 지원). 그대로 재시도하지 마세요.

- `map from string to any`

### 409 Conflict Error

`idempotency_conflict` 새 `Idempotency-Key`를 사용하거나, 이 키를 쓴 첫 요청이 끝날 때까지 기다리세요.

- `map from string to any`

### 429 Too Many Requests Error

`rate_limit_exceeded` `Retry-After`에 표시된 시간(또는 `error.retry_after_seconds`초)만큼 기다린 뒤 재시도하세요.

- `map from string to any`

### 500 Internal Server Error

`internal_error` 백오프를 적용해 재시도하고, 계속되면 `request_id`와 함께 지원팀에 문의하세요.

- `map from string to any`

### 503 Service Unavailable Error

`processing_unavailable`, `processing_timeout`, `processing_failed`, `result_transfer_failed` 과금되지 않았습니다. 지수 백오프를 적용해 재시도하세요.

- `map from string to any`

## Types

### KlingImageV4RequestElementsItems

- `element_input_urls` (list of string, required) — `elements[].element_input_urls`(문자열 배열, 필수): 요소 이미지를 가리키는 공개 HTTPS 링크 2~4개이며, 첫 번째가 메인 뷰입니다. **항목 수**: 2–4 각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요.
- `name` (string, required) — `elements[].name`(string, 필수): 영문자, 숫자, 밑줄 또는 한자 1~20자이며, 요청 안에서 대소문자 구분 없이 고유해야 합니다. `image_N`, `video_N`, `voice_N`, `keyframe_N`, `object_N`, `audio_N`, `first_frame`, `last_frame`은 쓸 수 없습니다. **길이**: 1–20자
- `description` (string, optional) — `elements[].description`(string, 선택): 요소에 대한 설명, 최대 100자. **길이**: 100자 이하
- `tag` (enum, optional) — `elements[].tag`(문자열, 선택): 요소의 종류입니다. **허용 값**: `character`, `animal`, `prop`, `costume`, `scene`, `effect`, `others`
  - Allowed values: `character`, `animal`, `prop`, `costume`, `scene`, `effect`, `others`

## Examples

### 텍스트로 이미지 생성

**Request**

```json
{
  "model": "kling-image-v4",
  "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}
```

**Response**

```json
{
  "data": {
    "capability_id": "kling-image-v4",
    "capability_version": 1,
    "completed_at": null,
    "created_at": 1791993600,
    "error_code": null,
    "error_message": null,
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "media_type": "image",
    "model": "kling-image-v4",
    "object": "task",
    "output": null,
    "poll_after_seconds": 5,
    "request_id": "req_5f0c2a9e4b7d4e31",
    "stage": "queued",
    "status": "queued",
    "task_kind": "image",
    "updated_at": 1791993600,
    "usage": {
      "credits_charged": 0.0593,
      "credits_refunded": 0,
      "credits_reserved": 0.0593,
      "credits_settled": 0
    }
  }
}
```

**SDK Code**

```python 텍스트로 이미지 생성
import requests

url = "https://api.beatapi.io/v1/images/tasks"

payload = {
    "model": "kling-image-v4",
    "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
    "aspect_ratio": "16:9",
    "resolution": "2K"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript 텍스트로 이미지 생성
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"kling-image-v4","prompt":"A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement","aspect_ratio":"16:9","resolution":"2K"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go 텍스트로 이미지 생성
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beatapi.io/v1/images/tasks"

	payload := strings.NewReader("{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement\",\n  \"aspect_ratio\": \"16:9\",\n  \"resolution\": \"2K\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby 텍스트로 이미지 생성
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/images/tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement\",\n  \"aspect_ratio\": \"16:9\",\n  \"resolution\": \"2K\"\n}"

response = http.request(request)
puts response.read_body
```

```java 텍스트로 이미지 생성
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/images/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement\",\n  \"aspect_ratio\": \"16:9\",\n  \"resolution\": \"2K\"\n}")
  .asString();
```

```php 텍스트로 이미지 생성
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "kling-image-v4",
  "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp 텍스트로 이미지 생성
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/images/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement\",\n  \"aspect_ratio\": \"16:9\",\n  \"resolution\": \"2K\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 텍스트로 이미지 생성
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "kling-image-v4",
  "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
  "aspect_ratio": "16:9",
  "resolution": "2K"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/images/tasks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### 작업 하나로 변형 4장

**Request**

```json
{
  "model": "kling-image-v4",
  "prompt": "A minimalist poster of a lighthouse on a cliff at dawn, soft pastel colours, generous empty sky",
  "aspect_ratio": "3:4",
  "n": 4,
  "resolution": "4K"
}
```

**Response**

```json
{
  "data": {
    "capability_id": "kling-image-v4",
    "capability_version": 1,
    "completed_at": null,
    "created_at": 1791993600,
    "error_code": null,
    "error_message": null,
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "media_type": "image",
    "model": "kling-image-v4",
    "object": "task",
    "output": null,
    "poll_after_seconds": 5,
    "request_id": "req_5f0c2a9e4b7d4e31",
    "stage": "queued",
    "status": "queued",
    "task_kind": "image",
    "updated_at": 1791993600
  }
}
```

**SDK Code**

```python 작업 하나로 변형 4장
import requests

url = "https://api.beatapi.io/v1/images/tasks"

payload = {
    "model": "kling-image-v4",
    "prompt": "A minimalist poster of a lighthouse on a cliff at dawn, soft pastel colours, generous empty sky",
    "aspect_ratio": "3:4",
    "n": 4,
    "resolution": "4K"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript 작업 하나로 변형 4장
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"kling-image-v4","prompt":"A minimalist poster of a lighthouse on a cliff at dawn, soft pastel colours, generous empty sky","aspect_ratio":"3:4","n":4,"resolution":"4K"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go 작업 하나로 변형 4장
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beatapi.io/v1/images/tasks"

	payload := strings.NewReader("{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"A minimalist poster of a lighthouse on a cliff at dawn, soft pastel colours, generous empty sky\",\n  \"aspect_ratio\": \"3:4\",\n  \"n\": 4,\n  \"resolution\": \"4K\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby 작업 하나로 변형 4장
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/images/tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"A minimalist poster of a lighthouse on a cliff at dawn, soft pastel colours, generous empty sky\",\n  \"aspect_ratio\": \"3:4\",\n  \"n\": 4,\n  \"resolution\": \"4K\"\n}"

response = http.request(request)
puts response.read_body
```

```java 작업 하나로 변형 4장
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/images/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"A minimalist poster of a lighthouse on a cliff at dawn, soft pastel colours, generous empty sky\",\n  \"aspect_ratio\": \"3:4\",\n  \"n\": 4,\n  \"resolution\": \"4K\"\n}")
  .asString();
```

```php 작업 하나로 변형 4장
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "kling-image-v4",
  "prompt": "A minimalist poster of a lighthouse on a cliff at dawn, soft pastel colours, generous empty sky",
  "aspect_ratio": "3:4",
  "n": 4,
  "resolution": "4K"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp 작업 하나로 변형 4장
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/images/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"A minimalist poster of a lighthouse on a cliff at dawn, soft pastel colours, generous empty sky\",\n  \"aspect_ratio\": \"3:4\",\n  \"n\": 4,\n  \"resolution\": \"4K\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 작업 하나로 변형 4장
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "kling-image-v4",
  "prompt": "A minimalist poster of a lighthouse on a cliff at dawn, soft pastel colours, generous empty sky",
  "aspect_ratio": "3:4",
  "n": 4,
  "resolution": "4K"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/images/tasks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### 이미지 한 장 편집

**Request**

```json
{
  "model": "kling-image-v4",
  "prompt": "Keep the bottle in @image_1 exactly as it is. Place it on a sunlit kitchen counter with a soft reflection under it.",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "resolution": "2K"
}
```

**Response**

```json
{
  "data": {
    "capability_id": "kling-image-v4",
    "capability_version": 1,
    "completed_at": null,
    "created_at": 1791993600,
    "error_code": null,
    "error_message": null,
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "media_type": "image",
    "model": "kling-image-v4",
    "object": "task",
    "output": null,
    "poll_after_seconds": 5,
    "request_id": "req_5f0c2a9e4b7d4e31",
    "stage": "queued",
    "status": "queued",
    "task_kind": "image",
    "updated_at": 1791993600
  }
}
```

**SDK Code**

```python 이미지 한 장 편집
import requests

url = "https://api.beatapi.io/v1/images/tasks"

payload = {
    "model": "kling-image-v4",
    "prompt": "Keep the bottle in @image_1 exactly as it is. Place it on a sunlit kitchen counter with a soft reflection under it.",
    "images": ["https://cdn.beatapi.io/samples/smart-bottle.png"],
    "resolution": "2K"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript 이미지 한 장 편집
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"kling-image-v4","prompt":"Keep the bottle in @image_1 exactly as it is. Place it on a sunlit kitchen counter with a soft reflection under it.","images":["https://cdn.beatapi.io/samples/smart-bottle.png"],"resolution":"2K"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go 이미지 한 장 편집
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beatapi.io/v1/images/tasks"

	payload := strings.NewReader("{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"Keep the bottle in @image_1 exactly as it is. Place it on a sunlit kitchen counter with a soft reflection under it.\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"resolution\": \"2K\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby 이미지 한 장 편집
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/images/tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"Keep the bottle in @image_1 exactly as it is. Place it on a sunlit kitchen counter with a soft reflection under it.\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"resolution\": \"2K\"\n}"

response = http.request(request)
puts response.read_body
```

```java 이미지 한 장 편집
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/images/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"Keep the bottle in @image_1 exactly as it is. Place it on a sunlit kitchen counter with a soft reflection under it.\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"resolution\": \"2K\"\n}")
  .asString();
```

```php 이미지 한 장 편집
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "kling-image-v4",
  "prompt": "Keep the bottle in @image_1 exactly as it is. Place it on a sunlit kitchen counter with a soft reflection under it.",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "resolution": "2K"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp 이미지 한 장 편집
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/images/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"Keep the bottle in @image_1 exactly as it is. Place it on a sunlit kitchen counter with a soft reflection under it.\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"resolution\": \"2K\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 이미지 한 장 편집
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "kling-image-v4",
  "prompt": "Keep the bottle in @image_1 exactly as it is. Place it on a sunlit kitchen counter with a soft reflection under it.",
  "images": ["https://cdn.beatapi.io/samples/smart-bottle.png"],
  "resolution": "2K"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/images/tasks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### 여러 이미지 합성

**Request**

```json
{
  "model": "kling-image-v4",
  "prompt": "Place the bottle from @image_1 on a neon-lit stage like the one in @image_2. Keep the bottle label readable.",
  "aspect_ratio": "16:9",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ],
  "resolution": "2K"
}
```

**Response**

```json
{
  "data": {
    "capability_id": "kling-image-v4",
    "capability_version": 1,
    "completed_at": null,
    "created_at": 1791993600,
    "error_code": null,
    "error_message": null,
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "media_type": "image",
    "model": "kling-image-v4",
    "object": "task",
    "output": null,
    "poll_after_seconds": 5,
    "request_id": "req_5f0c2a9e4b7d4e31",
    "stage": "queued",
    "status": "queued",
    "task_kind": "image",
    "updated_at": 1791993600
  }
}
```

**SDK Code**

```python 여러 이미지 합성
import requests

url = "https://api.beatapi.io/v1/images/tasks"

payload = {
    "model": "kling-image-v4",
    "prompt": "Place the bottle from @image_1 on a neon-lit stage like the one in @image_2. Keep the bottle label readable.",
    "aspect_ratio": "16:9",
    "images": ["https://cdn.beatapi.io/samples/smart-bottle.png", "https://cdn.beatapi.io/samples/neon-singer.png"],
    "resolution": "2K"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript 여러 이미지 합성
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"kling-image-v4","prompt":"Place the bottle from @image_1 on a neon-lit stage like the one in @image_2. Keep the bottle label readable.","aspect_ratio":"16:9","images":["https://cdn.beatapi.io/samples/smart-bottle.png","https://cdn.beatapi.io/samples/neon-singer.png"],"resolution":"2K"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go 여러 이미지 합성
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beatapi.io/v1/images/tasks"

	payload := strings.NewReader("{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"Place the bottle from @image_1 on a neon-lit stage like the one in @image_2. Keep the bottle label readable.\",\n  \"aspect_ratio\": \"16:9\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ],\n  \"resolution\": \"2K\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby 여러 이미지 합성
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/images/tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"Place the bottle from @image_1 on a neon-lit stage like the one in @image_2. Keep the bottle label readable.\",\n  \"aspect_ratio\": \"16:9\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ],\n  \"resolution\": \"2K\"\n}"

response = http.request(request)
puts response.read_body
```

```java 여러 이미지 합성
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/images/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"Place the bottle from @image_1 on a neon-lit stage like the one in @image_2. Keep the bottle label readable.\",\n  \"aspect_ratio\": \"16:9\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ],\n  \"resolution\": \"2K\"\n}")
  .asString();
```

```php 여러 이미지 합성
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "kling-image-v4",
  "prompt": "Place the bottle from @image_1 on a neon-lit stage like the one in @image_2. Keep the bottle label readable.",
  "aspect_ratio": "16:9",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ],
  "resolution": "2K"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp 여러 이미지 합성
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/images/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"Place the bottle from @image_1 on a neon-lit stage like the one in @image_2. Keep the bottle label readable.\",\n  \"aspect_ratio\": \"16:9\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ],\n  \"resolution\": \"2K\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 여러 이미지 합성
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "kling-image-v4",
  "prompt": "Place the bottle from @image_1 on a neon-lit stage like the one in @image_2. Keep the bottle label readable.",
  "aspect_ratio": "16:9",
  "images": ["https://cdn.beatapi.io/samples/smart-bottle.png", "https://cdn.beatapi.io/samples/neon-singer.png"],
  "resolution": "2K"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/images/tasks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### 이름 있는 요소

**Request**

```json
{
  "model": "kling-image-v4",
  "prompt": "A product shot of @Bottle on a marble bathroom shelf beside folded towels, morning light",
  "aspect_ratio": "1:1",
  "elements": [
    {
      "element_input_urls": [
        "https://your-cdn.example.com/bottle-front.png",
        "https://your-cdn.example.com/bottle-side.png"
      ],
      "name": "Bottle",
      "tag": "prop"
    }
  ],
  "resolution": "2K"
}
```

**Response**

```json
{
  "data": {
    "capability_id": "kling-image-v4",
    "capability_version": 1,
    "completed_at": null,
    "created_at": 1791993600,
    "error_code": null,
    "error_message": null,
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "media_type": "image",
    "model": "kling-image-v4",
    "object": "task",
    "output": null,
    "poll_after_seconds": 5,
    "request_id": "req_5f0c2a9e4b7d4e31",
    "stage": "queued",
    "status": "queued",
    "task_kind": "image",
    "updated_at": 1791993600
  }
}
```

**SDK Code**

```python 이름 있는 요소
import requests

url = "https://api.beatapi.io/v1/images/tasks"

payload = {
    "model": "kling-image-v4",
    "prompt": "A product shot of @Bottle on a marble bathroom shelf beside folded towels, morning light",
    "aspect_ratio": "1:1",
    "elements": [
        {
            "element_input_urls": ["https://your-cdn.example.com/bottle-front.png", "https://your-cdn.example.com/bottle-side.png"],
            "name": "Bottle",
            "tag": "prop"
        }
    ],
    "resolution": "2K"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript 이름 있는 요소
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"kling-image-v4","prompt":"A product shot of @Bottle on a marble bathroom shelf beside folded towels, morning light","aspect_ratio":"1:1","elements":[{"element_input_urls":["https://your-cdn.example.com/bottle-front.png","https://your-cdn.example.com/bottle-side.png"],"name":"Bottle","tag":"prop"}],"resolution":"2K"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go 이름 있는 요소
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.beatapi.io/v1/images/tasks"

	payload := strings.NewReader("{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"A product shot of @Bottle on a marble bathroom shelf beside folded towels, morning light\",\n  \"aspect_ratio\": \"1:1\",\n  \"elements\": [\n    {\n      \"element_input_urls\": [\n        \"https://your-cdn.example.com/bottle-front.png\",\n        \"https://your-cdn.example.com/bottle-side.png\"\n      ],\n      \"name\": \"Bottle\",\n      \"tag\": \"prop\"\n    }\n  ],\n  \"resolution\": \"2K\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby 이름 있는 요소
require 'uri'
require 'net/http'

url = URI("https://api.beatapi.io/v1/images/tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"A product shot of @Bottle on a marble bathroom shelf beside folded towels, morning light\",\n  \"aspect_ratio\": \"1:1\",\n  \"elements\": [\n    {\n      \"element_input_urls\": [\n        \"https://your-cdn.example.com/bottle-front.png\",\n        \"https://your-cdn.example.com/bottle-side.png\"\n      ],\n      \"name\": \"Bottle\",\n      \"tag\": \"prop\"\n    }\n  ],\n  \"resolution\": \"2K\"\n}"

response = http.request(request)
puts response.read_body
```

```java 이름 있는 요소
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/images/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"A product shot of @Bottle on a marble bathroom shelf beside folded towels, morning light\",\n  \"aspect_ratio\": \"1:1\",\n  \"elements\": [\n    {\n      \"element_input_urls\": [\n        \"https://your-cdn.example.com/bottle-front.png\",\n        \"https://your-cdn.example.com/bottle-side.png\"\n      ],\n      \"name\": \"Bottle\",\n      \"tag\": \"prop\"\n    }\n  ],\n  \"resolution\": \"2K\"\n}")
  .asString();
```

```php 이름 있는 요소
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "kling-image-v4",
  "prompt": "A product shot of @Bottle on a marble bathroom shelf beside folded towels, morning light",
  "aspect_ratio": "1:1",
  "elements": [
    {
      "element_input_urls": [
        "https://your-cdn.example.com/bottle-front.png",
        "https://your-cdn.example.com/bottle-side.png"
      ],
      "name": "Bottle",
      "tag": "prop"
    }
  ],
  "resolution": "2K"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp 이름 있는 요소
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/images/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"kling-image-v4\",\n  \"prompt\": \"A product shot of @Bottle on a marble bathroom shelf beside folded towels, morning light\",\n  \"aspect_ratio\": \"1:1\",\n  \"elements\": [\n    {\n      \"element_input_urls\": [\n        \"https://your-cdn.example.com/bottle-front.png\",\n        \"https://your-cdn.example.com/bottle-side.png\"\n      ],\n      \"name\": \"Bottle\",\n      \"tag\": \"prop\"\n    }\n  ],\n  \"resolution\": \"2K\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 이름 있는 요소
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "kling-image-v4",
  "prompt": "A product shot of @Bottle on a marble bathroom shelf beside folded towels, morning light",
  "aspect_ratio": "1:1",
  "elements": [
    [
      "element_input_urls": ["https://your-cdn.example.com/bottle-front.png", "https://your-cdn.example.com/bottle-side.png"],
      "name": "Bottle",
      "tag": "prop"
    ]
  ],
  "resolution": "2K"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/images/tasks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```