> 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 4.0

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

텍스트, 시간순 프레임, 또는 참조 이미지·영상·음성과 이름 있는 요소로 생성 오디오가 포함된 720p 또는 1080p의 3\~30초 영상을 생성합니다. 초 단위로 과금됩니다.- 비동기: 생성 호출은 작업 ID를 반환하며, 작업이 성공하면 영상이 준비됩니다.
- 네 가지 입력 방식: 텍스트만, 프레임(시간순 `images`), 참조 이미지·영상·음성, 이름 있는 `elements` 최대 7개. 프레임은 참조나 요소와 함께 쓸 수 없습니다.
- 프롬프트에서 모든 입력을 지칭하세요: `@image_1`, `@video_1`, `@voice_1`, `@` + 요소 이름, `@first_frame`, `@keyframe_1`, `@last_frame`. 모든 `@`는 같은 요청의 입력을 가리켜야 합니다.
- 오디오는 항상 생성됩니다. `keep_original_sound`를 쓰면 대신 참조 영상의 원래 소리를 유지합니다.
- `duration`은 3\~30초(기본값 5)이며, `720p`(기본값) 또는 `1080p`로 렌더링합니다. 선택한 해상도에서 초 단위로 과금되며, 실패한 작업은 비용이 들지 않습니다.POST/v1/videos/tasks실행해 보기API Explorer에서 이 모델을 엽니다. BeatAPI API 키를 입력해 작업을 만드세요. 실제 호출이며 본인 잔액에서 과금됩니다.## 모델 IDKling 생성 모델 두 개가 이 엔드포인트를 함께 씁니다. 아래 값은 게이트웨이 계약에서 그대로 가져왔으며, 참조 입력, 세 장 이상의 프레임, 최대 7개의 요소는 Kling 4.0만 받습니다.| 모델 ID          | `duration` (s) | `resolution`    | 최대 프레임 수 | 최대 참조 이미지 수 | 최대 요소 수 | 이럴 때 선택하세요                                           |
| -------------- | -------------- | --------------- | -------- | ----------- | ------- | ---------------------------------------------------- |
| **`kling-v4`** | 3–30           | `720p`, `1080p` | 10       | 10          | 7       | 최대 30초, 참조 이미지·영상·음성, 중간 프레임, 또는 요소가 3개보다 많이 필요한 경우. |
| `kling-v3`     | 3–15           | `std`, `pro`    | 2        | —           | 3       | 멀티샷 스토리보드, 소리 없는 영상, 또는 더 낮은 초당 가격이 필요한 경우.          |## 엔드포인트와 인증`POST https://api.beatapi.io/v1/videos/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`                                                                                     | 미디어를 보내지 않습니다. `aspect_ratio`가 없으면 영상은 16:9입니다.                       |
| 첫 프레임          | `model`, `prompt`, `images`(링크 1개)                                                                    | 이미지에서 영상이 시작되며 이미지의 모양을 따릅니다.                                         |
| 첫 프레임과 마지막 프레임 | `model`, `prompt`, `images`(링크 2개)                                                                    | `images[0]`은 첫 프레임, `images[1]`은 마지막 프레임입니다.                          |
| 프레임            | `model`, `prompt`, `images`(링크 3\~10개)                                                                | 시간순으로 첫 프레임, 중간 프레임, 마지막 프레임. 이미지는 영상 초 수보다 최대 한 장 더 보낼 수 있습니다.       |
| 참조와 요소         | `model`, `prompt`, 그리고 `reference_images`, `reference_videos`, `reference_audios`, `elements` 중 아무것이나 | 아래 제한 안에서 자유롭게 조합할 수 있습니다. `images`와 함께 쓸 수 없습니다. 프롬프트에서 각 입력을 지칭하세요. |## 요청 파라미터model
string
필수실행할 모델입니다.**값**: `kling-v4`**값이 잘못된 경우**- 누락: `"model" is required`
- 이 엔드포인트에 이미지 모델을 보낸 경우: `"model" nano-banana-2 is served by POST /v1/images/tasks, not this endpoint`prompt
string
필수영상에서 일어나는 일: 피사체, 동작, 카메라 움직임, 스타일, 소리. 각 입력은 `@` 멘션으로 지칭합니다.**길이**: 1–5000자- 길이는 문자 수로 계산합니다(한중일 문자 하나는 1자).
- 멘션: `reference_images`는 `@image_1`, `@image_2` …, `reference_videos`는 `@video_1` …, `reference_audios`는 `@voice_1` …이며, 요소는 `@` 뒤에 `name`을 붙입니다. 프레임은 `@first_frame`, `@keyframe_1`, `@keyframe_2` …, `@last_frame`입니다.
- 모든 `@`는 같은 요청의 입력을 가리켜야 합니다. 참조 이미지가 두 장인데 `@image_3`을 쓰거나 이미지가 한 장인데 `@last_frame`을 쓰는 등, 대응하는 입력이 없는 번호·프레임 멘션은 작업 생성 시 거부됩니다.**값이 잘못된 경우**- 누락: `"prompt" is required`
- 비어 있거나 한도보다 긴 경우: `"prompt" has an unsupported length`
- 요청에 없는 입력을 가리키는 멘션: `the prompt names @image_3, which this request does not send`images
string[]
선택시간순 프레임: 링크 하나는 첫 프레임, 두 개는 첫 프레임과 마지막 프레임이며, 더 보내면 그 사이에 중간 프레임이 추가됩니다.**항목 수**: 1–10  \
각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요.- 링크가 셋 이상이면 `images[0]`이 첫 프레임, 마지막 링크가 마지막 프레임이고, 그 사이의 링크는 중간 프레임입니다. 즉 `images[1]`은 `@keyframe_1`, `images[2]`는 `@keyframe_2`입니다.
- 영상에는 초 수보다 최대 한 장 많은 이미지를 넣을 수 있으며(`duration` + 1, `duration`을 생략하면 5초로 계산), 10장을 넘을 수 없습니다.
- 프레임은 `reference_images`, `reference_videos`, `reference_audios`, `elements`, `aspect_ratio`와 함께 보낼 수 없습니다. 영상은 첫 프레임의 모양을 따릅니다.**값이 잘못된 경우**- 링크가 10개 초과: `"images" accepts at most 10 items`
- 링크가 `duration` + 1개보다 많은 경우(여기서는 5초 영상에 링크 7개): `Kling V4 takes at most 6 images for a 5-second video`
- reference\_\* 필드와 함께 보낸 경우: `Cannot combine "images" with reference inputs in one task`
- `elements`와 함께 보낸 경우: `Kling V4 cannot combine elements with images`
- `aspect_ratio`와 함께 보낸 경우: `Kling V4 takes the first frame's shape; do not send aspect_ratio with images`
- https\:// 링크가 아닌 경우: `"images[0]" must be a public HTTPS URL`reference_images
string[]
선택영상의 내용, 인물, 제품, 스타일을 안내하는 이미지입니다. 프롬프트에서는 목록 순서대로 `@image_1`, `@image_2` …로 지칭하세요.**항목 수**: 1–10  \
각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요.- `images`와 함께 쓸 수 없습니다.
- 참조 입력과 요소를 합쳐 15개 제한에 포함됩니다.**값이 잘못된 경우**- 최대 개수를 넘은 경우: `"reference_images" accepts at most 10 items`
- 참조 입력과 요소를 합쳐 15개 초과: `Kling V4 takes at most 15 reference inputs and elements together`reference_videos
string[]
선택움직임, 카메라 워크, 내용을 가져올 영상입니다. 프롬프트에서는 목록 순서대로 `@video_1`, `@video_2` …로 지칭하세요.**항목 수**: 1–5  \
각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요.- 클립마다 2\~30초, 모든 클립 합계 최대 30초입니다. 게이트웨이는 작업 생성 전에 각 클립을 측정하고, 제한을 벗어난 클립은 해당 클립을 명시해 거부합니다.
- 참조 영상과 영상 요소는 합쳐서 최대 5개이며, 참조 입력과 요소의 15개 제한에 포함됩니다.
- `keep_original_sound: true`를 보내지 않으면 완성된 영상에는 생성 오디오가 들어가며, 보내면 참조 영상의 원래 소리를 유지합니다.**값이 잘못된 경우**- 최대 개수를 넘은 경우: `"reference_videos" accepts at most 5 items`
- 2초보다 짧거나 30초보다 긴 클립: `reference_videos[0] is 35 seconds long; this model takes reference video of 2 to 30 seconds.`
- 합계가 30초를 넘는 클립: `The reference videos run 36 seconds in total; this model takes at most 30.`
- 참조 영상과 영상 요소 합계 5개 초과: `Kling V4 takes at most 5 reference videos and video elements together`reference_audios
string[]
선택영상에 쓸 음성입니다. 프롬프트에서는 목록 순서대로 `@voice_1`, `@voice_2` …로 지칭하세요.**항목 수**: 1–3  \
각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요.- `images`와 함께 쓸 수 없습니다.
- 참조 입력과 요소를 합쳐 15개 제한에 포함됩니다.**값이 잘못된 경우**- 최대 개수를 넘은 경우: `"reference_audios" accepts at most 3 items`elements
object[]
선택인물, 동물, 소품, 의상, 장면, 이펙트 같은 이름 있는 피사체를 최대 7개까지 둘 수 있습니다. 각각 한 번 정의하고 프롬프트에서 `@` 뒤에 `name`을 붙여 지칭합니다.**항목 수**: 7개 이하- 객체를 최대 7개까지 담은 배열입니다. 각 객체는 다음 키만 받습니다.
- `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[].element_input_video_urls`(문자열 배열): 인물이 나오는 3\~8초 단일 샷 영상의 공개 HTTPS 링크 정확히 하나. 이것과 `element_input_urls` 중 하나만 보내세요.
- `elements[].element_input_audio_urls`(문자열 배열, 선택): 인물 요소의 음성인 공개 HTTPS 오디오 링크 정확히 하나.
- `elements[].tag`(string, 선택): 요소의 종류. 영상 요소나 음성이 있는 요소는 인물이어야 하므로 `tag`를 생략하거나 `character`를 보내세요.
- `elements[].description`(string, 선택): 요소에 대한 설명, 최대 100자.
- 영상 요소는 최대 3개, `reference_videos`와 합쳐 최대 5개입니다. 모든 요소는 참조 입력과 요소의 15개 제한에 포함됩니다.
- 요소는 `images`와 함께 보낼 수 없습니다.**값이 잘못된 경우**- 요소가 7개 초과: `"elements" accepts at most 7 items`
- 객체가 아닌 요소: `"elements[0]" must be an object`
- `name`이 없는 요소: `"name" 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] takes either element_input_urls or element_input_video_urls`
- 이미지가 두 장 미만: `"elements[0].element_input_urls" requires at least 2 item`
- 이미지가 네 장 초과: `"elements[0].element_input_urls" accepts at most 4 items`
- `tag`가 `character`가 아닌 영상 요소: `elements[0] is a video element, which is always a character`
- `tag`가 `character`가 아닌 요소에 음성: `elements[0] has a voice, which only a character element takes`
- 목록에 없는 `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 "start_time" is not supported in "elements[0]"`
- 영상 요소가 3개 초과: `Kling V4 takes at most 3 video elements`
- `images`와 함께 보낸 경우: `Kling V4 cannot combine elements with images`duration
integer
선택기본값: 5영상 길이(초)이며 정수입니다. 이 값으로 과금됩니다.**기본값**: `5`  \
**범위**: 3–30- 생략하면 `5`가 사용되어 과금됩니다.
- 프레임을 쓸 때는 이미지 수의 상한도 정합니다. 최대 `duration` + 1장이며 10장을 넘을 수 없습니다.**값이 잘못된 경우**- 범위 밖, 정수가 아님, 또는 문자열로 보낸 경우: `"duration" is outside its supported range`aspect_ratio
string
선택기본값: 16:9가로:세로로 나타낸 영상 모양입니다.**허용 값**: `16:9`, `9:16`, `1:1`, `21:9`  \
**기본값**: `16:9`- 생략하면 `16:9`가 사용됩니다.
- `images`와 함께 보내지 마세요. 영상은 첫 프레임의 모양을 따릅니다.**값이 잘못된 경우**- 목록에 없는 값: `"aspect_ratio" must be one of: [16:9 9:16 1:1 21:9]`
- `images`와 함께 보낸 경우: `Kling V4 takes the first frame's shape; do not send aspect_ratio with images`resolution
string
선택기본값: 720p출력 해상도입니다. `1080p`는 `720p`보다 초당 가격이 높습니다.**허용 값**: `720p`, `1080p`  \
**기본값**: `720p`- 생략하면 `720p`가 사용되어 과금됩니다.
- 이 모델에서는 4K를 사용할 수 없습니다.**값이 잘못된 경우**- 목록에 없는 값(예: `4K` 또는 `pro`): `"resolution" must be one of: [720p 1080p]`keep_original_sound
boolean
선택완성된 영상에 생성 오디오 대신 참조 영상의 원래 소리를 유지합니다.- `reference_videos`가 있을 때만 유효합니다. 없이 보내면 `false`라도 거부됩니다.
- 이 필드가 없으면 영상에 생성 오디오가 들어갑니다. 오디오를 끄는 필드는 없습니다.**값이 잘못된 경우**- true나 false가 아닌 경우: `"keep_original_sound" must be a boolean`
- `reference_videos` 없이 보낸 경우: `"keep_original_sound" needs reference_videos`게이트웨이는 작업을 만들기 전에 다음 조합도 검사합니다.- images는 참조 입력과 함께 쓸 수 없습니다
- images는 시간순 프레임입니다. 하나는 첫 프레임, 두 개는 첫 프레임과 마지막 프레임이며, 더 보내면 그 사이에 중간 프레임이 추가됩니다. 프롬프트에서는 @first\_frame, @keyframe\_1, @keyframe\_2 …, @last\_frame으로 지칭합니다
- 영상에는 초 수보다 최대 한 장 많은 이미지를 넣을 수 있으며, 10장을 넘을 수 없습니다
- 프롬프트에서 reference\_images는 @image\_1, @image\_2 …, reference\_videos는 @video\_1 …, reference\_audios는 @voice\_1 …, elements는 @ 뒤에 이름을 붙여 지칭합니다. 프롬프트의 모든 @는 같은 요청의 입력을 가리켜야 합니다
- 참조 영상은 각각 2-30초, 합계 30초입니다. 참조 영상과 영상 요소는 합쳐서 최대 5개, 영상 요소는 최대 3개이며, reference\_images, reference\_videos, reference\_audios, elements는 합쳐서 최대 15개입니다
- 요소는 element\_input\_urls의 이미지 2-4장(첫 번째가 대표 이미지) 또는 element\_input\_video\_urls의 3-8초 단일 샷 인물 영상 하나입니다. element\_input\_audio\_urls로 인물 요소에 음성을 지정합니다
- 요소 이름은 영문자, 숫자, 밑줄 또는 한자 1-20자이며, 대소문자 구분 없이 고유해야 하고 image\_N, video\_N, voice\_N, keyframe\_N, object\_N, audio\_N, first\_frame, last\_frame은 쓸 수 없습니다
- elements와 aspect\_ratio는 images와 함께 보낼 수 없습니다. 출력은 첫 프레임의 모양을 따르며, images가 없으면 aspect\_ratio 기본값은 16:9입니다
- keep\_original\_sound는 참조 영상의 원래 오디오를 유지하며 reference\_videos가 필요합니다. 그렇지 않으면 영상에 생성 오디오가 들어갑니다## 입력 미디어 제한게이트웨이는 작업을 만들기 전에 모든 입력을 읽고, 아래 제한을 벗어난 입력은 해당 입력을 명시한 `400 bad_request`로 거부합니다. 과금되지 않습니다.| 미디어 | 작업 생성 전에 검사하는 제한                         |
| --- | ---------------------------------------- |
| 이미지 | 가로·세로 300–65536 px, 화면비(가로 ÷ 세로) 0.4–2.5 |
| 영상  | 각각 2–30초, 합계 30초                         |- 게이트웨이는 작업 생성 전에 `images`, `reference_images`, `reference_videos`를 측정하고, 제한을 벗어난 입력은 목록과 위치를 명시한 메시지로 거부합니다(예: `reference_videos[0] is 35 seconds long; this model takes reference video of 2 to 30 seconds.`). 비용은 청구되지 않습니다.
- 요소 링크와 `reference_audios`는 작업 생성 전에 공개 HTTPS 링크인지만 검사합니다. 요소 영상은 3\~8초여야 합니다.
- 로컬 파일이 있다면 `POST /v1/files`로 업로드하고 반환된 `data.url`을 전달하세요.## 프롬프트 멘션입력 종류마다 고유한 멘션이 있으며, 목록 순서대로 1부터 번호를 매깁니다.| 멘션                             | 대상                    | 사용 조건                   |
| ------------------------------ | --------------------- | ----------------------- |
| `@image_1`, `@image_2` …       | `reference_images`    | 참조 이미지를 그 수 이상 보낸 경우    |
| `@video_1`, `@video_2` …       | `reference_videos`    | 참조 영상을 그 수 이상 보낸 경우     |
| `@voice_1`, `@voice_2` …       | `reference_audios`    | 참조 오디오 링크를 그 수 이상 보낸 경우 |
| `@` + 요소 이름                    | 해당 `name`을 가진 요소      | 요소가 `elements`에 있는 경우   |
| `@first_frame`                 | `images[0]`           | 이미지를 하나 이상 보낸 경우        |
| `@keyframe_1`, `@keyframe_2` … | `images[1]`부터의 중간 프레임 | 이미지를 셋 이상 보낸 경우         |
| `@last_frame`                  | `images`의 마지막 링크      | 이미지를 둘 이상 보낸 경우         |- 대응하는 입력이 없는 번호·프레임 멘션은 작업 생성 시 거부됩니다(예: `the prompt names @last_frame, which this request does not send`).## 조합 규칙작업 생성 시 검사하며, 위반한 요청은 `400 bad_request`로 거부되고 비용이 들지 않습니다.| 규칙                                          | 메시지                                                                            |
| ------------------------------------------- | ------------------------------------------------------------------------------ |
| `reference_*` 필드와 함께 보낸 `images`            | `Cannot combine "images" with reference inputs in one task`                    |
| `elements`와 함께 보낸 `images`                  | `Kling V4 cannot combine elements with images`                                 |
| `aspect_ratio`와 함께 보낸 `images`              | `Kling V4 takes the first frame's shape; do not send aspect_ratio with images` |
| 이미지가 `duration` + 1장보다 많음(여기서는 5초 영상)       | `Kling V4 takes at most 6 images for a 5-second video`                         |
| `reference_videos` 없는 `keep_original_sound` | `"keep_original_sound" needs reference_videos`                                 |
| 영상 요소가 3개 초과                                | `Kling V4 takes at most 3 video elements`                                      |
| 참조 영상과 영상 요소 합계 5개 초과                       | `Kling V4 takes at most 5 reference videos and video elements together`        |
| 참조 이미지, 영상, 오디오 링크, 요소 합계 15개 초과            | `Kling V4 takes at most 15 reference inputs and elements together`             |## 이 모델이 받지 않는 필드다음 필드를 보내면 무시되지 않고 과금 전에 거부됩니다.- `sound`, `generate_audio`, `seed`, `multi_shots`, `multi_prompt`, `quality`, `watermark`, `task_type`, `output_format` → `field "sound" is not supported by model kling-v4`(보낸 필드 포함).
- 그 밖의 알 수 없는 필드 → `unknown field: <name>`.## 요청 예시```bash title="cURL"
curl --request POST \
  --url https://api.beatapi.io/v1/videos/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "kling-v4",
  "prompt": "A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone",
  "duration": 5,
  "aspect_ratio": "16:9",
  "resolution": "720p"
}'
``````python title="Python"
import os
import requests

response = requests.post(
    "https://api.beatapi.io/v1/videos/tasks",
    headers={"Authorization": f"Bearer {os.environ['BEATAPI_API_KEY']}"},
    json={
      "model": "kling-v4",
      "prompt": "A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone",
      "duration": 5,
      "aspect_ratio": "16:9",
      "resolution": "720p"
    },
    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/videos/tasks', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.BEATAPI_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "model": "kling-v4",
    "prompt": "A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone",
    "duration": 5,
    "aspect_ratio": "16:9",
    "resolution": "720p"
  }),
});
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);
```### 텍스트로 영상 생성생성 오디오가 포함된 720p 16:9 5초 클립입니다.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/videos/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "kling-v4",
  "prompt": "A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone",
  "duration": 5,
  "aspect_ratio": "16:9",
  "resolution": "720p"
}'
```### 첫 프레임과 마지막 프레임1080p로 첫 번째 이미지에서 두 번째 이미지로 이어지며, 첫 프레임의 모양을 따릅니다.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/videos/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "kling-v4",
  "prompt": "The camera moves from the bottle in @first_frame to the singer on a neon stage in @last_frame in one continuous shot",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ],
  "duration": 5,
  "resolution": "1080p"
}'
```### 참조 이미지와 음성참조 이미지 두 장과 음성 하나이며, 각각 프롬프트에서 지칭합니다.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/videos/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "kling-v4",
  "prompt": "The singer from @image_1 lifts the bottle from @image_2 toward the camera and says a short line in the voice of @voice_1",
  "reference_images": [
    "https://cdn.beatapi.io/samples/neon-singer.png",
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "reference_audios": [
    "https://cdn.beatapi.io/samples/neon-singer-preview.mp3"
  ],
  "duration": 8,
  "aspect_ratio": "9:16",
  "resolution": "720p"
}'
```### 원래 소리를 유지하는 참조 영상자리 표시자를 직접 준비한 2\~30초 클립으로 바꾸세요. `keep_original_sound`는 생성 오디오 대신 원래 소리를 유지합니다.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/videos/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "kling-v4",
  "prompt": "Restyle @video_1 as a neon-lit night scene and keep its camera movement",
  "reference_videos": [
    "https://your-cdn.example.com/clips/source.mp4"
  ],
  "keep_original_sound": true,
  "duration": 10,
  "resolution": "720p"
}'
```### 이름 있는 요소인물과 소품을 각각 이미지 두 장(첫 번째가 대표 이미지)으로 정의합니다. 자리 표시자 링크를 직접 준비한 이미지로 바꾸세요.```bash
curl --request POST \
  --url https://api.beatapi.io/v1/videos/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "kling-v4",
  "prompt": "@singer walks across a neon stage holding @bottle and smiles at the camera",
  "duration": 6,
  "aspect_ratio": "16:9",
  "resolution": "720p",
  "elements": [
    {
      "name": "singer",
      "tag": "character",
      "description": "A performer in a silver jacket",
      "element_input_urls": [
        "https://your-cdn.example.com/elements/singer-front.png",
        "https://your-cdn.example.com/elements/singer-side.png"
      ]
    },
    {
      "name": "bottle",
      "tag": "prop",
      "element_input_urls": [
        "https://your-cdn.example.com/elements/bottle-front.png",
        "https://your-cdn.example.com/elements/bottle-back.png"
      ]
    }
  ]
}'
```## 응답### 작업 생성(201)작업 객체입니다. 작업이 성공할 때까지 `output`는 `null`입니다. '실행 중'으로 표시된 필드는 작업이 끝나면 사라집니다.```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "video",
    "capability_id": "kling-v4",
    "capability_version": 1,
    "media_type": "video",
    "model": "kling-v4",
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "poll_after_seconds": 8,
    "output": null,
    "usage": {
      "credits_reserved": 0.75,
      "credits_settled": 0,
      "credits_refunded": 0,
      "credits_charged": 0.75,
      "billable_duration_seconds": 5
    },
    "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": "video",
    "capability_id": "kling-v4",
    "capability_version": 1,
    "media_type": "video",
    "model": "kling-v4",
    "status": "succeeded",
    "stage": "succeeded",
    "created_at": 1791993600,
    "updated_at": 1791993690,
    "completed_at": 1791993690,
    "output": {
      "media": [
        {
          "type": "video",
          "url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/0.mp4",
          "mime_type": "video/mp4"
        }
      ],
      "r2_url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/0.mp4"
    },
    "usage": {
      "credits_reserved": 0.75,
      "credits_settled": 0.75,
      "credits_refunded": 0,
      "credits_charged": 0.75,
      "billable_duration_seconds": 5
    },
    "request_id": "req_5f0c2a9e4b7d4e31",
    "error_code": null,
    "error_message": null
  }
}
```#### 출력 필드| 필드                         | 타입         | 설명                                                 |
| -------------------------- | ---------- | -------------------------------------------------- |
| `output.media`             | `object[]` | 생성된 파일입니다. 이 모델은 영상 하나를 만듭니다.                      |
| `output.media[].type`      | `string`   | 항상 `video`.                                        |
| `output.media[].url`       | `string`   | 저장된 영상의 HTTPS 링크입니다. 내려받아 보관하세요. 보관 기간은 보장하지 않습니다. |
| `output.media[].mime_type` | `string`   | 파일의 미디어 형식이며 보통 `video/mp4`입니다.                    |
| `output.r2_url`            | `string`   | 이전 클라이언트를 위해 다시 넣은 영상 URL입니다. 대신 `media`를 읽으세요.    |### 실패한 작업실패한 작업도 `GET /v1/tasks/{task_id}`에서는 HTTP 200입니다. 실패 정보는 본문에 있습니다. 보류 금액이 전액 환불되므로 과금되지 않습니다.```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "video",
    "capability_id": "kling-v4",
    "capability_version": 1,
    "media_type": "video",
    "model": "kling-v4",
    "status": "failed",
    "stage": "failed",
    "created_at": 1791993600,
    "updated_at": 1791993690,
    "completed_at": 1791993690,
    "output": null,
    "usage": {
      "credits_reserved": 0.75,
      "credits_settled": 0,
      "credits_refunded": 0.75,
      "credits_charged": 0,
      "billable_duration_seconds": 5
    },
    "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/videos/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-v4",
  "prompt": "A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone",
  "duration": 5,
  "aspect_ratio": "16:9",
  "resolution": "720p"
})
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"])
```## 과금- 가격은 선택한 해상도의 영상 초당 요금입니다. `720p`는 초당 $0.15, `1080p`는 초당 $0.23입니다. 아래 목록은 8초 클립 기준입니다.
- 초 수는 `duration`이며, 생략하면 5입니다. 작업의 `usage.billable_duration_seconds`에 표시됩니다.
- 영상 입력(`reference_videos` 또는 영상으로 만든 요소)이 있으면 요금은 `720p` 초당 $0.09, `1080p` 초당 $0.14이며, 출력 초 수에 입력 영상 초 수를 더한 값으로 과금되고 출력 초 수의 두 배보다 적게 과금되지 않습니다. 영상 요소는 각각 8초로 계산합니다. `keep_original_sound`에는 `reference_videos`가 필요하므로 항상 이 방식으로 과금됩니다. 아래 영상 입력 행은 8초 참조로 만든 8초 클립 기준입니다.
- 모든 영상에는 생성되었거나 참조 영상에서 유지된 오디오가 별도 요금 없이 포함됩니다.
- 가격은 작업 생성 시 보류되고 영상이 준비되면 정산됩니다. 실패한 작업은 제출 후 콘텐츠 검수에서 거부된 경우를 포함해 전액 환불됩니다.현재 정가이며 [가격](https://beatapi.io/pricing) 페이지와 같습니다. 별도 할인 계약이 있는 계정은 더 적게 지불하며, 실제 청구 금액은 항상 작업의 `data.usage`에서 확인할 수 있습니다.| 옵션                            | 정가(USD) |
| ----------------------------- | ------- |
| 8초 · 720p                     | \$1.2   |
| 8초 · 720p · 영상 입력 포함 · 8초 참조  | \$1.44  |
| 8초 · 1080p                    | \$1.84  |
| 8초 · 1080p · 영상 입력 포함 · 8초 참조 | \$2.24  |## 자주 발생하는 오류| 오류 또는 증상                                                                                           | 원인                                                                                     | 해결 방법                                                                |
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| 400 `the prompt names @image_3, which this request does not send`                                  | 요청에 없는 입력을 가리키는 멘션이 있습니다(예: 참조 이미지를 두 장 보냈는데 세 번째를 지칭).                                | 모든 `@`를 같은 요청의 입력과 맞추세요. 번호는 목록 순서대로 1부터입니다.                         |
| 400 `Cannot combine "images" with reference inputs in one task`                                    | `images`의 프레임을 `reference_images`, `reference_videos` 또는 `reference_audios`와 함께 보냈습니다. | 프레임과 참조 중 하나만 사용하세요. 프레임이 아니라 영상을 안내할 이미지는 `reference_images`에 넣으세요. |
| 400 `Kling V4 cannot combine elements with images`                                                 | 프레임과 함께 `elements`를 보냈습니다.                                                             | `images`를 삭제하거나 `elements`를 삭제하세요.                                   |
| 400 `Kling V4 takes the first frame's shape; do not send aspect_ratio with images`                 | 프레임과 함께 `aspect_ratio`를 보냈습니다.                                                         | `aspect_ratio`를 삭제하고 첫 프레임을 원하는 모양으로 자르세요.                           |
| 400 `Kling V4 takes at most 6 images for a 5-second video`                                         | 프레임이 `duration` + 1장보다 많습니다.                                                           | 프레임 수를 줄이거나 `duration`을 늘리세요. 어떤 경우든 프레임은 최대 10장입니다.                 |
| 400 `elements[0] takes either element_input_urls or element_input_video_urls`                      | 요소에 이미지와 영상이 모두 있거나 둘 다 없습니다.                                                          | 요소마다 이미지 2\~4장 또는 인물 영상 하나를 지정하세요.                                   |
| 400 `"elements[0].element_input_urls" requires at least 2 item`                                    | 요소에 이미지가 한 장뿐입니다.                                                                      | 요소 이미지를 2\~4장 보내세요. 대표 이미지가 첫 번째입니다.                                 |
| 400 `elements[0].name "image_1" is not a name Kling V4 accepts`                                    | 이름에 영문자, 숫자, 밑줄, 한자 이외의 문자가 있거나 `image_1`, `first_frame` 같은 예약된 이름입니다.                 | 요소 이름을 바꾸고(예: `singer`, `hero_bottle`) 그 이름으로 지칭하세요.                 |
| 400 `"keep_original_sound" needs reference_videos`                                                 | `reference_videos` 없이 `keep_original_sound`를 보냈습니다.                                    | 삭제하거나, 소리를 유지할 참조 영상을 추가하세요.                                         |
| 400 `reference_videos[0] is 35 seconds long; this model takes reference video of 2 to 30 seconds.` | 참조 클립이 2초보다 짧거나 30초보다 깁니다. 모든 클립 합계는 최대 30초입니다.                                        | 필요한 부분만 남도록 클립을 자르세요.                                                |
| 400 `field "sound" is not supported by model kling-v4`                                             | 오디오는 항상 생성되며 사운드 스위치는 없습니다(`generate_audio`, `seed`, `multi_shots`도 거부됨).              | 해당 필드를 삭제하세요. 참조 영상의 원래 소리를 유지하려면 `keep_original_sound: true`를 보내세요. |
| 400 `"resolution" must be one of: [720p 1080p]`                                                    | `4K` 또는 `pro` 같은 등급 이름을 보냈습니다.                                                         | `720p` 또는 `1080p`를 보내세요.                                             |
| 400 `"duration" is outside its supported range`                                                    | 3\~30 사이의 정수가 아니거나 문자열로 보냈습니다.                                                         | `5` 같은 정수를 보내세요.                                                     |
| 작업이 `content_policy_violation`과 함께 `failed`                                                        | 프롬프트, 입력 또는 결과가 콘텐츠 검수에서 거부되었습니다.                                                      | 프롬프트나 입력을 바꾸세요. 그대로 재시도하면 다시 실패하며, 비용은 청구되지 않습니다.                    |
| 402 `insufficient_credits`                                                                         | 잔액이 이 길이와 해상도의 보류 금액보다 적습니다.                                                           | 충전하거나, `duration`을 줄이거나, `720p`를 사용하세요.                              |## 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/video-api/kling-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 KlingV4VideoRequest.

- `model` (enum, required) — 실행할 모델입니다. **값**: `kling-v4` **값이 잘못된 경우** - 누락: `"model" is required` - 이 엔드포인트에 이미지 모델을 보낸 경우: `"model" nano-banana-2 is served by POST /v1/images/tasks, not this endpoint`
  - Allowed values: `kling-v4`
- `prompt` (string, required) — 영상에서 일어나는 일: 피사체, 동작, 카메라 움직임, 스타일, 소리. 각 입력은 `@` 멘션으로 지칭합니다. **길이**: 1–5000자 - 길이는 문자 수로 계산합니다(한중일 문자 하나는 1자). - 멘션: `reference_images`는 `@image_1`, `@image_2` …, `reference_videos`는 `@video_1` …, `reference_audios`는 `@voice_1` …이며, 요소는 `@` 뒤에 `name`을 붙입니다. 프레임은 `@first_frame`, `@keyframe_1`, `@keyframe_2` …, `@last_frame`입니다. - 모든 `@`는 같은 요청의 입력을 가리켜야 합니다. 참조 이미지가 두 장인데 `@image_3`을 쓰거나 이미지가 한 장인데 `@last_frame`을 쓰는 등, 대응하는 입력이 없는 번호·프레임 멘션은 작업 생성 시 거부됩니다. **값이 잘못된 경우** - 누락: `"prompt" is required` - 비어 있거나 한도보다 긴 경우: `"prompt" has an unsupported length` - 요청에 없는 입력을 가리키는 멘션: `the prompt names @image_3, which this request does not send`
- `aspect_ratio` (enum, optional, default: 16:9) — 가로:세로로 나타낸 영상 모양입니다. **허용 값**: `16:9`, `9:16`, `1:1`, `21:9` **기본값**: `16:9` - 생략하면 `16:9`가 사용됩니다. - `images`와 함께 보내지 마세요. 영상은 첫 프레임의 모양을 따릅니다. **값이 잘못된 경우** - 목록에 없는 값: `"aspect_ratio" must be one of: [16:9 9:16 1:1 21:9]` - `images`와 함께 보낸 경우: `Kling V4 takes the first frame's shape; do not send aspect_ratio with images`
  - Allowed values: `16:9`, `9:16`, `1:1`, `21:9`
- `duration` (integer, optional, default: 5) — 영상 길이(초)이며 정수입니다. 이 값으로 과금됩니다. **기본값**: `5` **범위**: 3–30 - 생략하면 `5`가 사용되어 과금됩니다. - 프레임을 쓸 때는 이미지 수의 상한도 정합니다. 최대 `duration` + 1장이며 10장을 넘을 수 없습니다. **값이 잘못된 경우** - 범위 밖, 정수가 아님, 또는 문자열로 보낸 경우: `"duration" is outside its supported range`
- `elements` (list of KlingV4VideoRequestElementsItems, optional) — 인물, 동물, 소품, 의상, 장면, 이펙트 같은 이름 있는 피사체를 최대 7개까지 둘 수 있습니다. 각각 한 번 정의하고 프롬프트에서 `@` 뒤에 `name`을 붙여 지칭합니다. **항목 수**: 7개 이하 - 객체를 최대 7개까지 담은 배열입니다. 각 객체는 다음 키만 받습니다. - `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[].element_input_video_urls`(문자열 배열): 인물이 나오는 3~8초 단일 샷 영상의 공개 HTTPS 링크 정확히 하나. 이것과 `element_input_urls` 중 하나만 보내세요. - `elements[].element_input_audio_urls`(문자열 배열, 선택): 인물 요소의 음성인 공개 HTTPS 오디오 링크 정확히 하나. - `elements[].tag`(string, 선택): 요소의 종류. 영상 요소나 음성이 있는 요소는 인물이어야 하므로 `tag`를 생략하거나 `character`를 보내세요. - `elements[].description`(string, 선택): 요소에 대한 설명, 최대 100자. - 영상 요소는 최대 3개, `reference_videos`와 합쳐 최대 5개입니다. 모든 요소는 참조 입력과 요소의 15개 제한에 포함됩니다. - 요소는 `images`와 함께 보낼 수 없습니다. **값이 잘못된 경우** - 요소가 7개 초과: `"elements" accepts at most 7 items` - 객체가 아닌 요소: `"elements[0]" must be an object` - `name`이 없는 요소: `"name" 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] takes either element_input_urls or element_input_video_urls` - 이미지가 두 장 미만: `"elements[0].element_input_urls" requires at least 2 item` - 이미지가 네 장 초과: `"elements[0].element_input_urls" accepts at most 4 items` - `tag`가 `character`가 아닌 영상 요소: `elements[0] is a video element, which is always a character` - `tag`가 `character`가 아닌 요소에 음성: `elements[0] has a voice, which only a character element takes` - 목록에 없는 `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 "start_time" is not supported in "elements[0]"` - 영상 요소가 3개 초과: `Kling V4 takes at most 3 video elements` - `images`와 함께 보낸 경우: `Kling V4 cannot combine elements with images`
- `images` (list of string, optional) — 시간순 프레임: 링크 하나는 첫 프레임, 두 개는 첫 프레임과 마지막 프레임이며, 더 보내면 그 사이에 중간 프레임이 추가됩니다. **항목 수**: 1–10 각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요. - 링크가 셋 이상이면 `images[0]`이 첫 프레임, 마지막 링크가 마지막 프레임이고, 그 사이의 링크는 중간 프레임입니다. 즉 `images[1]`은 `@keyframe_1`, `images[2]`는 `@keyframe_2`입니다. - 영상에는 초 수보다 최대 한 장 많은 이미지를 넣을 수 있으며(`duration` + 1, `duration`을 생략하면 5초로 계산), 10장을 넘을 수 없습니다. - 프레임은 `reference_images`, `reference_videos`, `reference_audios`, `elements`, `aspect_ratio`와 함께 보낼 수 없습니다. 영상은 첫 프레임의 모양을 따릅니다. **값이 잘못된 경우** - 링크가 10개 초과: `"images" accepts at most 10 items` - 링크가 `duration` + 1개보다 많은 경우(여기서는 5초 영상에 링크 7개): `Kling V4 takes at most 6 images for a 5-second video` - reference_* 필드와 함께 보낸 경우: `Cannot combine "images" with reference inputs in one task` - `elements`와 함께 보낸 경우: `Kling V4 cannot combine elements with images` - `aspect_ratio`와 함께 보낸 경우: `Kling V4 takes the first frame's shape; do not send aspect_ratio with images` - https:// 링크가 아닌 경우: `"images[0]" must be a public HTTPS URL`
- `keep_original_sound` (boolean, optional) — 완성된 영상에 생성 오디오 대신 참조 영상의 원래 소리를 유지합니다. - `reference_videos`가 있을 때만 유효합니다. 없이 보내면 `false`라도 거부됩니다. - 이 필드가 없으면 영상에 생성 오디오가 들어갑니다. 오디오를 끄는 필드는 없습니다. **값이 잘못된 경우** - true나 false가 아닌 경우: `"keep_original_sound" must be a boolean` - `reference_videos` 없이 보낸 경우: `"keep_original_sound" needs reference_videos`
- `reference_audios` (list of string, optional) — 영상에 쓸 음성입니다. 프롬프트에서는 목록 순서대로 `@voice_1`, `@voice_2` …로 지칭하세요. **항목 수**: 1–3 각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요. - `images`와 함께 쓸 수 없습니다. - 참조 입력과 요소를 합쳐 15개 제한에 포함됩니다. **값이 잘못된 경우** - 최대 개수를 넘은 경우: `"reference_audios" accepts at most 3 items`
- `reference_images` (list of string, optional) — 영상의 내용, 인물, 제품, 스타일을 안내하는 이미지입니다. 프롬프트에서는 목록 순서대로 `@image_1`, `@image_2` …로 지칭하세요. **항목 수**: 1–10 각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요. - `images`와 함께 쓸 수 없습니다. - 참조 입력과 요소를 합쳐 15개 제한에 포함됩니다. **값이 잘못된 경우** - 최대 개수를 넘은 경우: `"reference_images" accepts at most 10 items` - 참조 입력과 요소를 합쳐 15개 초과: `Kling V4 takes at most 15 reference inputs and elements together`
- `reference_videos` (list of string, optional) — 움직임, 카메라 워크, 내용을 가져올 영상입니다. 프롬프트에서는 목록 순서대로 `@video_1`, `@video_2` …로 지칭하세요. **항목 수**: 1–5 각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요. - 클립마다 2~30초, 모든 클립 합계 최대 30초입니다. 게이트웨이는 작업 생성 전에 각 클립을 측정하고, 제한을 벗어난 클립은 해당 클립을 명시해 거부합니다. - 참조 영상과 영상 요소는 합쳐서 최대 5개이며, 참조 입력과 요소의 15개 제한에 포함됩니다. - `keep_original_sound: true`를 보내지 않으면 완성된 영상에는 생성 오디오가 들어가며, 보내면 참조 영상의 원래 소리를 유지합니다. **값이 잘못된 경우** - 최대 개수를 넘은 경우: `"reference_videos" accepts at most 5 items` - 2초보다 짧거나 30초보다 긴 클립: `reference_videos[0] is 35 seconds long; this model takes reference video of 2 to 30 seconds.` - 합계가 30초를 넘는 클립: `The reference videos run 36 seconds in total; this model takes at most 30.` - 참조 영상과 영상 요소 합계 5개 초과: `Kling V4 takes at most 5 reference videos and video elements together`
- `resolution` (enum, optional, default: 720p) — 출력 해상도입니다. `1080p`는 `720p`보다 초당 가격이 높습니다. **허용 값**: `720p`, `1080p` **기본값**: `720p` - 생략하면 `720p`가 사용되어 과금됩니다. - 이 모델에서는 4K를 사용할 수 없습니다. **값이 잘못된 경우** - 목록에 없는 값(예: `4K` 또는 `pro`): `"resolution" must be one of: [720p 1080p]`
  - Allowed values: `720p`, `1080p`

## 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

### KlingV4VideoRequestElementsItems

- `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자 이하
- `element_input_audio_urls` (list of string, optional) — `elements[].element_input_audio_urls`(문자열 배열, 선택): 인물 요소의 음성인 공개 HTTPS 오디오 링크 정확히 하나. **항목 수**: 1–1 각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요.
- `element_input_urls` (list of string, optional) — `elements[].element_input_urls`(문자열 배열): 요소 이미지의 공개 HTTPS 링크 2~4개. 첫 번째가 대표 이미지입니다. **항목 수**: 2–4 각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요.
- `element_input_video_urls` (list of string, optional) — `elements[].element_input_video_urls`(문자열 배열): 인물이 나오는 3~8초 단일 샷 영상의 공개 HTTPS 링크 정확히 하나. 이것과 `element_input_urls` 중 하나만 보내세요. **항목 수**: 1–1 각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요.
- `tag` (enum, optional) — `elements[].tag`(string, 선택): 요소의 종류. 영상 요소나 음성이 있는 요소는 인물이어야 하므로 `tag`를 생략하거나 `character`를 보내세요. **허용 값**: `character`, `animal`, `prop`, `costume`, `scene`, `effect`, `others`
  - Allowed values: `character`, `animal`, `prop`, `costume`, `scene`, `effect`, `others`

## Examples

### 텍스트로 영상 생성

**Request**

```json
{
  "model": "kling-v4",
  "prompt": "A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone",
  "aspect_ratio": "16:9",
  "duration": 5,
  "resolution": "720p"
}
```

**Response**

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

**SDK Code**

```python 텍스트로 영상 생성
import requests

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

payload = {
    "model": "kling-v4",
    "prompt": "A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone",
    "aspect_ratio": "16:9",
    "duration": 5,
    "resolution": "720p"
}
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/videos/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"kling-v4","prompt":"A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone","aspect_ratio":"16:9","duration":5,"resolution":"720p"}'
};

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/videos/tasks"

	payload := strings.NewReader("{\n  \"model\": \"kling-v4\",\n  \"prompt\": \"A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone\",\n  \"aspect_ratio\": \"16:9\",\n  \"duration\": 5,\n  \"resolution\": \"720p\"\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/videos/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-v4\",\n  \"prompt\": \"A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone\",\n  \"aspect_ratio\": \"16:9\",\n  \"duration\": 5,\n  \"resolution\": \"720p\"\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/videos/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"kling-v4\",\n  \"prompt\": \"A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone\",\n  \"aspect_ratio\": \"16:9\",\n  \"duration\": 5,\n  \"resolution\": \"720p\"\n}")
  .asString();
```

```php 텍스트로 영상 생성
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/videos/tasks', [
  'body' => '{
  "model": "kling-v4",
  "prompt": "A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone",
  "aspect_ratio": "16:9",
  "duration": 5,
  "resolution": "720p"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp 텍스트로 영상 생성
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/videos/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-v4\",\n  \"prompt\": \"A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone\",\n  \"aspect_ratio\": \"16:9\",\n  \"duration\": 5,\n  \"resolution\": \"720p\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 텍스트로 영상 생성
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "kling-v4",
  "prompt": "A dramatic product reveal of a glass water bottle, slow orbiting camera, soft studio reflections, a low ambient synth tone",
  "aspect_ratio": "16:9",
  "duration": 5,
  "resolution": "720p"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/videos/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-v4",
  "prompt": "The camera moves from the bottle in @first_frame to the singer on a neon stage in @last_frame in one continuous shot",
  "duration": 5,
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ],
  "resolution": "1080p"
}
```

**Response**

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

**SDK Code**

```python 첫 프레임과 마지막 프레임
import requests

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

payload = {
    "model": "kling-v4",
    "prompt": "The camera moves from the bottle in @first_frame to the singer on a neon stage in @last_frame in one continuous shot",
    "duration": 5,
    "images": ["https://cdn.beatapi.io/samples/smart-bottle.png", "https://cdn.beatapi.io/samples/neon-singer.png"],
    "resolution": "1080p"
}
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/videos/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"kling-v4","prompt":"The camera moves from the bottle in @first_frame to the singer on a neon stage in @last_frame in one continuous shot","duration":5,"images":["https://cdn.beatapi.io/samples/smart-bottle.png","https://cdn.beatapi.io/samples/neon-singer.png"],"resolution":"1080p"}'
};

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/videos/tasks"

	payload := strings.NewReader("{\n  \"model\": \"kling-v4\",\n  \"prompt\": \"The camera moves from the bottle in @first_frame to the singer on a neon stage in @last_frame in one continuous shot\",\n  \"duration\": 5,\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ],\n  \"resolution\": \"1080p\"\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/videos/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-v4\",\n  \"prompt\": \"The camera moves from the bottle in @first_frame to the singer on a neon stage in @last_frame in one continuous shot\",\n  \"duration\": 5,\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ],\n  \"resolution\": \"1080p\"\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/videos/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"kling-v4\",\n  \"prompt\": \"The camera moves from the bottle in @first_frame to the singer on a neon stage in @last_frame in one continuous shot\",\n  \"duration\": 5,\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ],\n  \"resolution\": \"1080p\"\n}")
  .asString();
```

```php 첫 프레임과 마지막 프레임
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/videos/tasks', [
  'body' => '{
  "model": "kling-v4",
  "prompt": "The camera moves from the bottle in @first_frame to the singer on a neon stage in @last_frame in one continuous shot",
  "duration": 5,
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ],
  "resolution": "1080p"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp 첫 프레임과 마지막 프레임
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/videos/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-v4\",\n  \"prompt\": \"The camera moves from the bottle in @first_frame to the singer on a neon stage in @last_frame in one continuous shot\",\n  \"duration\": 5,\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ],\n  \"resolution\": \"1080p\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 첫 프레임과 마지막 프레임
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "kling-v4",
  "prompt": "The camera moves from the bottle in @first_frame to the singer on a neon stage in @last_frame in one continuous shot",
  "duration": 5,
  "images": ["https://cdn.beatapi.io/samples/smart-bottle.png", "https://cdn.beatapi.io/samples/neon-singer.png"],
  "resolution": "1080p"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/videos/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-v4",
  "prompt": "The singer from @image_1 lifts the bottle from @image_2 toward the camera and says a short line in the voice of @voice_1",
  "aspect_ratio": "9:16",
  "duration": 8,
  "reference_audios": [
    "https://cdn.beatapi.io/samples/neon-singer-preview.mp3"
  ],
  "reference_images": [
    "https://cdn.beatapi.io/samples/neon-singer.png",
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "resolution": "720p"
}
```

**Response**

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

**SDK Code**

```python 참조 이미지와 음성
import requests

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

payload = {
    "model": "kling-v4",
    "prompt": "The singer from @image_1 lifts the bottle from @image_2 toward the camera and says a short line in the voice of @voice_1",
    "aspect_ratio": "9:16",
    "duration": 8,
    "reference_audios": ["https://cdn.beatapi.io/samples/neon-singer-preview.mp3"],
    "reference_images": ["https://cdn.beatapi.io/samples/neon-singer.png", "https://cdn.beatapi.io/samples/smart-bottle.png"],
    "resolution": "720p"
}
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/videos/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"kling-v4","prompt":"The singer from @image_1 lifts the bottle from @image_2 toward the camera and says a short line in the voice of @voice_1","aspect_ratio":"9:16","duration":8,"reference_audios":["https://cdn.beatapi.io/samples/neon-singer-preview.mp3"],"reference_images":["https://cdn.beatapi.io/samples/neon-singer.png","https://cdn.beatapi.io/samples/smart-bottle.png"],"resolution":"720p"}'
};

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/videos/tasks"

	payload := strings.NewReader("{\n  \"model\": \"kling-v4\",\n  \"prompt\": \"The singer from @image_1 lifts the bottle from @image_2 toward the camera and says a short line in the voice of @voice_1\",\n  \"aspect_ratio\": \"9:16\",\n  \"duration\": 8,\n  \"reference_audios\": [\n    \"https://cdn.beatapi.io/samples/neon-singer-preview.mp3\"\n  ],\n  \"reference_images\": [\n    \"https://cdn.beatapi.io/samples/neon-singer.png\",\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"resolution\": \"720p\"\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/videos/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-v4\",\n  \"prompt\": \"The singer from @image_1 lifts the bottle from @image_2 toward the camera and says a short line in the voice of @voice_1\",\n  \"aspect_ratio\": \"9:16\",\n  \"duration\": 8,\n  \"reference_audios\": [\n    \"https://cdn.beatapi.io/samples/neon-singer-preview.mp3\"\n  ],\n  \"reference_images\": [\n    \"https://cdn.beatapi.io/samples/neon-singer.png\",\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"resolution\": \"720p\"\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/videos/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"kling-v4\",\n  \"prompt\": \"The singer from @image_1 lifts the bottle from @image_2 toward the camera and says a short line in the voice of @voice_1\",\n  \"aspect_ratio\": \"9:16\",\n  \"duration\": 8,\n  \"reference_audios\": [\n    \"https://cdn.beatapi.io/samples/neon-singer-preview.mp3\"\n  ],\n  \"reference_images\": [\n    \"https://cdn.beatapi.io/samples/neon-singer.png\",\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"resolution\": \"720p\"\n}")
  .asString();
```

```php 참조 이미지와 음성
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/videos/tasks', [
  'body' => '{
  "model": "kling-v4",
  "prompt": "The singer from @image_1 lifts the bottle from @image_2 toward the camera and says a short line in the voice of @voice_1",
  "aspect_ratio": "9:16",
  "duration": 8,
  "reference_audios": [
    "https://cdn.beatapi.io/samples/neon-singer-preview.mp3"
  ],
  "reference_images": [
    "https://cdn.beatapi.io/samples/neon-singer.png",
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "resolution": "720p"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp 참조 이미지와 음성
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/videos/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-v4\",\n  \"prompt\": \"The singer from @image_1 lifts the bottle from @image_2 toward the camera and says a short line in the voice of @voice_1\",\n  \"aspect_ratio\": \"9:16\",\n  \"duration\": 8,\n  \"reference_audios\": [\n    \"https://cdn.beatapi.io/samples/neon-singer-preview.mp3\"\n  ],\n  \"reference_images\": [\n    \"https://cdn.beatapi.io/samples/neon-singer.png\",\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"resolution\": \"720p\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 참조 이미지와 음성
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "kling-v4",
  "prompt": "The singer from @image_1 lifts the bottle from @image_2 toward the camera and says a short line in the voice of @voice_1",
  "aspect_ratio": "9:16",
  "duration": 8,
  "reference_audios": ["https://cdn.beatapi.io/samples/neon-singer-preview.mp3"],
  "reference_images": ["https://cdn.beatapi.io/samples/neon-singer.png", "https://cdn.beatapi.io/samples/smart-bottle.png"],
  "resolution": "720p"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/videos/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-v4",
  "prompt": "Restyle @video_1 as a neon-lit night scene and keep its camera movement",
  "duration": 10,
  "keep_original_sound": true,
  "reference_videos": [
    "https://your-cdn.example.com/clips/source.mp4"
  ],
  "resolution": "720p"
}
```

**Response**

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

**SDK Code**

```python 원래 소리를 유지하는 참조 영상
import requests

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

payload = {
    "model": "kling-v4",
    "prompt": "Restyle @video_1 as a neon-lit night scene and keep its camera movement",
    "duration": 10,
    "keep_original_sound": True,
    "reference_videos": ["https://your-cdn.example.com/clips/source.mp4"],
    "resolution": "720p"
}
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/videos/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"kling-v4","prompt":"Restyle @video_1 as a neon-lit night scene and keep its camera movement","duration":10,"keep_original_sound":true,"reference_videos":["https://your-cdn.example.com/clips/source.mp4"],"resolution":"720p"}'
};

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/videos/tasks"

	payload := strings.NewReader("{\n  \"model\": \"kling-v4\",\n  \"prompt\": \"Restyle @video_1 as a neon-lit night scene and keep its camera movement\",\n  \"duration\": 10,\n  \"keep_original_sound\": true,\n  \"reference_videos\": [\n    \"https://your-cdn.example.com/clips/source.mp4\"\n  ],\n  \"resolution\": \"720p\"\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/videos/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-v4\",\n  \"prompt\": \"Restyle @video_1 as a neon-lit night scene and keep its camera movement\",\n  \"duration\": 10,\n  \"keep_original_sound\": true,\n  \"reference_videos\": [\n    \"https://your-cdn.example.com/clips/source.mp4\"\n  ],\n  \"resolution\": \"720p\"\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/videos/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"kling-v4\",\n  \"prompt\": \"Restyle @video_1 as a neon-lit night scene and keep its camera movement\",\n  \"duration\": 10,\n  \"keep_original_sound\": true,\n  \"reference_videos\": [\n    \"https://your-cdn.example.com/clips/source.mp4\"\n  ],\n  \"resolution\": \"720p\"\n}")
  .asString();
```

```php 원래 소리를 유지하는 참조 영상
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/videos/tasks', [
  'body' => '{
  "model": "kling-v4",
  "prompt": "Restyle @video_1 as a neon-lit night scene and keep its camera movement",
  "duration": 10,
  "keep_original_sound": true,
  "reference_videos": [
    "https://your-cdn.example.com/clips/source.mp4"
  ],
  "resolution": "720p"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp 원래 소리를 유지하는 참조 영상
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/videos/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-v4\",\n  \"prompt\": \"Restyle @video_1 as a neon-lit night scene and keep its camera movement\",\n  \"duration\": 10,\n  \"keep_original_sound\": true,\n  \"reference_videos\": [\n    \"https://your-cdn.example.com/clips/source.mp4\"\n  ],\n  \"resolution\": \"720p\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 원래 소리를 유지하는 참조 영상
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "kling-v4",
  "prompt": "Restyle @video_1 as a neon-lit night scene and keep its camera movement",
  "duration": 10,
  "keep_original_sound": true,
  "reference_videos": ["https://your-cdn.example.com/clips/source.mp4"],
  "resolution": "720p"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/videos/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-v4",
  "prompt": "@singer walks across a neon stage holding @bottle and smiles at the camera",
  "aspect_ratio": "16:9",
  "duration": 6,
  "elements": [
    {
      "name": "singer",
      "description": "A performer in a silver jacket",
      "element_input_urls": [
        "https://your-cdn.example.com/elements/singer-front.png",
        "https://your-cdn.example.com/elements/singer-side.png"
      ],
      "tag": "character"
    },
    {
      "name": "bottle",
      "element_input_urls": [
        "https://your-cdn.example.com/elements/bottle-front.png",
        "https://your-cdn.example.com/elements/bottle-back.png"
      ],
      "tag": "prop"
    }
  ],
  "resolution": "720p"
}
```

**Response**

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

**SDK Code**

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

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

payload = {
    "model": "kling-v4",
    "prompt": "@singer walks across a neon stage holding @bottle and smiles at the camera",
    "aspect_ratio": "16:9",
    "duration": 6,
    "elements": [
        {
            "name": "singer",
            "description": "A performer in a silver jacket",
            "element_input_urls": ["https://your-cdn.example.com/elements/singer-front.png", "https://your-cdn.example.com/elements/singer-side.png"],
            "tag": "character"
        },
        {
            "name": "bottle",
            "element_input_urls": ["https://your-cdn.example.com/elements/bottle-front.png", "https://your-cdn.example.com/elements/bottle-back.png"],
            "tag": "prop"
        }
    ],
    "resolution": "720p"
}
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/videos/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"kling-v4","prompt":"@singer walks across a neon stage holding @bottle and smiles at the camera","aspect_ratio":"16:9","duration":6,"elements":[{"name":"singer","description":"A performer in a silver jacket","element_input_urls":["https://your-cdn.example.com/elements/singer-front.png","https://your-cdn.example.com/elements/singer-side.png"],"tag":"character"},{"name":"bottle","element_input_urls":["https://your-cdn.example.com/elements/bottle-front.png","https://your-cdn.example.com/elements/bottle-back.png"],"tag":"prop"}],"resolution":"720p"}'
};

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/videos/tasks"

	payload := strings.NewReader("{\n  \"model\": \"kling-v4\",\n  \"prompt\": \"@singer walks across a neon stage holding @bottle and smiles at the camera\",\n  \"aspect_ratio\": \"16:9\",\n  \"duration\": 6,\n  \"elements\": [\n    {\n      \"name\": \"singer\",\n      \"description\": \"A performer in a silver jacket\",\n      \"element_input_urls\": [\n        \"https://your-cdn.example.com/elements/singer-front.png\",\n        \"https://your-cdn.example.com/elements/singer-side.png\"\n      ],\n      \"tag\": \"character\"\n    },\n    {\n      \"name\": \"bottle\",\n      \"element_input_urls\": [\n        \"https://your-cdn.example.com/elements/bottle-front.png\",\n        \"https://your-cdn.example.com/elements/bottle-back.png\"\n      ],\n      \"tag\": \"prop\"\n    }\n  ],\n  \"resolution\": \"720p\"\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/videos/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-v4\",\n  \"prompt\": \"@singer walks across a neon stage holding @bottle and smiles at the camera\",\n  \"aspect_ratio\": \"16:9\",\n  \"duration\": 6,\n  \"elements\": [\n    {\n      \"name\": \"singer\",\n      \"description\": \"A performer in a silver jacket\",\n      \"element_input_urls\": [\n        \"https://your-cdn.example.com/elements/singer-front.png\",\n        \"https://your-cdn.example.com/elements/singer-side.png\"\n      ],\n      \"tag\": \"character\"\n    },\n    {\n      \"name\": \"bottle\",\n      \"element_input_urls\": [\n        \"https://your-cdn.example.com/elements/bottle-front.png\",\n        \"https://your-cdn.example.com/elements/bottle-back.png\"\n      ],\n      \"tag\": \"prop\"\n    }\n  ],\n  \"resolution\": \"720p\"\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/videos/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"kling-v4\",\n  \"prompt\": \"@singer walks across a neon stage holding @bottle and smiles at the camera\",\n  \"aspect_ratio\": \"16:9\",\n  \"duration\": 6,\n  \"elements\": [\n    {\n      \"name\": \"singer\",\n      \"description\": \"A performer in a silver jacket\",\n      \"element_input_urls\": [\n        \"https://your-cdn.example.com/elements/singer-front.png\",\n        \"https://your-cdn.example.com/elements/singer-side.png\"\n      ],\n      \"tag\": \"character\"\n    },\n    {\n      \"name\": \"bottle\",\n      \"element_input_urls\": [\n        \"https://your-cdn.example.com/elements/bottle-front.png\",\n        \"https://your-cdn.example.com/elements/bottle-back.png\"\n      ],\n      \"tag\": \"prop\"\n    }\n  ],\n  \"resolution\": \"720p\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/videos/tasks', [
  'body' => '{
  "model": "kling-v4",
  "prompt": "@singer walks across a neon stage holding @bottle and smiles at the camera",
  "aspect_ratio": "16:9",
  "duration": 6,
  "elements": [
    {
      "name": "singer",
      "description": "A performer in a silver jacket",
      "element_input_urls": [
        "https://your-cdn.example.com/elements/singer-front.png",
        "https://your-cdn.example.com/elements/singer-side.png"
      ],
      "tag": "character"
    },
    {
      "name": "bottle",
      "element_input_urls": [
        "https://your-cdn.example.com/elements/bottle-front.png",
        "https://your-cdn.example.com/elements/bottle-back.png"
      ],
      "tag": "prop"
    }
  ],
  "resolution": "720p"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

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

var client = new RestClient("https://api.beatapi.io/v1/videos/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-v4\",\n  \"prompt\": \"@singer walks across a neon stage holding @bottle and smiles at the camera\",\n  \"aspect_ratio\": \"16:9\",\n  \"duration\": 6,\n  \"elements\": [\n    {\n      \"name\": \"singer\",\n      \"description\": \"A performer in a silver jacket\",\n      \"element_input_urls\": [\n        \"https://your-cdn.example.com/elements/singer-front.png\",\n        \"https://your-cdn.example.com/elements/singer-side.png\"\n      ],\n      \"tag\": \"character\"\n    },\n    {\n      \"name\": \"bottle\",\n      \"element_input_urls\": [\n        \"https://your-cdn.example.com/elements/bottle-front.png\",\n        \"https://your-cdn.example.com/elements/bottle-back.png\"\n      ],\n      \"tag\": \"prop\"\n    }\n  ],\n  \"resolution\": \"720p\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

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

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "kling-v4",
  "prompt": "@singer walks across a neon stage holding @bottle and smiles at the camera",
  "aspect_ratio": "16:9",
  "duration": 6,
  "elements": [
    [
      "name": "singer",
      "description": "A performer in a silver jacket",
      "element_input_urls": ["https://your-cdn.example.com/elements/singer-front.png", "https://your-cdn.example.com/elements/singer-side.png"],
      "tag": "character"
    ],
    [
      "name": "bottle",
      "element_input_urls": ["https://your-cdn.example.com/elements/bottle-front.png", "https://your-cdn.example.com/elements/bottle-back.png"],
      "tag": "prop"
    ]
  ],
  "resolution": "720p"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.beatapi.io/v1/videos/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()
```