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

# Midjourney V8.2

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

모델 ID 하나로 Midjourney V8.2을 사용합니다. 텍스트와 이미지 프롬프트로 이미지 네 장을 생성한 뒤 그중 한 장을 변형하거나 업스케일하거나 네 장 전체를 다시 그릴 수 있고, 이미지를 리텍스처, 편집, 블렌드, 프롬프트 추출할 수도 있습니다.- 모든 Midjourney 작업에 모델 ID 하나를 씁니다. `action`으로 작업을 고르며 기본값은 `generate`입니다. Midjourney가 결과 아래에 보여 주는 버튼도 작업입니다.
- 비동기입니다. 생성 호출은 즉시 작업 ID를 반환합니다. `fast` 생성은 보통 1\~3분 안에 끝나며, 최대 10분까지 폴링하세요.
- 생성 한 번에 이미지 네 장이 반환됩니다. 후속 작업은 이전 작업을 `source_task_id`에 지정하고, 이미지를 고를 때는 그 위치를 `index`(1\~4)에 지정합니다.
- `--ar`, `--s`, `--sref`, `--no` 같은 Midjourney 파라미터는 `prompt`에 씁니다. 버전, 속도, 품질, 초안은 필드로 지정합니다.
- 호출당 가격이며 `speed`와 `quality`로 정해집니다. `upscale`와 `describe`는 낮은 고정 가격 하나입니다. 거부된 요청과 실패한 작업에는 비용이 청구되지 않습니다.
- 결과는 7일 후 삭제됩니다. 보관할 이미지는 다운로드하세요.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 이후의 재시도는 다시 실행됩니다.## 요청 처리 방식1) **작업 만들기** 아래 파라미터를 엔드포인트로 `POST`하세요. `201`은 작업이 접수되었고 가격만큼 잔액이 보류되었다는 뜻이며, 작업은 백그라운드에서 실행됩니다. `data.id`를 저장하세요.
2) **완료 기다리기** `status`가 `succeeded` 또는 `failed`가 될 때까지 `GET /v1/tasks/{task_id}`를 호출하고, 호출 사이에 `data.poll_after_seconds`만큼 기다리세요(이미지 5초, 영상 8초). 또는 `task.succeeded`와 `task.failed`에 대한 [웹훅](/webhooks)을 등록하세요. 처리 시간 초과로 중단된 작업은 이벤트를 보내지 않으므로 폴링은 대비책으로 유지하세요.
3) **결과 저장하기** `succeeded`이면 모든 `data.output.media[].url`을 다운로드해 필요한 파일을 저장하세요. BeatAPI는 결과 URL을 얼마 동안 사용할 수 있는지 보장하지 않습니다. `failed`이면 `data.error_code`와 `data.error_message`를 확인하세요. 보류된 금액은 잔액으로 돌아왔으며, `data.retryable`은 같은 요청을 다시 보내면 성공할 수 있는지 알려 줍니다.## 입력 모드| 모드      | 필수 입력                                        | 참고                                                                                                                                                     |
| ------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 생성      | `model`, `prompt`                            | 기본 작업입니다. 선택 항목: `images`(이미지 프롬프트 1\~5장), `aspect_ratio`, `quality`, `speed`, `draft`. 이미지 네 장을 반환합니다. `prompt`는 `images`에 링크가 두 개 이상일 때만 생략할 수 있습니다. |
| 변형      | `model`, `action`, `source_task_id`, `index` | 네 장 결과 중 한 장의 V 버튼입니다. 새 이미지 네 장을 반환합니다.                                                                                                               |
| 업스케일    | `model`, `action`, `source_task_id`, `index` | 네 장 결과에서 한 장을 골라 같은 픽셀 크기로 단독 반환합니다. 후속 작업은 할 수 없습니다.                                                                                                  |
| 다시 그리기  | `model`, `action`, `source_task_id`          | 네 장 결과의 프롬프트 전체를 새 이미지 네 장으로 다시 그립니다. `index` 없음.                                                                                                      |
| 리텍스처    | `model`, `action`, `images`, `prompt`        | 이미지는 정확히 한 장입니다. 구도는 유지하고 스타일을 바꿉니다. 이미지 네 장을 반환하며, 이들에는 후속 작업을 할 수 없습니다.                                                                              |
| 편집(베타)  | `model`, `action`, `images`, `prompt`        | 투명 영역이 있는 PNG 정확히 한 장이며, 그 부분만 다시 그립니다. 이미지 네 장을 반환하며, 이들에는 후속 작업을 할 수 없습니다.                                                                           |
| 블렌드     | `model`, `action`, `images`                  | 이미지 2\~5장을 한 장면으로 합칩니다. `aspect_ratio`는 `1:1`, `3:2` 또는 `2:3`입니다. Midjourney V7으로 렌더링됩니다.                                                              |
| 프롬프트 추출 | `model`, `action`, `images`                  | 이미지는 정확히 한 장입니다. `output.data.prompts`에 프롬프트 네 개를 반환하며 이미지는 반환하지 않습니다.                                                                                 |## 요청 파라미터### `model``string` · 필수실행할 모델입니다.**값**: `mj-v8.2`**값이 잘못된 경우**- 누락: `"model" is required`
- 알 수 없는 모델 ID: `"model" mj-v7 is not catalogued`
- 이 엔드포인트로 영상 모델을 보낸 경우: `"model" seedance-2.5 is served by POST /v1/videos/tasks, not this endpoint`### `prompt``string` · 선택midjourney.com과 같은 방식으로 그릴 내용을 씁니다. 먼저 설명을 쓰고, 이어서 `--ar 3:2 --s 250` 같은 Midjourney 파라미터를 씁니다. `retexture`와 `edit`에서는 새로운 모습을 설명합니다.**길이**: 1–2048자- `generate`에서는 필수입니다(`images`에 링크가 두 개 이상이면 예외). `retexture`와 `edit`에서도 필수입니다. 다른 작업은 받지 않습니다.
- `generate`에서 링크와 `--` 파라미터를 뺀 텍스트는 최대 1024자입니다.
- API가 필드로 지정하는 파라미터와 지원하지 않는 파라미터는 거부됩니다. 아래 파라미터 표를 참고하세요.**값이 잘못된 경우**- 이미지가 두 장 미만인 생성에서 생략함: `generate needs "prompt"; only two or more images may go without one`
- retexture 또는 edit에서 생략함: `"prompt" is required for action retexture`
- 받지 않는 작업과 함께 보냄: `prompt is not used by action upscale; leave it out`
- 비어 있거나 한도보다 긴 경우: `"prompt" has an unsupported length`
- 링크와 파라미터를 뺀 텍스트가 너무 김: `the prompt's text (without links and --parameters) is at most 1024 characters`
- 버전 파라미터: `remove --v from the prompt: the version is fixed at 8.2; leave it out`
- 속도 파라미터: `remove --fast from the prompt: set the speed field to fast instead`
- 소수 비율: `--ar takes whole numbers, like 139:100 instead of 1.39:1`
- `--q`가 1\~4 범위를 벗어남: `--q takes 1, 2, 3 or 4 (detail; 4 is the most detailed); for a bigger picture set quality hd`### `action``string` · 선택 · 기본값: `generate`실행할 작업입니다. 각 작업은 자신의 필드만 받습니다(위의 입력 모드 참고). 그 밖의 필드는 거부되므로 효과 없는 설정에 비용을 내지 않습니다.**허용 값**: `generate`, `variation`, `upscale`, `reroll`, `retexture`, `edit`, `blend`, `describe`  \
**기본값**: `generate`- `generate`는 새로 시작합니다. `variation`, `upscale`, `reroll`은 네 장 결과에 적용하며, 업스케일된 이미지에는 후속 작업을 할 수 없습니다.
- `retexture`, `edit`, `blend`, `describe`는 `images`에 보낸 자신의 이미지에서 시작합니다.
- 입력은 대소문자를 구분하지 않으며, 문서는 소문자로 표기합니다.**값이 잘못된 경우**- 목록에 없는 값: `"action" must be one of: [generate variation upscale reroll retexture edit blend describe]`
- 작업이 받지 않는 필드: `quality is not used by action retexture; leave it out`### `images``string[]` · 선택자신의 이미지를 공개 HTTPS 링크로 지정합니다. `generate`에서는 이미지 프롬프트(1~~5장), `retexture`, `edit`, `describe`에서는 정확히 한 장, `blend`에서는 2~~5장입니다.**항목 수**: 1–5  \
각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요.- 링크는 공개되어 있고 몇 초 안에 다운로드되어야 합니다. 로컬 파일은 `POST /v1/files`로 업로드하고 반환된 링크를 보내세요.
- `edit`에는 PNG를 보내고 바꿀 부분을 오려 내어 투명하게 하세요. 투명 영역이 없는 이미지(모든 JPEG 포함)도 그려지고 비용이 청구됩니다.
- 후속 작업(`variation`, `upscale`, `reroll`)은 `source_task_id`에 적용되며 `images`를 받지 않습니다.
- 오류 메시지의 위치는 0부터 시작합니다. `images[0]`이 첫 번째 링크입니다.**값이 잘못된 경우**- retexture, edit, blend, describe에서 누락: `"images" is required for action describe`
- blend에 필요한 수보다 적음: `action blend needs at least 2 image(s) in "images"`
- describe, retexture, edit에 두 장 이상: `action describe takes at most 1 image(s) in "images"`
- 다섯 장 초과: `"images" accepts at most 5 items`
- https\:// 링크가 아닌 경우: `"images[0]" must be a public HTTPS URL`### `aspect_ratio``string` · 선택이미지의 가로:세로 비율이며 `generate`와 `blend`에서 사용합니다.**허용 값**: `1:1`, `4:3`, `3:4`, `3:2`, `2:3`, `16:9`, `9:16`, `21:9`, `9:21`, `5:4`, `4:5`, `2:1`, `1:2`- 생성에서 생략하면 `1:1`로 그립니다.
- `blend`는 `1:1`(기본값), `3:2`, `2:3`만 받습니다.
- 다른 비율은 `prompt`에 정수로 `--ar W:H`를 쓰세요(예: `--ar 7:4`). 이 필드보다 우선합니다.**값이 잘못된 경우**- 목록에 없는 값: `"aspect_ratio" must be one of: [1:1 4:3 3:4 3:2 2:3 16:9 9:16 21:9 9:21 5:4 4:5 2:1 1:2]`
- blend에 다른 비율 지정: `"aspect_ratio" for blend is one of: 1:1, 3:2, 2:3`### `quality``string` · 선택 · 기본값: `standard``hd`는 표준 크기 대신 약 2K로 그립니다. 생성할 때 지정하며 나중에 추가할 수 없습니다.**허용 값**: `standard`, `hd`  \
**기본값**: `standard`- `fast`에서는 `hd`가 더 비싸고, `relax`에서는 가격이 같습니다.
- `upscale`는 그려진 픽셀 크기 그대로 이미지를 반환하며 확대하지 않습니다. 더 큰 이미지가 필요하면 첫 호출에서 `hd`를 지정하세요.
- 후속 작업은 원본 작업의 품질로 실행됩니다. 후속 작업에서는 이 필드를 생략하거나 같은 값을 보내세요.
- `retexture`, `edit`, `blend`, `describe`는 받지 않습니다.**값이 잘못된 경우**- 목록에 없는 값: `"quality" must be one of: [standard hd]`
- draft와 함께 사용: `draft cannot be combined with quality hd`
- 후속 작업이 원본 작업과 다른 품질을 요청함: `source_task_id was made at quality hd and a follow-up runs the same; leave quality out`### `speed``string` · 선택 · 기본값: `fast``fast`(기본값)는 보통 1~~3분 안에 생성을 마치고, `relax`는 2~~5분이 걸리며 더 저렴합니다.**허용 값**: `fast`, `relax`  \
**기본값**: `fast`- 후속 작업은 원본 작업의 속도로 실행되고 그 속도로 청구됩니다. 후속 작업에서는 이 필드를 생략하거나 같은 값을 보내세요.
- `describe`는 받지 않습니다.**값이 잘못된 경우**- 목록에 없는 값: `"speed" must be one of: [fast relax]`
- 후속 작업이 원본 작업과 다른 속도를 요청함: `source_task_id was made at speed relax and a follow-up runs the same; leave speed out`### `draft``boolean` · 선택`generate` 전용입니다. `true`이면 생성 한 번 가격으로 512 px 빠른 초안 24장을 반환하며, 본 렌더링 전에 프롬프트를 시험해 볼 때 씁니다.- 어느 `speed`에서나 동작하며 `quality` `hd`와 함께 쓸 수 없습니다.
- 초안에는 후속 작업을 할 수 없고 이미지를 고를 수도 없습니다. 프롬프트를 제대로 렌더링하려면 `draft` 없이 다시 보내세요. 초안 프롬프트에 `--seed N`을 쓰면 비슷하지만 같지는 않은 구도가 나옵니다.**값이 잘못된 경우**- 불리언이 아님: `"draft" must be a boolean`
- 초안에 후속 작업: `source_task_id is a draft, which takes no follow-up; send the prompt again without draft (add --seed N to keep a similar composition)`### `source_task_id``string` · 선택후속 작업용: 작업 대상인 자신의 이전 Midjourney 작업의 `id`입니다. 그 작업은 성공한 상태여야 합니다.- 먼저 그 작업의 `output.data.follow_ups`를 읽으세요. 결과가 받는 작업이 나열되어 있습니다. 그 밖의 후속 작업은 비용 없이 거부됩니다.
- 업스케일된 이미지에는 후속 작업을 할 수 없습니다. 변형하려면 그 이미지가 나온 네 장 결과의 `source_task_id`와 같은 `index`로 `variation`을 보내세요.
- `upscale`, `retexture`, `edit`, `describe`의 결과와 초안에는 후속 작업을 할 수 없습니다.**값이 잘못된 경우**- 작업 ID가 아님: `"source_task_id" must be the id of one of your earlier tasks: "task_" followed by 32 letters or digits`
- 후속 작업에서 누락: `"source_task_id" is required for action upscale: the id of your own Midjourney task it works on`
- 원본 작업이 아직 실행 중이거나 실패함: `source_task_id has not finished successfully; wait for it to succeed and try again`
- 다른 모델의 작업: `source_task_id was made by seedream-5.5, not Midjourney; name one of your Midjourney tasks`
- 업스케일된 이미지에 후속 작업: `an upscaled image takes no follow-up; to vary it, send action variation with source_task_id of its four-image result and the same index`
- retexture, edit, describe의 결과: `source_task_id is the result of retexture, which takes no follow-up`
- 같은 결과의 같은 이미지를 다시 업스케일함: `that image of source_task_id was already upscaled in task_Up4Rk9Ns2Wq7Zx5Mc8Hv1Lb6Tj3Fd0Gy; use that task's result`
- 그 결과의 follow\_ups에 없는 작업: `this result does not support action upscale; generate the image again and continue from the new result`### `index``integer` · 선택네 장 결과 중 어느 이미지에 적용할지, 1\~4입니다. 1부터 세며 원본 작업의 `output.media` 순서입니다.**범위**: 1–4- `upscale`와 `variation`에서 필수입니다.
- `reroll`과 `source_task_id` 없는 작업에서는 쓰지 않습니다.**값이 잘못된 경우**- upscale 또는 variation에서 누락: `"index" is required for action upscale`
- 1\~4 사이의 정수가 아님: `"index" is outside its supported range`### `callback_url``string` · 선택이 작업이 성공하거나 실패할 때 알림을 받을 주소입니다. 사용 중인 [웹훅 엔드포인트](/webhooks) 중 하나와 스킴, 호스트, 포트가 같은 공개 HTTPS URL이어야 하며, 그 엔드포인트의 `secret`으로 전송에 서명합니다.**길이**: 2048자 이하- 먼저 `POST /v1/webhooks`로 엔드포인트를 등록하세요. BeatAPI는 계정 웹훅과 같은 본문, 헤더, 재시도 규칙으로 `task.succeeded` 또는 `task.failed`를 보냅니다. 해당 이벤트를 구독한 계정 엔드포인트도 이를 받으며, 그 엔드포인트의 주소와 완전히 같으면 한 번만 알립니다.
- 서명 엔드포인트가 삭제·비활성화되거나 다른 호스트로 바뀌면 이 콜백은 무효가 됩니다.**값이 잘못된 경우**- 값이 문자열이 아님: `"callback_url" must be a string.`
- 주소가 2048자를 초과함: `"callback_url" must be at most 2048 characters.`
- URL이 아니거나 호스트가 없거나 `http` 또는 `https` 스킴이 없음: `"callback_url" must be a valid https URL.`
- `http`를 사용하거나 비공개 등 공개되지 않은 주소를 가리킴: `"callback_url" must be a public HTTPS URL.`
- 스킴, 호스트, 포트가 같은 활성 웹훅 엔드포인트가 없음: `"callback_url" must be on the host of one of your active webhook endpoints, whose secret signs it; register one with POST /v1/webhooks.`게이트웨이는 작업을 만들기 전에 다음 조합도 검사합니다.- action은 작업을 고르며 기본값은 generate입니다. 각 작업은 여기 나열된 필드만 받고, 그 밖의 필드는 거부됩니다.
- 거부된 요청(HTTP 400)과 실패한 작업에는 비용이 청구되지 않습니다.
- generate: prompt(images에 링크가 2개 이상이면 생략 가능), 선택 항목 images(이미지 프롬프트로 쓰는 공개 이미지 링크 1-5개), aspect\_ratio(생략 시 1:1), quality, speed, draft. 이미지 네 장을 반환합니다.
- quality hd는 생성 시 약 2K로 그립니다. 나중에 추가할 수 없으므로 더 큰 이미지가 필요하면 첫 호출에서 지정하세요.
- variation: 네 장 결과의 source\_task\_id와 index(1-4). 해당 이미지의 Midjourney V 버튼으로, 새 이미지 네 장을 반환합니다.
- upscale: 네 장 결과의 source\_task\_id와 index(1-4). 그 이미지를 골라 같은 픽셀 크기로 단독 반환하며(확대하지 않음), 업스케일된 이미지에는 후속 작업을 할 수 없습니다.
- reroll: 네 장 결과의 source\_task\_id, index 없음. 프롬프트 전체를 새 이미지 네 장으로 다시 그립니다.
- retexture와 edit: images(정확히 1장)와 prompt. retexture는 구도를 유지하고 프롬프트대로 스타일을 바꿉니다. edit(베타)은 PNG의 투명 영역을 다시 그리므로 바꿀 부분을 오려 내세요. 투명 영역이 없는 이미지(모든 JPEG)도 그려지고 청구됩니다. 둘 다 이미지 네 장을 반환하며 후속 작업은 할 수 없습니다.
- blend: images(2-5)와 선택 항목 aspect\_ratio 1:1(기본값), 3:2, 2:3. Midjourney V7으로 렌더링되므로 V8.2 이미지와 모습이 다를 수 있습니다. describe: images(정확히 1장), output.data.prompts에 프롬프트 네 개를 반환하며 이미지는 없습니다.
- index는 1부터 세며 원본 작업의 output.media 순서입니다. output.data.kind(grid, single, text)와 output.data.follow\_ups는 완료된 작업이 받는 작업을 나열합니다(예비 경로로 처리된 작업은 가끔 더 적거나 없음). 그 밖의 후속 작업은 비용 없이 거부되므로 연결을 계획하기 전에 확인하세요.
- 후속 작업은 원본 작업의 speed와 quality로 실행되며(둘 다 생략하거나 같은 값을 보냄) 그 설정의 새 이미지로 청구됩니다. 단, upscale와 describe는 고정 가격 하나입니다.
- 초안 결과에는 후속 작업을 할 수 없고 이미지를 고를 수도 없습니다. 프롬프트를 제대로 렌더링하려면 draft 없이 다시 보내세요(초안 프롬프트에 --seed N을 쓰면 비슷하지만 같지는 않은 구도가 나옴).
- Midjourney 파라미터는 midjourney.com처럼 prompt에 씁니다: --ar W:H 정수(aspect\_ratio보다 우선), --s 0-1000, --c 0-100, --seed 0-4294967295, --exp 0-100, --q 1-4, --raw, --no, --tile, --weird 0-3000, --iw 0-3, --sref(링크 또는 코드)와 --sw. generate에서 링크와 파라미터를 뺀 텍스트는 최대 1024자입니다.
- 버전(8.2), speed, quality, draft는 필드로만 지정합니다. 프롬프트에 --v, --niji, --fast, --relax, --turbo, --hd, --draft가 있으면 거부되며, 이 API가 지원하지 않는 --oref, --cref, --stop, --p, --bs, --repeat, --edit, --stealth, --public도 거부됩니다.
- speed fast(기본값)는 보통 1-3분, relax는 2-5분이며 더 저렴합니다. edit과 retexture는 최대 5분, upscale와 describe는 몇 초입니다. 최대 10분까지 폴링하세요. quality hd는 fast에서 더 비싸고 relax에서는 같습니다. draft는 어느 속도에서나 동작하며 생성 한 번 가격으로 512 px 빠른 이미지 24장을 반환하고 hd일 수 없습니다.
- 이미지 링크는 공개되어 있고 몇 초 안에 다운로드되어야 합니다. 로컬 파일은 POST /v1/files로 업로드하고 그 링크를 보내세요. 보관할 결과는 저장하세요. 이미지는 7일 후 삭제됩니다.## 작업 한눈에 보기모든 작업은 같은 엔드포인트의 새 작업입니다. 결과의 `output.data.kind`가 종류를 알려 줍니다: `grid`(이미지 네 장), `single`(업스케일된 이미지 한 장), `text`.| 액션          | 대상            | `model`과 `action` 외의 필드                                         | 반환값               |
| ----------- | ------------- | --------------------------------------------------------------- | ----------------- |
| `generate`  | 텍스트와 이미지 프롬프트 | `prompt`, `images`, `aspect_ratio`, `quality`, `speed`, `draft` | 이미지 네 장           |
| `variation` | 네 장 결과        | `source_task_id`, `index`, `speed`, `quality`                   | 이미지 네 장           |
| `upscale`   | 네 장 결과        | `source_task_id`, `index`, `speed`, `quality`                   | 이미지 한 장, 후속 작업 불가 |
| `reroll`    | 네 장 결과        | `source_task_id`, `speed`, `quality`                            | 이미지 네 장           |
| `retexture` | 내 이미지 한 장     | `images`, `prompt`, `speed`                                     | 이미지 네 장, 후속 작업 불가 |
| `edit`(베타)  | 내 PNG 한 장     | `images`, `prompt`, `speed`                                     | 이미지 네 장, 후속 작업 불가 |
| `blend`     | 내 이미지 2\~5장   | `images`, `aspect_ratio`, `speed`                               | 이미지 네 장           |
| `describe`  | 내 이미지 한 장     | `images`                                                        | 프롬프트 네 개, 이미지 없음  |- 작업이 받지 않는 필드는 무시되지 않고 거부됩니다. 그렇지 않으면 생성에 잘못 넣은 `index`가 효과 없이 청구됩니다.
- `blend`는 Midjourney V7으로 렌더링되므로 V8.2 이미지와 모습이 다를 수 있습니다.## 후속 작업 연결하기후속 작업은 자신의 완료된 Midjourney 작업 하나를 `source_task_id`에 지정합니다. 네 장 결과에 적용되며 `index`로 그중 한 장을 고릅니다. 1은 그 작업 `output.media`의 첫 항목, 4는 마지막 항목입니다.- `index`가 있는 `variation`: V 버튼으로, 그 이미지와 비슷한 새 이미지 네 장입니다.
- `index`가 있는 `upscale`: U 버튼으로, 그 이미지만 반환합니다. 같은 결과의 같은 이미지를 다시 업스케일하면 거부되며, 이미 그 이미지를 가진 작업을 알려 줍니다.
- `reroll`: 같은 프롬프트로 새 이미지 네 장입니다.업스케일된 이미지에는 후속 작업을 할 수 없습니다. 변형하려면 그 이미지가 나온 네 장 결과와 같은 `index`로 `variation`을 보내세요. `retexture`, `edit`, `describe`의 결과와 초안에도 후속 작업을 할 수 없습니다.연결을 계획하기 전에 이어 갈 작업의 `output.data.follow_ups`를 읽으세요. 그 결과가 받는 작업이 정확히 나열되어 있습니다. 예비 경로에서 만들어진 결과는 목록이 더 적거나 비어 있을 수 있습니다. 그 밖의 후속 작업은 비용 없이 거부되며, 이미지를 다시 생성해 새 결과에서 이어 가면 됩니다.후속 작업은 원본 작업의 속도와 품질로 실행되고 그 기준으로 청구됩니다. `speed`와 `quality`는 생략하거나 같은 값을 보내세요. 다른 값은 거부됩니다.## 속도, 품질, 초안| 설정                  | 동작                                                 | 가격                            |
| ------------------- | -------------------------------------------------- | ----------------------------- |
| `speed` `fast`(기본값) | 생성은 보통 1\~3분 걸립니다.                                 | 더 높은 요금                       |
| `speed` `relax`     | 보통 2\~5분입니다.                                       | 더 낮은 요금                       |
| `quality` `hd`      | 약 2K로 그립니다. 생성할 때 지정하며 나중에 추가할 수 없습니다.             | `fast`에서는 더 높고, `relax`에서는 같음 |
| `draft` `true`      | 프롬프트를 시험해 보는 512 px 빠른 이미지 24장. 후속 작업 불가, `hd` 불가. | 그 속도의 생성 한 번 가격               |- `edit`과 `retexture`는 최대 5분 걸릴 수 있고, `upscale`와 `describe`는 몇 초면 됩니다. 작업을 포기하기 전에 최대 10분까지 폴링하세요.
- `upscale`는 이미지를 고르는 것이며 확대하지 않습니다. 업스케일된 이미지는 그려진 픽셀 크기 그대로입니다.## 프롬프트에 쓰는 Midjourney 파라미터Midjourney 고유 파라미터는 midjourney.com처럼 `prompt` 끝에 쓰세요. 쓴 그대로 전달됩니다.| 파라미터              | 값                     | 참고                                                             |
| ----------------- | --------------------- | -------------------------------------------------------------- |
| `--ar W:H`        | 정수(예: `7:4`)          | `aspect_ratio`보다 우선합니다. `1.39:1` 같은 소수는 거부되므로 `139:100`으로 쓰세요. |
| `--s`             | 0\~1000               | 스타일 강도.                                                        |
| `--c`             | 0\~100                | 카오스: 네 장 이미지가 서로 얼마나 다른지.                                      |
| `--seed`          | 0\~4294967295         | 재현 가능한 초기 노이즈.                                                 |
| `--q`             | 1\~4                  | 디테일. 4가 가장 정밀합니다. 더 큰 이미지에는 `quality` `hd`를 쓰세요.               |
| `--sref`와 `--sw`  | 이미지 링크 또는 스타일 코드, 가중치 | 스타일 참조와 그 가중치.                                                 |
| `--iw`            | 0\~3                  | `images`의 이미지 프롬프트 가중치.                                        |
| `--exp`           | 0\~100                | 실험적 미학.                                                        |
| `--weird`         | 0\~3000               | 색다른 결과.                                                        |
| `--no`            | 단어                    | 제외할 내용.                                                        |
| `--raw`, `--tile` | 값 없음                  | 기본 스타일 적용을 줄임, 이음매 없는 타일.                                      |- 버전(8.2), 속도, 품질, 초안은 필드로 지정합니다. 프롬프트에 `--v`, `--niji`, `--fast`, `--relax`, `--turbo`, `--hd`, `--draft`가 있으면 거부됩니다.
- 이 API가 지원하지 않아 거부됨: `--oref`, `--cref`, `--stop`, `--p`, `--bs`, `--repeat`, `--edit`, `--stealth`, `--public`.
- `generate`에서 링크와 파라미터를 뺀 텍스트는 최대 1024자입니다.## 결과와 보관 기간이미지는 7일 동안 저장된 후 삭제됩니다. 보관할 이미지는 다운로드하세요. `describe`는 파일을 저장하지 않으며, 프롬프트 네 개는 `output.data.prompts`에 있습니다.보내는 이미지 링크는 공개되어 있고 몇 초 안에 다운로드되어야 합니다. 가져올 수 없는 링크는 작업을 실패시키며, 실패한 작업에는 비용이 청구되지 않습니다.## 요청 예시```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": "mj-v8.2",
  "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250",
  "aspect_ratio": "16:9"
}'
``````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": "mj-v8.2",
      "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250",
      "aspect_ratio": "16:9"
    },
    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": "mj-v8.2",
    "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250",
    "aspect_ratio": "16:9"
  }),
});
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);
```### 이미지 네 장 생성기본 작업입니다. Midjourney 파라미터는 프롬프트 끝에 씁니다.```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": "mj-v8.2",
  "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250",
  "aspect_ratio": "16:9"
}'
```### 3번 이미지 변형V3 버튼: 위 생성 결과의 세 번째 이미지와 비슷한 새 이미지 네 장입니다.```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": "mj-v8.2",
  "action": "variation",
  "source_task_id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
  "index": 3
}'
```### 2번 이미지 업스케일변형 결과에서 U2 버튼: 두 번째 이미지만 그려진 픽셀 크기 그대로 꺼냅니다. 후속 작업은 할 수 없습니다.```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": "mj-v8.2",
  "action": "upscale",
  "source_task_id": "task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E",
  "index": 2
}'
```### 이미지의 프롬프트 추출비슷한 이미지를 그릴 수 있는 프롬프트 네 개를 `output.data.prompts`에 반환합니다.```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": "mj-v8.2",
  "action": "describe",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ]
}'
```### relax에서 이미지 프롬프트와 스타일 참조로 HD 생성제품 이미지를 이미지 프롬프트로, 스타일 참조를 프롬프트에 넣습니다. `relax`가 더 저렴하며 이때 `hd`는 추가 비용이 없습니다.```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": "mj-v8.2",
  "prompt": "The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "aspect_ratio": "4:5",
  "speed": "relax",
  "quality": "hd"
}'
```### 이미지 두 장 블렌드이미지를 한 장면으로 합치며 Midjourney V7으로 렌더링합니다. 프롬프트는 없습니다.```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": "mj-v8.2",
  "action": "blend",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ],
  "aspect_ratio": "3:2"
}'
```## 응답### 작업 생성(201)작업 객체입니다. 작업이 성공할 때까지 `output`는 `null`입니다. '실행 중'으로 표시된 필드는 작업이 끝나면 사라집니다.```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "media_type": "image",
    "model": "mj-v8.2",
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "poll_after_seconds": 5,
    "output": null,
    "usage": {
      "credits_reserved": 0.08,
      "credits_settled": 0,
      "credits_refunded": 0,
      "credits_charged": 0.08
    },
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "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": "mj-v8.2",
    "capability_version": 1,
    "media_type": "image",
    "model": "mj-v8.2",
    "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"
        },
        {
          "type": "image",
          "url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/1.png",
          "mime_type": "image/png"
        },
        {
          "type": "image",
          "url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/2.png",
          "mime_type": "image/png"
        },
        {
          "type": "image",
          "url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/3.png",
          "mime_type": "image/png"
        }
      ],
      "url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/0.png",
      "r2_url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/0.png",
      "data": {
        "kind": "grid",
        "follow_ups": [
          "variation",
          "upscale",
          "reroll"
        ]
      }
    },
    "usage": {
      "credits_reserved": 0.08,
      "credits_settled": 0.08,
      "credits_refunded": 0,
      "credits_charged": 0.08
    },
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null
  }
}
```#### 출력 필드| 필드                         | 타입         | 설명                                                               |
| -------------------------- | ---------- | ---------------------------------------------------------------- |
| `output.media`             | `object[]` | 이미지: grid는 네 장, upscale는 한 장, describe는 없음. `index`는 이를 1부터 셉니다. |
| `output.media[].type`      | `string`   | 항상 `image`.                                                      |
| `output.media[].url`       | `string`   | 저장된 이미지의 HTTPS 링크입니다. 7일 후 삭제되므로 보관할 것은 다운로드하세요.                 |
| `output.media[].mime_type` | `string`   | 저장된 파일 형식이며 `image/png`입니다.                                      |
| `output.url`               | `string`   | 주요 결과물: 첫 이미지 링크입니다. describe에서는 비어 있습니다.                        |
| `output.r2_url`            | `string`   | `output.url`의 이전 이름이며 값은 같습니다. 읽어야 할 필드는 `output.url`입니다.        |
| `output.data.kind`         | `string`   | `grid`(이미지 네 장), `single`(업스케일된 이미지 한 장) 또는 `text`(describe).    |
| `output.data.follow_ups`   | `string[]` | 이 결과를 `source_task_id`로 쓸 때 받는 작업입니다. 후속 작업이 불가능하면 비어 있습니다.      |
| `output.data.prompts`      | `string[]` | describe 전용: 프롬프트 네 개.                                           |### 실패한 작업실패한 작업도 `GET /v1/tasks/{task_id}`에서는 HTTP 200입니다. 실패 정보는 본문에 있습니다. 보류 금액이 전액 환불되므로 과금되지 않습니다.```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "media_type": "image",
    "model": "mj-v8.2",
    "status": "failed",
    "stage": "failed",
    "created_at": 1791993600,
    "updated_at": 1791993690,
    "completed_at": 1791993690,
    "output": null,
    "usage": {
      "credits_reserved": 0.08,
      "credits_settled": 0,
      "credits_refunded": 0.08,
      "credits_charged": 0
    },
    "retryable": true,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": "processing_failed",
    "error_message": "The task failed during processing on our side. Retry; a failed task is refunded.",
    "error": {
      "code": "processing_failed",
      "message": "The task failed during processing on our side. Retry; a failed task is refunded.",
      "retryable": true
    }
  }
}
```| 필드                   | 타입        | 설명                                                                                                                                                                                           |
| -------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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.error`         | `object`  | 실패한 작업에만 있습니다. `code`, `message`, `retryable`을 하나의 객체로 묶은 것이며 값은 `data.error_code`, `data.error_message`, `data.retryable`과 같습니다.                                                            |
| `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": "mj-v8.2",
  "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250",
  "aspect_ratio": "16:9"
})
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"])
```## 과금- 호출 한 번이 작업 하나이며 가격은 `speed`와 `quality`로 정해집니다(아래 표). 생성, 변형, 다시 그리기, 리텍스처, 편집, 블렌드, 초안은 반환되는 이미지 수와 관계없이 그 설정의 호출 한 번 가격입니다.
- 후속 작업은 원본 작업의 속도와 품질로 청구됩니다. `upscale`와 `describe`는 어떤 속도에서도 고정 가격 하나입니다.
- 가격은 작업 생성 시 예약됩니다. HTTP 400으로 거부된 요청은 비용이 없고, 실패한 작업은 예약액을 전액 돌려받습니다. 이때 `credits_refunded`는 `credits_reserved`와 같습니다.
- 투명 영역이 없는 이미지로 한 `edit`도 그려지고 청구됩니다.현재 정가이며 [가격](https://beatapi.io/pricing) 페이지와 같습니다. 별도 할인 계약이 있는 계정은 더 적게 지불하며, 실제 청구 금액은 항상 작업의 `data.usage`에서 확인할 수 있습니다.| 옵션                 | 정가(USD) |
| ------------------ | ------- |
| 이미지 1장 · fast\_hd  | \$0.11  |
| 이미지 1장 · relax     | \$0.055 |
| 이미지 1장 · relax\_hd | \$0.055 |
| 이미지 1장 · upscale   | \$0.02  |
| 이미지 1장 · describe  | \$0.02  |
| 이미지 1장 · fast      | \$0.08  |## 자주 발생하는 오류| 오류 또는 증상                                                                                                                                      | 원인                                                                                 | 해결 방법                                                     |
| --------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------- |
| 400 `"index" is required for action upscale`                                                                                                  | 고를 이미지를 지정하지 않은 업스케일.                                                              | `index`에 1\~4(원본 작업 `output.media`에서의 위치)를 보내세요.          |
| 400 `an upscaled image takes no follow-up; to vary it, send action variation with source_task_id of its four-image result and the same index` | 업스케일 결과에 후속 작업을 보냄.                                                                | 네 장 결과 작업의 `id`와 같은 `index`로 `variation`을 보내세요.           |
| 400 `that image of source_task_id was already upscaled in task_Up4Rk9Ns2Wq7Zx5Mc8Hv1Lb6Tj3Fd0Gy; use that task's result`                      | 같은 결과의 같은 이미지를 이미 업스케일했습니다.                                                        | 메시지에 나온 작업의 결과를 읽으세요. 거부된 요청에는 비용이 청구되지 않습니다.             |
| 400 `prompt is not used by action upscale; leave it out`                                                                                      | 작업이 받지 않는 필드.                                                                      | 그 작업에 나열된 필드만 보내세요.                                       |
| 400 `remove --v from the prompt: the version is fixed at 8.2; leave it out`                                                                   | midjourney.com에서 복사한 프롬프트에 `--v`, `--fast`, `--hd` 또는 이 API가 필드로 지정하는 다른 파라미터가 있음. | 그것을 지우고 필드(`speed`, `quality`, `draft`)를 쓰세요.             |
| 400 `source_task_id is a draft, which takes no follow-up; send the prompt again without draft (add --seed N to keep a similar composition)`   | 초안 결과에 후속 작업.                                                                      | `draft` 없이 프롬프트를 다시 보내세요.                                 |
| 400 `source_task_id was made at speed relax and a follow-up runs the same; leave speed out`                                                   | 후속 작업의 `speed` 또는 `quality`가 원본 작업과 다름.                                            | 후속 작업에서는 두 필드를 모두 생략하세요.                                  |
| `edit` 후 이미지 네 장이 바뀌지 않은 것처럼 보임                                                                                                               | 이미지에 투명 영역이 없어 다시 그릴 부분이 없었습니다. 그래도 청구되었습니다.                                       | 바꿀 부분을 투명하게 만든 PNG를 보내세요.                                 |
| 이미지를 보낸 뒤 작업이 `failed`됨                                                                                                                       | 링크가 웹 페이지, 로그인 페이지, 만료된 URL을 열었거나 몇 초 안에 다운로드되지 않았습니다.                             | 이미지 파일로 직접 연결하거나 `POST /v1/files`로 업로드하세요. 비용은 청구되지 않습니다. |
| 작업이 `content_policy_violation`과 함께 `failed`                                                                                                   | 프롬프트 또는 이미지가 모더레이션에서 거부되었습니다.                                                      | 프롬프트나 이미지를 바꾸세요. 그대로 재시도하면 다시 실패하며, 과금되지 않습니다.            |
| 이미지 링크가 더 이상 열리지 않음                                                                                                                           | 결과는 7일 후 삭제됩니다.                                                                    | 작업이 성공하면 바로 결과를 다운로드하세요.                                  |## HTTP 오류 요약작업이 생성되기 전의 오류는 2xx가 아닌 응답으로 오며 과금되지 않습니다. `error.code` 또는 `error.retryable`로 분기하세요. `message`에 문제가 표시됩니다. 전체 목록과 재시도 정책은 [오류](/errors)에 있습니다.```json
{
  "error": {
    "code": "bad_request",
    "message": "\"prompt\" is required",
    "retryable": false,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV"
  }
}
```| 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/mj-v8-2

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

- `model` (enum, required) — 실행할 모델입니다. **값**: `mj-v8.2` **값이 잘못된 경우** - 누락: `"model" is required` - 알 수 없는 모델 ID: `"model" mj-v7 is not catalogued` - 이 엔드포인트로 영상 모델을 보낸 경우: `"model" seedance-2.5 is served by POST /v1/videos/tasks, not this endpoint`
  - Allowed values: `mj-v8.2`
- `action` (enum, optional, default: generate) — 실행할 작업입니다. 각 작업은 자신의 필드만 받습니다(위의 입력 모드 참고). 그 밖의 필드는 거부되므로 효과 없는 설정에 비용을 내지 않습니다. **허용 값**: `generate`, `variation`, `upscale`, `reroll`, `retexture`, `edit`, `blend`, `describe` **기본값**: `generate` - `generate`는 새로 시작합니다. `variation`, `upscale`, `reroll`은 네 장 결과에 적용하며, 업스케일된 이미지에는 후속 작업을 할 수 없습니다. - `retexture`, `edit`, `blend`, `describe`는 `images`에 보낸 자신의 이미지에서 시작합니다. - 입력은 대소문자를 구분하지 않으며, 문서는 소문자로 표기합니다. **값이 잘못된 경우** - 목록에 없는 값: `"action" must be one of: [generate variation upscale reroll retexture edit blend describe]` - 작업이 받지 않는 필드: `quality is not used by action retexture; leave it out`
  - Allowed values: `generate`, `variation`, `upscale`, `reroll`, `retexture`, `edit`, `blend`, `describe`
- `aspect_ratio` (enum, optional) — 이미지의 가로:세로 비율이며 `generate`와 `blend`에서 사용합니다. **허용 값**: `1:1`, `4:3`, `3:4`, `3:2`, `2:3`, `16:9`, `9:16`, `21:9`, `9:21`, `5:4`, `4:5`, `2:1`, `1:2` - 생성에서 생략하면 `1:1`로 그립니다. - `blend`는 `1:1`(기본값), `3:2`, `2:3`만 받습니다. - 다른 비율은 `prompt`에 정수로 `--ar W:H`를 쓰세요(예: `--ar 7:4`). 이 필드보다 우선합니다. **값이 잘못된 경우** - 목록에 없는 값: `"aspect_ratio" must be one of: [1:1 4:3 3:4 3:2 2:3 16:9 9:16 21:9 9:21 5:4 4:5 2:1 1:2]` - blend에 다른 비율 지정: `"aspect_ratio" for blend is one of: 1:1, 3:2, 2:3`
  - Allowed values: `1:1`, `4:3`, `3:4`, `3:2`, `2:3`, `16:9`, `9:16`, `21:9`, `9:21`, `5:4`, `4:5`, `2:1`, `1:2`
- `draft` (boolean, optional) — `generate` 전용입니다. `true`이면 생성 한 번 가격으로 512 px 빠른 초안 24장을 반환하며, 본 렌더링 전에 프롬프트를 시험해 볼 때 씁니다. - 어느 `speed`에서나 동작하며 `quality` `hd`와 함께 쓸 수 없습니다. - 초안에는 후속 작업을 할 수 없고 이미지를 고를 수도 없습니다. 프롬프트를 제대로 렌더링하려면 `draft` 없이 다시 보내세요. 초안 프롬프트에 `--seed N`을 쓰면 비슷하지만 같지는 않은 구도가 나옵니다. **값이 잘못된 경우** - 불리언이 아님: `"draft" must be a boolean` - 초안에 후속 작업: `source_task_id is a draft, which takes no follow-up; send the prompt again without draft (add --seed N to keep a similar composition)`
- `images` (list of string, optional) — 자신의 이미지를 공개 HTTPS 링크로 지정합니다. `generate`에서는 이미지 프롬프트(1~5장), `retexture`, `edit`, `describe`에서는 정확히 한 장, `blend`에서는 2~5장입니다. **항목 수**: 1–5 각 항목은 공개 `https://` URL입니다. 로컬 파일은 `POST /v1/files`로 [먼저 업로드](/quick-guide#upload-an-input-file)한 뒤 반환된 `data.url`을 전달하세요. - 링크는 공개되어 있고 몇 초 안에 다운로드되어야 합니다. 로컬 파일은 `POST /v1/files`로 업로드하고 반환된 링크를 보내세요. - `edit`에는 PNG를 보내고 바꿀 부분을 오려 내어 투명하게 하세요. 투명 영역이 없는 이미지(모든 JPEG 포함)도 그려지고 비용이 청구됩니다. - 후속 작업(`variation`, `upscale`, `reroll`)은 `source_task_id`에 적용되며 `images`를 받지 않습니다. - 오류 메시지의 위치는 0부터 시작합니다. `images[0]`이 첫 번째 링크입니다. **값이 잘못된 경우** - retexture, edit, blend, describe에서 누락: `"images" is required for action describe` - blend에 필요한 수보다 적음: `action blend needs at least 2 image(s) in "images"` - describe, retexture, edit에 두 장 이상: `action describe takes at most 1 image(s) in "images"` - 다섯 장 초과: `"images" accepts at most 5 items` - https:// 링크가 아닌 경우: `"images[0]" must be a public HTTPS URL`
- `index` (integer, optional) — 네 장 결과 중 어느 이미지에 적용할지, 1~4입니다. 1부터 세며 원본 작업의 `output.media` 순서입니다. **범위**: 1–4 - `upscale`와 `variation`에서 필수입니다. - `reroll`과 `source_task_id` 없는 작업에서는 쓰지 않습니다. **값이 잘못된 경우** - upscale 또는 variation에서 누락: `"index" is required for action upscale` - 1~4 사이의 정수가 아님: `"index" is outside its supported range`
- `prompt` (string, optional) — midjourney.com과 같은 방식으로 그릴 내용을 씁니다. 먼저 설명을 쓰고, 이어서 `--ar 3:2 --s 250` 같은 Midjourney 파라미터를 씁니다. `retexture`와 `edit`에서는 새로운 모습을 설명합니다. **길이**: 1–2048자 - `generate`에서는 필수입니다(`images`에 링크가 두 개 이상이면 예외). `retexture`와 `edit`에서도 필수입니다. 다른 작업은 받지 않습니다. - `generate`에서 링크와 `--` 파라미터를 뺀 텍스트는 최대 1024자입니다. - API가 필드로 지정하는 파라미터와 지원하지 않는 파라미터는 거부됩니다. 아래 파라미터 표를 참고하세요. **값이 잘못된 경우** - 이미지가 두 장 미만인 생성에서 생략함: `generate needs "prompt"; only two or more images may go without one` - retexture 또는 edit에서 생략함: `"prompt" is required for action retexture` - 받지 않는 작업과 함께 보냄: `prompt is not used by action upscale; leave it out` - 비어 있거나 한도보다 긴 경우: `"prompt" has an unsupported length` - 링크와 파라미터를 뺀 텍스트가 너무 김: `the prompt's text (without links and --parameters) is at most 1024 characters` - 버전 파라미터: `remove --v from the prompt: the version is fixed at 8.2; leave it out` - 속도 파라미터: `remove --fast from the prompt: set the speed field to fast instead` - 소수 비율: `--ar takes whole numbers, like 139:100 instead of 1.39:1` - `--q`가 1~4 범위를 벗어남: `--q takes 1, 2, 3 or 4 (detail; 4 is the most detailed); for a bigger picture set quality hd`
- `quality` (enum, optional, default: standard) — `hd`는 표준 크기 대신 약 2K로 그립니다. 생성할 때 지정하며 나중에 추가할 수 없습니다. **허용 값**: `standard`, `hd` **기본값**: `standard` - `fast`에서는 `hd`가 더 비싸고, `relax`에서는 가격이 같습니다. - `upscale`는 그려진 픽셀 크기 그대로 이미지를 반환하며 확대하지 않습니다. 더 큰 이미지가 필요하면 첫 호출에서 `hd`를 지정하세요. - 후속 작업은 원본 작업의 품질로 실행됩니다. 후속 작업에서는 이 필드를 생략하거나 같은 값을 보내세요. - `retexture`, `edit`, `blend`, `describe`는 받지 않습니다. **값이 잘못된 경우** - 목록에 없는 값: `"quality" must be one of: [standard hd]` - draft와 함께 사용: `draft cannot be combined with quality hd` - 후속 작업이 원본 작업과 다른 품질을 요청함: `source_task_id was made at quality hd and a follow-up runs the same; leave quality out`
  - Allowed values: `standard`, `hd`
- `source_task_id` (string, optional) — 후속 작업용: 작업 대상인 자신의 이전 Midjourney 작업의 `id`입니다. 그 작업은 성공한 상태여야 합니다. - 먼저 그 작업의 `output.data.follow_ups`를 읽으세요. 결과가 받는 작업이 나열되어 있습니다. 그 밖의 후속 작업은 비용 없이 거부됩니다. - 업스케일된 이미지에는 후속 작업을 할 수 없습니다. 변형하려면 그 이미지가 나온 네 장 결과의 `source_task_id`와 같은 `index`로 `variation`을 보내세요. - `upscale`, `retexture`, `edit`, `describe`의 결과와 초안에는 후속 작업을 할 수 없습니다. **값이 잘못된 경우** - 작업 ID가 아님: `"source_task_id" must be the id of one of your earlier tasks: "task_" followed by 32 letters or digits` - 후속 작업에서 누락: `"source_task_id" is required for action upscale: the id of your own Midjourney task it works on` - 원본 작업이 아직 실행 중이거나 실패함: `source_task_id has not finished successfully; wait for it to succeed and try again` - 다른 모델의 작업: `source_task_id was made by seedream-5.5, not Midjourney; name one of your Midjourney tasks` - 업스케일된 이미지에 후속 작업: `an upscaled image takes no follow-up; to vary it, send action variation with source_task_id of its four-image result and the same index` - retexture, edit, describe의 결과: `source_task_id is the result of retexture, which takes no follow-up` - 같은 결과의 같은 이미지를 다시 업스케일함: `that image of source_task_id was already upscaled in task_Up4Rk9Ns2Wq7Zx5Mc8Hv1Lb6Tj3Fd0Gy; use that task's result` - 그 결과의 follow_ups에 없는 작업: `this result does not support action upscale; generate the image again and continue from the new result`
- `speed` (enum, optional, default: fast) — `fast`(기본값)는 보통 1~3분 안에 생성을 마치고, `relax`는 2~5분이 걸리며 더 저렴합니다. **허용 값**: `fast`, `relax` **기본값**: `fast` - 후속 작업은 원본 작업의 속도로 실행되고 그 속도로 청구됩니다. 후속 작업에서는 이 필드를 생략하거나 같은 값을 보내세요. - `describe`는 받지 않습니다. **값이 잘못된 경우** - 목록에 없는 값: `"speed" must be one of: [fast relax]` - 후속 작업이 원본 작업과 다른 속도를 요청함: `source_task_id was made at speed relax and a follow-up runs the same; leave speed out`
  - Allowed values: `fast`, `relax`
- `callback_url` (string, optional) — 이 작업이 성공하거나 실패할 때 알림을 받을 주소입니다. 사용 중인 [웹훅 엔드포인트](/webhooks) 중 하나와 스킴, 호스트, 포트가 같은 공개 HTTPS URL이어야 하며, 그 엔드포인트의 `secret`으로 전송에 서명합니다. **길이**: 2048자 이하 - 먼저 `POST /v1/webhooks`로 엔드포인트를 등록하세요. BeatAPI는 계정 웹훅과 같은 본문, 헤더, 재시도 규칙으로 `task.succeeded` 또는 `task.failed`를 보냅니다. 해당 이벤트를 구독한 계정 엔드포인트도 이를 받으며, 그 엔드포인트의 주소와 완전히 같으면 한 번만 알립니다. - 서명 엔드포인트가 삭제·비활성화되거나 다른 호스트로 바뀌면 이 콜백은 무효가 됩니다. **값이 잘못된 경우** - 값이 문자열이 아님: `"callback_url" must be a string.` - 주소가 2048자를 초과함: `"callback_url" must be at most 2048 characters.` - URL이 아니거나 호스트가 없거나 `http` 또는 `https` 스킴이 없음: `"callback_url" must be a valid https URL.` - `http`를 사용하거나 비공개 등 공개되지 않은 주소를 가리킴: `"callback_url" must be a public HTTPS URL.` - 스킴, 호스트, 포트가 같은 활성 웹훅 엔드포인트가 없음: `"callback_url" must be on the host of one of your active webhook endpoints, whose secret signs it; register one with POST /v1/webhooks.`

## Response

### 201

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

- `data` (QueuedTask, required) — 접수되었거나 현재의 BeatAPI 작업 상태입니다.

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

### QueuedTask

- `id` (string, required) — 폴링과 지원 요청에 쓰는 안정적인 BeatAPI 작업 ID입니다.
- `object` (enum, required) — 객체 구분자이며 항상 `task`입니다.
  - Allowed values: `task`
- `task_kind` (enum, required) — 어떤 기능 필드가 있는지 결정하는 공개 작업 계열입니다. `data`는 작업으로 실행되는 데이터 기능(`data:web.research`)이며 `POST /v1/capabilities/run`으로 폴링합니다.
  - Allowed values: `workflow`, `effect`, `image`, `video`, `audio`, `data`
- `capability_id` (string, required) — 작업 접수 시 선택된 안정적인 BeatAPI 워크플로, 이펙트, 생성 모델 또는 데이터 기능 ID(예: `web.research`)입니다.
- `capability_version` (integer, required) — 항상 `1`.
- `status` (enum, required) — 현재 작업 수명 주기 상태입니다. `succeeded` 또는 `failed`에서 폴링을 멈추세요. Music Video는 수동 조치가 필요할 수도 있습니다.
  - Allowed values: `queued`, `processing`, `storyboard_ready`, `requires_action`, `editing`, `composing`, `succeeded`, `failed`
- `stage` (enum, required) — 항상 `status`를 반복합니다. 호환성을 위해 유지되며, `status`를 읽으세요.
  - Allowed values: `queued`, `processing`, `storyboard_ready`, `requires_action`, `editing`, `composing`, `succeeded`, `failed`
- `created_at` (integer, required) — BeatAPI가 작업을 접수한 Unix 타임스탬프입니다.
- `updated_at` (integer, required) — 최근 작업 업데이트의 Unix 타임스탬프입니다.
- `completed_at` (integer, required, nullable) — 종료 Unix 타임스탬프이며, 작업 진행 중에는 null입니다.
- `output` (QueuedTaskOutput, required, nullable) — 작업이 성공할 때까지 출력은 null입니다.
- `request_id` (string, required) — 로그와 BeatAPI 지원 요청용으로 보관할 상관관계 ID입니다.
- `error_code` (string, required, nullable) — 기계가 읽을 수 있는 종료 실패 코드이며, 기록된 작업 실패가 없으면 null입니다. `task_cancelled`는 모델 대기열에서 기다리는 동안 취소한 작업을 나타냅니다.
- `error_message` (string, required, nullable) — 사람이 읽을 수 있는 종료 실패 상세 내용이며, 기록된 작업 실패가 없으면 null입니다.
- `workflow` (enum, optional) — 워크플로 작업에 있으며, 선택된 BeatAPI 워크플로를 식별합니다.
  - Allowed values: `music-video`, `ecommerce-video`, `video-analysis`
- `effect_id` (string, optional) — 이펙트 작업에 있으며, 선택된 안정적인 이펙트 ID입니다.
- `effect_version` (integer, optional) — 이펙트 작업에 있으며, 처리에 사용된 변경 불가능한 이펙트 버전입니다.
- `media_type` (enum, optional) — task_kind가 image 또는 video일 때 있습니다.
  - Allowed values: `image`, `video`, `audio`
- `model` (string, optional) — 안정적인 BeatAPI 모델 별칭입니다. 내부 실행 라우팅과 독립적입니다.
- `storyboard` (Storyboard, optional) — 사용 가능한 경우 Music Video 스토리보드 메타데이터입니다.
- `poll_after_seconds` (integer, optional) — 작업 실행 중에 있으며, 다음 상태 조회까지 기다릴 시간입니다(이미지는 5, 영상과 이펙트는 8, 워크플로와 데이터 작업은 10). 고정 간격 대신 이 값을 따르세요. 종료된 작업에는 없습니다.
- `typical_seconds` (QueuedTaskTypicalSeconds, optional) — 작업 실행 중이고 최근 완료 건이 충분할 때 있으며, 이 작업의 모델이 최근 이 게이트웨이에서 수락부터 성공까지 걸린 시간입니다. 변화 없이 `p90`를 넘기면 작업이 오래 실행되는 것이며, 그 이후의 예상 완료 시간은 없습니다.
- `queue` (QueuedTaskQueue, optional) — 작업이 모델 용량을 기다리는 동안에만 있습니다(ID로 조회할 때만, 작업 목록에는 없음). `deadline`까지 기다린 작업은 `processing_unavailable`로 실패하고 환불됩니다. `POST /v1/tasks/{task_id}/cancel`로 취소할 수 있습니다.
- `usage` (TaskUsage, optional) — 이 작업의 USD 보류, 정산, 환불 금액과 선택적인 과금 길이입니다.
- `error` (QueuedTaskError, optional) — 실패한 작업에 있습니다. 최종 실패를 하나의 객체로 나타낸 것이며 값은 평면 필드 `error_code`, `error_message`, `retryable`과 같습니다. 평면 필드도 그대로 남습니다.
- `retryable` (boolean, optional) — 실패한 작업에 있으며, 다시 제출하면 성공할 수 있는지 여부입니다. 작업이 BeatAPI 측에서 실패했거나 시간이 초과되면 true(실패한 작업은 과금되지 않음), 콘텐츠나 잘못된 입력으로 거부되면 false입니다. 코드와 재시도 가능 여부의 규칙은 오류 형식과 같습니다.

### QueuedTaskOutput

작업이 성공할 때까지 출력은 null입니다.

- QueuedTaskOutput0
- QueuedTaskOutput1
- QueuedTaskOutput2

### Storyboard

- `shots` (list of StoryboardShot, required) — 순서가 지정된 Music Video 스토리보드 샷입니다. 스토리보드 생성이 끝나기 전에는 배열이 비어 있을 수 있습니다.

### QueuedTaskTypicalSeconds

작업 실행 중이고 최근 완료 건이 충분할 때 있으며, 이 작업의 모델이 최근 이 게이트웨이에서 수락부터 성공까지 걸린 시간입니다. 변화 없이 `p90`를 넘기면 작업이 오래 실행되는 것이며, 그 이후의 예상 완료 시간은 없습니다.

- `p50` (integer, required) — 중앙값(초)입니다.
- `p90` (integer, required) — 90번째 백분위수(초)입니다.
- `samples` (integer, required) — 수치의 근거가 된 완료 작업 수입니다.
- `window` (string, required) — 측정 기간이며, 예를 들어 `7d`입니다.

### QueuedTaskQueue

작업이 모델 용량을 기다리는 동안에만 있습니다(ID로 조회할 때만, 작업 목록에는 없음). `deadline`까지 기다린 작업은 `processing_unavailable`로 실패하고 환불됩니다. `POST /v1/tasks/{task_id}/cancel`로 취소할 수 있습니다.

- `position` (integer, required) — 대기열 내 순서입니다. 1이 다음 차례입니다.
- `ahead` (integer, required) — 이 작업보다 앞에 있는 같은 모델의 작업 수입니다.
- `queued_at` (integer, required) — 작업이 대기열에 들어간 시각(Unix 초)입니다.
- `deadline` (integer, required) — 작업이 대기를 멈추는 시각(Unix 초)입니다.

### TaskUsage

- `credits_reserved` (double, required) — 이 작업에 보류된 USD 금액입니다. 호환성을 위해 필드 이름을 유지하며, 1 Credit은 $1 USD입니다.
- `credits_charged` (double, required) — 청구된 USD 금액입니다. 실패한 작업은 보류 금액이 반환되므로 `0`입니다.
- `credits_settled` (double, required) — 작업 성공 후 정산된 USD 금액입니다.
- `credits_refunded` (double, required) — 실패한 작업 후 반환된 USD 금액입니다. 실패한 작업에서 `credits_reserved`는 생성 시 보류된 금액, `credits_charged`와 `credits_settled`는 `0`, `credits_refunded`는 반환된 금액입니다.
- `billable_duration_seconds` (integer, optional) — USD 계산에 사용된, 서버가 감지했거나 요청에서 선언한 과금 길이입니다.

### QueuedTaskError

실패한 작업에 있습니다. 최종 실패를 하나의 객체로 나타낸 것이며 값은 평면 필드 `error_code`, `error_message`, `retryable`과 같습니다. 평면 필드도 그대로 남습니다.

- `code` (string, required) — 기계 판독용 실패 코드이며 `error_code`와 같은 값입니다.
- `message` (string, required) — 원인을 밝히는 영어 문장이며 `error_message`와 같은 값입니다.
- `retryable` (boolean, optional) — 다시 제출하면 성공할 수 있는지 나타내며 `retryable`과 같은 값입니다. `retryable`이 없으면 이것도 없습니다.

### QueuedTaskOutput0

- `media` (list of QueuedTaskOutputOneOf0MediaItems, required) — BeatAPI가 호스팅하는 결과 자산입니다.
- `url` (string, required) — 주 결과물의 URL이며, 파일 하나만 읽고 싶을 때 읽는 값입니다(첫 번째 영상, 없으면 첫 번째 이미지). `r2_url`과 같은 값입니다.
- `r2_url` (string, required, deprecated) — 더 이상 사용되지 않습니다. `url`을 읽으세요. `url`과 같은 값이며, 이미 이 필드를 읽는 클라이언트를 위해서만 남겨 두었습니다.
- `tracks` (list of QueuedTaskOutputOneOf0TracksItems, optional) — 음악 작업에서만 나타납니다. 호출로 만들어진 노래 또는 스템마다 항목이 하나씩 있으며, `media`의 파일과 함께 제공됩니다.
- `data` (any, optional) — 음악 작업에서만 나타납니다. 가사, 타임스탬프 가사, 강화된 스타일, 페르소나 ID, MIDI 노트처럼 작업이 파일이 아닌 형태로 반환하는 결과입니다.

### QueuedTaskOutput1

- `text` (string, required) — 완료된 영상 분석 텍스트입니다.
- `usage` (QueuedTaskOutputOneOf1Usage, required) — 최종 USD 정산에 사용된 측정 토큰 사용량입니다.
- `finish_reason` (string, required, nullable) — 모델이 생성을 멈춘 이유입니다.

### QueuedTaskOutput2

데이터 작업의 결과입니다. 기능 자체의 결과 객체이며, 예를 들어 `research_notes`와 `sources`가 있는 `web.research`입니다(보기 사용 시: `items`).

- `object` (string, required) — 결과 종류이며, 예를 들어 `web.research`입니다.
- `request_id` (string, optional) — 결과를 만든 작업의 ID입니다.
- `query` (string, optional) — 조사한 질문입니다.
- `status` (enum, optional) — 조사의 일부를 끝내지 못했을 때 `partial`이며, 이유는 `partial_reasons`에 나옵니다.
  - Allowed values: `complete`, `partial`
- `research_notes` (string, optional) — 조사 노트입니다.
- `sources` (list of map from string to any, optional) — 노트의 근거가 된 출처입니다.
- `partial_reasons` (list of string, optional) — `status`가 `partial`일 때 포함됩니다.
- `x_search` (map from string to any, optional) — 실행이 X를 검색한 경우, X를 얼마나 검색했는지 나타냅니다.

### StoryboardShot

- `id` (string, required) — BeatAPI 샷 ID입니다. 미디어 조회, 편집, 합성 작업에 이 ID를 사용하세요.
- `index` (integer, required) — 스토리보드에서 0부터 시작하는 샷 순서입니다.
- `status` (enum, required) — 이 스토리보드 샷의 현재 수명 주기 상태입니다.
  - Allowed values: `queued`, `processing`, `storyboard_ready`, `requires_action`, `editing`, `composing`, `succeeded`, `failed`
- `created_at` (integer, required) — 샷 레코드가 생성된 Unix 타임스탬프입니다.
- `updated_at` (integer, required) — 샷 레코드가 마지막으로 변경된 Unix 타임스탬프입니다.
- `duration_seconds` (integer, optional) — 계획되었거나 생성된 샷 길이(초)입니다.
- `prompt` (string, optional) — 이 샷 생성에 사용된 크리에이티브 지시문입니다.
- `lyric_text` (string, optional) — 사용 가능한 경우 이 샷에 맞춘 가사 구간입니다.
- `media` (StoryboardShotMedia, optional) — 샷 미디어가 실체화되었거나 샷 편집이 끝난 뒤에만 있습니다.

### QueuedTaskOutputOneOf0MediaItems

- `type` (enum, required) — 결과 자산 종류입니다.
  - Allowed values: `image`, `video`, `audio`
- `url` (string, required) — BeatAPI가 호스팅하는 HTTPS 결과 URL입니다.
- `mime_type` (string, required) — 결과 자산 MIME 타입입니다.

### QueuedTaskOutputOneOf0TracksItems

- `id` (string, required) — 후속 작업이 `audio_id`로 보내는 ID입니다.
- `title` (string, optional) — 노래 제목입니다.
- `name` (string, optional) — 분리 결과의 스템 이름입니다.
- `tags` (string, optional) — 스타일 태그입니다.
- `lyrics` (string, optional) — 노래 가사입니다.
- `duration` (double, optional) — 길이(초)입니다.
- `audio_url` (string, optional) — 노래 또는 스템 파일입니다.
- `image_url` (string, optional) — 커버 이미지입니다.

### QueuedTaskOutputOneOf1Usage

최종 USD 정산에 사용된 측정 토큰 사용량입니다.

- `input_tokens` (integer, required) — 프롬프트와 영상 입력이 소비한 토큰입니다.
- `output_tokens` (integer, required) — 표시되는 출력과 모델 추론이 소비한 토큰입니다.
- `total_tokens` (integer, required) — 측정된 입력·출력 토큰 합계입니다.

### StoryboardShotMedia

샷 미디어가 실체화되었거나 샷 편집이 끝난 뒤에만 있습니다.

- `type` (string, optional) — 실체화된 샷의 호스팅 미디어 종류입니다.
- `url` (string, optional) — 실체화된 샷의 BeatAPI 호스팅 HTTPS URL입니다.
- `mime_type` (string, optional) — 호스팅된 샷 미디어의 MIME 타입입니다.

## Examples

### 이미지 네 장 생성

**Request**

```json
{
  "model": "mj-v8.2",
  "aspect_ratio": "16:9",
  "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "output": null,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null,
    "media_type": "image",
    "model": "mj-v8.2",
    "poll_after_seconds": 5,
    "usage": {
      "credits_reserved": 0.08,
      "credits_charged": 0.08,
      "credits_settled": 0,
      "credits_refunded": 0
    }
  }
}
```

**SDK Code**

```python 이미지 네 장 생성
import requests

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

payload = {
    "model": "mj-v8.2",
    "aspect_ratio": "16:9",
    "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250"
}
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":"mj-v8.2","aspect_ratio":"16:9","prompt":"A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250"}'
};

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\": \"mj-v8.2\",\n  \"aspect_ratio\": \"16:9\",\n  \"prompt\": \"A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250\"\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\": \"mj-v8.2\",\n  \"aspect_ratio\": \"16:9\",\n  \"prompt\": \"A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250\"\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\": \"mj-v8.2\",\n  \"aspect_ratio\": \"16:9\",\n  \"prompt\": \"A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250\"\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": "mj-v8.2",
  "aspect_ratio": "16:9",
  "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250"
}',
  '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\": \"mj-v8.2\",\n  \"aspect_ratio\": \"16:9\",\n  \"prompt\": \"A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 이미지 네 장 생성
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "mj-v8.2",
  "aspect_ratio": "16:9",
  "prompt": "A lighthouse on a basalt cliff at dusk, storm clouds breaking, cinematic light --s 250"
] 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()
```

### 3번 이미지 변형

**Request**

```json
{
  "model": "mj-v8.2",
  "action": "variation",
  "index": 3,
  "source_task_id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "output": null,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null,
    "media_type": "image",
    "model": "mj-v8.2",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python 3번 이미지 변형
import requests

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

payload = {
    "model": "mj-v8.2",
    "action": "variation",
    "index": 3,
    "source_task_id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript 3번 이미지 변형
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"mj-v8.2","action":"variation","index":3,"source_task_id":"task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ"}'
};

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

```go 3번 이미지 변형
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"variation\",\n  \"index\": 3,\n  \"source_task_id\": \"task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ\"\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 3번 이미지 변형
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\": \"mj-v8.2\",\n  \"action\": \"variation\",\n  \"index\": 3,\n  \"source_task_id\": \"task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ\"\n}"

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

```java 3번 이미지 변형
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\": \"mj-v8.2\",\n  \"action\": \"variation\",\n  \"index\": 3,\n  \"source_task_id\": \"task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ\"\n}")
  .asString();
```

```php 3번 이미지 변형
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "mj-v8.2",
  "action": "variation",
  "index": 3,
  "source_task_id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp 3번 이미지 변형
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\": \"mj-v8.2\",\n  \"action\": \"variation\",\n  \"index\": 3,\n  \"source_task_id\": \"task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 3번 이미지 변형
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "mj-v8.2",
  "action": "variation",
  "index": 3,
  "source_task_id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ"
] 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()
```

### 2번 이미지 업스케일

**Request**

```json
{
  "model": "mj-v8.2",
  "action": "upscale",
  "index": 2,
  "source_task_id": "task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "output": null,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null,
    "media_type": "image",
    "model": "mj-v8.2",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python 2번 이미지 업스케일
import requests

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

payload = {
    "model": "mj-v8.2",
    "action": "upscale",
    "index": 2,
    "source_task_id": "task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript 2번 이미지 업스케일
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"mj-v8.2","action":"upscale","index":2,"source_task_id":"task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E"}'
};

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

```go 2번 이미지 업스케일
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"model\": \"mj-v8.2\",\n  \"action\": \"upscale\",\n  \"index\": 2,\n  \"source_task_id\": \"task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E\"\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 2번 이미지 업스케일
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\": \"mj-v8.2\",\n  \"action\": \"upscale\",\n  \"index\": 2,\n  \"source_task_id\": \"task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E\"\n}"

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

```java 2번 이미지 업스케일
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\": \"mj-v8.2\",\n  \"action\": \"upscale\",\n  \"index\": 2,\n  \"source_task_id\": \"task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E\"\n}")
  .asString();
```

```php 2번 이미지 업스케일
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "mj-v8.2",
  "action": "upscale",
  "index": 2,
  "source_task_id": "task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp 2번 이미지 업스케일
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\": \"mj-v8.2\",\n  \"action\": \"upscale\",\n  \"index\": 2,\n  \"source_task_id\": \"task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 2번 이미지 업스케일
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "mj-v8.2",
  "action": "upscale",
  "index": 2,
  "source_task_id": "task_Vb3nK8wQ2mZr5Tx9Lc4Hd7Jf1Ps6Ya0E"
] 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": "mj-v8.2",
  "action": "describe",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ]
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "output": null,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null,
    "media_type": "image",
    "model": "mj-v8.2",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python 이미지의 프롬프트 추출
import requests

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

payload = {
    "model": "mj-v8.2",
    "action": "describe",
    "images": ["https://cdn.beatapi.io/samples/smart-bottle.png"]
}
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":"mj-v8.2","action":"describe","images":["https://cdn.beatapi.io/samples/smart-bottle.png"]}'
};

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\": \"mj-v8.2\",\n  \"action\": \"describe\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ]\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\": \"mj-v8.2\",\n  \"action\": \"describe\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ]\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\": \"mj-v8.2\",\n  \"action\": \"describe\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ]\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": "mj-v8.2",
  "action": "describe",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ]
}',
  '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\": \"mj-v8.2\",\n  \"action\": \"describe\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 이미지의 프롬프트 추출
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "mj-v8.2",
  "action": "describe",
  "images": ["https://cdn.beatapi.io/samples/smart-bottle.png"]
] 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()
```

### relax에서 이미지 프롬프트와 스타일 참조로 HD 생성

**Request**

```json
{
  "model": "mj-v8.2",
  "aspect_ratio": "4:5",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "prompt": "The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200",
  "quality": "hd",
  "speed": "relax"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "output": null,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null,
    "media_type": "image",
    "model": "mj-v8.2",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python relax에서 이미지 프롬프트와 스타일 참조로 HD 생성
import requests

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

payload = {
    "model": "mj-v8.2",
    "aspect_ratio": "4:5",
    "images": ["https://cdn.beatapi.io/samples/smart-bottle.png"],
    "prompt": "The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200",
    "quality": "hd",
    "speed": "relax"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript relax에서 이미지 프롬프트와 스타일 참조로 HD 생성
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"mj-v8.2","aspect_ratio":"4:5","images":["https://cdn.beatapi.io/samples/smart-bottle.png"],"prompt":"The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200","quality":"hd","speed":"relax"}'
};

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

```go relax에서 이미지 프롬프트와 스타일 참조로 HD 생성
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"model\": \"mj-v8.2\",\n  \"aspect_ratio\": \"4:5\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"prompt\": \"The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200\",\n  \"quality\": \"hd\",\n  \"speed\": \"relax\"\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 relax에서 이미지 프롬프트와 스타일 참조로 HD 생성
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\": \"mj-v8.2\",\n  \"aspect_ratio\": \"4:5\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"prompt\": \"The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200\",\n  \"quality\": \"hd\",\n  \"speed\": \"relax\"\n}"

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

```java relax에서 이미지 프롬프트와 스타일 참조로 HD 생성
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\": \"mj-v8.2\",\n  \"aspect_ratio\": \"4:5\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"prompt\": \"The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200\",\n  \"quality\": \"hd\",\n  \"speed\": \"relax\"\n}")
  .asString();
```

```php relax에서 이미지 프롬프트와 스타일 참조로 HD 생성
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "mj-v8.2",
  "aspect_ratio": "4:5",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "prompt": "The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200",
  "quality": "hd",
  "speed": "relax"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp relax에서 이미지 프롬프트와 스타일 참조로 HD 생성
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\": \"mj-v8.2\",\n  \"aspect_ratio\": \"4:5\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"prompt\": \"The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200\",\n  \"quality\": \"hd\",\n  \"speed\": \"relax\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift relax에서 이미지 프롬프트와 스타일 참조로 HD 생성
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "mj-v8.2",
  "aspect_ratio": "4:5",
  "images": ["https://cdn.beatapi.io/samples/smart-bottle.png"],
  "prompt": "The bottle on a sunlit kitchen counter, soft morning light --sref https://cdn.beatapi.io/samples/neon-singer.png --sw 200",
  "quality": "hd",
  "speed": "relax"
] 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": "mj-v8.2",
  "action": "blend",
  "aspect_ratio": "3:2",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ]
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "mj-v8.2",
    "capability_version": 1,
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "output": null,
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null,
    "media_type": "image",
    "model": "mj-v8.2",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python 이미지 두 장 블렌드
import requests

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

payload = {
    "model": "mj-v8.2",
    "action": "blend",
    "aspect_ratio": "3:2",
    "images": ["https://cdn.beatapi.io/samples/smart-bottle.png", "https://cdn.beatapi.io/samples/neon-singer.png"]
}
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":"mj-v8.2","action":"blend","aspect_ratio":"3:2","images":["https://cdn.beatapi.io/samples/smart-bottle.png","https://cdn.beatapi.io/samples/neon-singer.png"]}'
};

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\": \"mj-v8.2\",\n  \"action\": \"blend\",\n  \"aspect_ratio\": \"3:2\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ]\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\": \"mj-v8.2\",\n  \"action\": \"blend\",\n  \"aspect_ratio\": \"3:2\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ]\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\": \"mj-v8.2\",\n  \"action\": \"blend\",\n  \"aspect_ratio\": \"3:2\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ]\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": "mj-v8.2",
  "action": "blend",
  "aspect_ratio": "3:2",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ]
}',
  '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\": \"mj-v8.2\",\n  \"action\": \"blend\",\n  \"aspect_ratio\": \"3:2\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 이미지 두 장 블렌드
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "mj-v8.2",
  "action": "blend",
  "aspect_ratio": "3:2",
  "images": ["https://cdn.beatapi.io/samples/smart-bottle.png", "https://cdn.beatapi.io/samples/neon-singer.png"]
] 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()
```