> 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

1 つのモデル ID で Midjourney V8.2 を使えます。テキストと画像プロンプトから 4 枚の画像を生成し、そのうち 1 枚のバリエーションやアップスケール、4 枚全体の再生成ができます。画像のリテクスチャ、編集、ブレンド、プロンプトの逆生成も行えます。- Midjourney のすべての操作を 1 つのモデル ID で扱います。操作は `action` で選び、デフォルトは `generate` です。Midjourney が結果の下に表示するボタンも操作として指定します。
- 非同期です。作成の呼び出しはすぐにタスク ID を返します。`fast` の生成は通常 1～3 分で終わります。ポーリングは最長 10 分まで続けてください。
- 1 回の生成で画像が 4 枚返ります。続きの操作では、以前のタスクを `source_task_id` で指定し、画像を選ぶ場合はその位置を `index`（1～4）で指定します。
- `--ar`、`--s`、`--sref`、`--no` などの Midjourney パラメータは `prompt` に書きます。バージョン、速度、品質、ドラフトはフィールドで指定します。
- 料金は 1 回の呼び出しごとで、`speed` と `quality` で決まります。`upscale` と `describe` は安価な固定料金です。拒否されたリクエストと失敗したタスクには課金されません。
- 結果は 7 日後に削除されます。残したい画像はダウンロードしてください。POST/v1/images/tasks試してみるこのモデルをテスト画面で開きます。BeatAPI の API キーを入力するとタスクを作成できます。実際に呼び出され、ご自身の残高から課金されます。## エンドポイントと認証`POST https://api.beatapi.io/v1/images/tasks`### `Authorization``string` · 必須BeatAPI の API キーを `Bearer <BEATAPI_API_KEY>` の形式で送信します。キーは[ダッシュボード](https://beatapi.io/dashboard)で作成できます。キーはサーバー側で保管し、ブラウザーやモバイルアプリに含めないでください。ボディは JSON で送信し、`Content-Type: application/json` を指定します。`Idempotency-Key` は任意です。論理的に 1 件のリクエストごとに一意の値（255 文字以内）を送り、まったく同じボディを再試行するときだけ再利用してください。24 時間以内に同じキーと同じボディで再試行すると、最初のレスポンスが `Idempotent-Replayed: true` 付きで再度返されます。同じキーで異なるボディを送ると `409 idempotency_conflict` が返ります。2xx 以外のレスポンスは保存されないため、400 や 402 の後の再試行は改めて実行されます。## リクエストの流れ1) **タスクを作成する** 下記のパラメーターをエンドポイントに `POST` します。`201` が返れば、タスクが受け付けられ、料金が残高から仮確保されたことを意味します。処理はバックグラウンドで実行されます。`data.id` を保存してください。
2) **完了を待つ** `GET /v1/tasks/{task_id}` を呼び出し、`status` が `succeeded` または `failed` になるまで、呼び出しの間隔を `data.poll_after_seconds`（画像は 5 秒、動画は 8 秒）だけ空けてください。あるいは `task.succeeded` と `task.failed` の[Webhook](/webhooks)を登録することもできます。処理タイムアウトで停止したタスクはイベントを送信しないため、フォールバックとしてポーリングも続けてください。
3) **結果を保存する** `succeeded` の場合は、すべての `data.output.media[].url` をダウンロードし、必要なファイルを保存してください。結果 URL がいつまで利用できるかは保証されません。`failed` の場合は、`data.error_code` と `data.error_message` を確認してください。仮確保された金額は残高に戻されます。`data.retryable` は、同じリクエストをもう一度送れば成功する可能性があるかどうかを示します。## 入力モード| モード       | 必須の入力                                        | 備考                                                                                                                                                  |
| --------- | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| 生成        | `model`, `prompt`                            | デフォルトの操作です。任意で `images`（画像プロンプト 1～5 枚）、`aspect_ratio`、`quality`、`speed`、`draft` を指定できます。画像が 4 枚返ります。`prompt` を省略できるのは `images` にリンクが 2 つ以上あるときだけです。 |
| バリエーション   | `model`, `action`, `source_task_id`, `index` | 4 枚の結果のうち 1 枚の V ボタンです。新しい画像を 4 枚返します。                                                                                                              |
| アップスケール   | `model`, `action`, `source_task_id`, `index` | 4 枚の結果から 1 枚を選び、同じピクセルサイズのまま単独で返します。続きの操作はできません。                                                                                                    |
| 再生成       | `model`, `action`, `source_task_id`          | 4 枚の結果のプロンプト全体を描き直し、新しい 4 枚を返します。`index` は送りません。                                                                                                    |
| リテクスチャ    | `model`, `action`, `images`, `prompt`        | 画像はちょうど 1 枚です。構図を保ったままスタイルを変えます。画像が 4 枚返り、それらに続きの操作はできません。                                                                                          |
| 編集（beta）  | `model`, `action`, `images`, `prompt`        | 透明な部分を含む PNG をちょうど 1 枚送ります。描き直されるのは透明な部分だけです。画像が 4 枚返り、それらに続きの操作はできません。                                                                             |
| ブレンド      | `model`, `action`, `images`                  | 2～5 枚の画像を 1 つの絵にまとめます。`aspect_ratio` は `1:1`、`3:2`、`2:3` のいずれかです。Midjourney V7 で描画されます。                                                             |
| プロンプトの逆生成 | `model`, `action`, `images`                  | 画像はちょうど 1 枚です。`output.data.prompts` に 4 つのプロンプトを返し、画像は返しません。                                                                                        |## リクエストパラメーター### `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` にリンクが 2 つ以上ある場合を除く）、`retexture`、`edit` では必須です。ほかの操作では受け付けません。
- `generate` では、リンクと `--` パラメータを除いたテキストは最大 1024 文字です。
- フィールドで指定するパラメータと、この API が対応していないパラメータは拒否されます。後述のパラメータ表を参照してください。**値が正しくない場合**- 画像が 2 枚未満の生成で省略した：`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` は 4 枚の結果に対して行います。アップスケールした画像には続きの操作ができません。
- `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` ではちょうど 1 枚、`blend` では 2～5 枚です。**要素数**：1–5  \
各要素は公開されている `https://` の URL です。ローカルファイルは先に [アップロード](/quick-guide#upload-an-input-file)（`POST /v1/files`）し、返された `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 で 2 枚以上送った：`action describe takes at most 1 image(s) in "images"`
- 5 枚を超えた：`"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` にすると、生成 1 回分の料金で 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` を確認してください。結果が受け付ける操作が一覧になっています。それ以外の続きの操作は課金なしで拒否されます。
- アップスケールした画像には続きの操作ができません。バリエーションが必要なら、元の 4 枚の結果の `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` · 任意4 枚の結果のうちどの画像に対して行うか（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` · 任意タスクが成功または失敗したときに通知するアドレスです。公開 HTTPS URL で、スキーム・ホスト・ポートが有効な [Webhook エンドポイント](/webhooks)のいずれかと同じである必要があり、そのエンドポイントの `secret` で署名されます。**長さ**：≤ 2048 文字- 先に `POST /v1/webhooks` でエンドポイントを登録してください。BeatAPI は `task.succeeded` または `task.failed` を、アカウントの Webhook と同じ本文・ヘッダー・再試行規則で送ります。そのイベントを購読しているアカウントのエンドポイントにも届き、そのエンドポイントと同じアドレスなら通知は 1 回だけです。
- 署名エンドポイントが削除・停止された、または別のホストに変更された場合、このコールバックは無効になります。**値が正しくない場合**- 値が文字列ではない：`"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.`
- スキーム・ホスト・ポートが同じ有効な Webhook エンドポイントがない：`"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`。画像を 4 枚返します。
- `quality` の `hd` は生成時に約 2K で描きます。後から追加はできないため、大きな画像が必要なら最初の呼び出しで指定してください。
- `variation`：4 枚の結果の `source_task_id` と `index`（1～4）。その画像の Midjourney の V ボタンで、新しい画像を 4 枚返します。
- `upscale`：4 枚の結果の `source_task_id` と `index`（1～4）。その画像を選んで単独で返し、ピクセルサイズは変わりません（拡大はしません）。アップスケールした画像には続きの操作ができません。
- `reroll`：4 枚の結果の `source_task_id`。`index` は送りません。プロンプト全体を描き直し、新しい 4 枚にします。
- `retexture` と `edit`：`images`（ちょうど 1 枚）と `prompt`。`retexture` は構図を保ってプロンプトどおりにスタイルを変えます。`edit`（beta）は PNG の透明部分を描き直すので、変えたい部分を切り抜いてください。透明部分のない画像（JPEG はすべて該当）でも描画され課金されます。どちらも画像を 4 枚返し、それらに続きの操作はできません。
- `blend`：`images`（2～5 枚）と任意の `aspect_ratio`（1:1（デフォルト）、3:2、2:3）。Midjourney V7 で描画されるため、V8.2 の画像と見た目が異なることがあります。`describe`：`images`（ちょうど 1 枚）。`output.data.prompts` に 4 つのプロンプトを返し、画像は返しません。
- `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 があると拒否されます。--oref、--cref、--stop、--p、--bs、--repeat、--edit、--stealth、--public はこの API が対応しておらず、同様に拒否されます。
- `speed` が fast（デフォルト）なら通常 1～3 分、relax は 2～5 分で料金が安く、`edit` と `retexture` は最長 5 分、`upscale` と `describe` は数秒です。ポーリングは最長 10 分まで続けてください。`quality` の `hd` は fast では高く、relax では同じ料金です。`draft` はどちらの速度でも使え、生成 1 回分の料金で 512 px の簡易画像を 24 枚返し、`hd` にはできません。
- 画像リンクは公開されていて、数秒以内にダウンロードできる必要があります。ローカルのファイルは `POST /v1/files` でアップロードしてリンクを送ってください。残したい結果は保存してください。画像は 7 日後に削除されます。## 操作の一覧どの操作も同じエンドポイントでの新しいタスクです。結果の `output.data.kind` が種類を示します。`grid`（4 枚）、`single`（アップスケールした 1 枚）、`text` のいずれかです。| 操作           | 対象           | `model` と `action` 以外のフィールド                                     | 返るもの             |
| ------------ | ------------ | --------------------------------------------------------------- | ---------------- |
| `generate`   | テキストと画像プロンプト | `prompt`, `images`, `aspect_ratio`, `quality`, `speed`, `draft` | 画像 4 枚           |
| `variation`  | 4 枚の結果       | `source_task_id`, `index`, `speed`, `quality`                   | 画像 4 枚           |
| `upscale`    | 4 枚の結果       | `source_task_id`, `index`, `speed`, `quality`                   | 画像 1 枚（続きの操作は不可） |
| `reroll`     | 4 枚の結果       | `source_task_id`, `speed`, `quality`                            | 画像 4 枚           |
| `retexture`  | 自分の画像 1 枚    | `images`, `prompt`, `speed`                                     | 画像 4 枚（続きの操作は不可） |
| `edit`（beta） | 自分の PNG 1 枚  | `images`, `prompt`, `speed`                                     | 画像 4 枚（続きの操作は不可） |
| `blend`      | 自分の画像 2～5 枚  | `images`, `aspect_ratio`, `speed`                               | 画像 4 枚           |
| `describe`   | 自分の画像 1 枚    | `images`                                                        | プロンプト 4 つ（画像なし）  |- 操作が受け付けないフィールドは無視されず、拒否されます。そうしないと、生成に誤って付けた `index` が効果のないまま課金されてしまいます。
- `blend` は Midjourney V7 で描画されるため、V8.2 の画像と見た目が異なることがあります。## 続きの操作をつなげる続きの操作では、自分の完了済み Midjourney タスクを `source_task_id` で指定します。対象は 4 枚の結果で、`index` でそのうち 1 枚を選びます。1 はそのタスクの `output.media` の最初の項目、4 は最後の項目です。- `index` 付きの `variation`：V ボタンです。その画像に近い新しい 4 枚を返します。
- `index` 付きの `upscale`：U ボタンです。その画像だけを返します。同じ結果の同じ画像をもう一度アップスケールすると拒否され、すでにその画像を持つタスクが示されます。
- `reroll`：同じプロンプトで新しい 4 枚を返します。アップスケールした画像には続きの操作ができません。バリエーションが必要なら、元の 4 枚の結果と同じ `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` もできません。 | その速度の生成 1 回分の料金          |- `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              | カオス。4 枚の画像の違いの大きさです。                                               |
| `--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` はファイルを保存しません。4 つのプロンプトは `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);
```### 画像を 4 枚生成するデフォルトの操作です。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 ボタンです。上の生成結果の 3 枚目に近い新しい画像を 4 枚返します。```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "mj-v8.2",
  "action": "variation",
  "source_task_id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
  "index": 3
}'
```### 2 枚目のアップスケールバリエーションの結果で U2 を押します。2 枚目だけを、描かれたときのピクセルサイズのまま取り出します。続きの操作はできません。```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
}'
```### 画像からプロンプトを逆生成する似た画像を描けるプロンプトを 4 つ、`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"
}'
```### 2 枚の画像をブレンドする画像を 1 つの絵にまとめ、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 文字が続きます。ポーリングや Webhook イベントとの照合に使います。                             |
| `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` のいずれかです。最終状態は後ろの 2 つだけです。                          |
| `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 では 4 枚、upscale では 1 枚、describe では 0 枚です。`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`（4 枚）、`single`（アップスケールした 1 枚）、`text`（describe）のいずれかです。             |
| `output.data.follow_ups`   | `string[]` | この結果を `source_task_id` にしたときに受け付ける操作です。続きの操作ができない場合は空です。                 |
| `output.data.prompts`      | `string[]` | describe のみ。4 つのプロンプトです。                                                 |### 失敗したタスク失敗したタスクも、`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` を 1 つのオブジェクトにまとめたもので、値は `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"])
```## 課金- 1 回の呼び出しが 1 つのタスクで、料金は `speed` と `quality` で決まります（下表）。生成、バリエーション、再生成、リテクスチャ、編集、ブレンド、ドラフトは、返る画像の枚数にかかわらず、その設定で 1 回分の料金です。
- 続きの操作は元のタスクの速度と品質で課金されます。`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` | アップスケールの結果に続きの操作を送った。                                                                 | 4 枚の結果のタスクの `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` 後の 4 枚が変わっていないように見える                                                                                                                   | 画像に透明な部分がなく、描き直す部分がなかった。課金はされています。                                                    | 変更したい部分を透明にした 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) — ボディは JSON で送信し、`Content-Type: application/json` を指定します。`Idempotency-Key` は任意です。論理的に 1 件のリクエストごとに一意の値（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` は 4 枚の結果に対して行います。アップスケールした画像には続きの操作ができません。 - `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` にすると、生成 1 回分の料金で 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` ではちょうど 1 枚、`blend` では 2～5 枚です。 **要素数**：1–5 各要素は公開されている `https://` の URL です。ローカルファイルは先に [アップロード](/quick-guide#upload-an-input-file)（`POST /v1/files`）し、返された `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 で 2 枚以上送った：`action describe takes at most 1 image(s) in "images"` - 5 枚を超えた：`"images" accepts at most 5 items` - https:// のリンクではない：`"images[0]" must be a public HTTPS URL`
- `index` (integer, optional) — 4 枚の結果のうちどの画像に対して行うか（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` にリンクが 2 つ以上ある場合を除く）、`retexture`、`edit` では必須です。ほかの操作では受け付けません。 - `generate` では、リンクと `--` パラメータを除いたテキストは最大 1024 文字です。 - フィールドで指定するパラメータと、この API が対応していないパラメータは拒否されます。後述のパラメータ表を参照してください。 **値が正しくない場合** - 画像が 2 枚未満の生成で省略した：`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` を確認してください。結果が受け付ける操作が一覧になっています。それ以外の続きの操作は課金なしで拒否されます。 - アップスケールした画像には続きの操作ができません。バリエーションが必要なら、元の 4 枚の結果の `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) — タスクが成功または失敗したときに通知するアドレスです。公開 HTTPS URL で、スキーム・ホスト・ポートが有効な [Webhook エンドポイント](/webhooks)のいずれかと同じである必要があり、そのエンドポイントの `secret` で署名されます。 **長さ**：≤ 2048 文字 - 先に `POST /v1/webhooks` でエンドポイントを登録してください。BeatAPI は `task.succeeded` または `task.failed` を、アカウントの Webhook と同じ本文・ヘッダー・再試行規則で送ります。そのイベントを購読しているアカウントのエンドポイントにも届き、そのエンドポイントと同じアドレスなら通知は 1 回だけです。 - 署名エンドポイントが削除・停止された、または別のホストに変更された場合、このコールバックは無効になります。 **値が正しくない場合** - 値が文字列ではない：`"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.` - スキーム・ホスト・ポートが同じ有効な Webhook エンドポイントがない：`"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) — Accepted or current BeatAPI task state.

## 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) — Stable BeatAPI task ID used for polling and support.
- `object` (enum, required) — Object discriminator; always `task`.
  - Allowed values: `task`
- `task_kind` (enum, required) — Public task family that determines which capability fields are present. `data` is a data capability run as a task (`data:web.research`), polled through `POST /v1/capabilities/run`.
  - Allowed values: `workflow`, `effect`, `image`, `video`, `audio`, `data`
- `capability_id` (string, required) — Stable BeatAPI workflow, Effect, generation model, or data capability ID (such as `web.research`) selected when the task was accepted.
- `capability_version` (integer, required) — Always `1`.
- `status` (enum, required) — Current task lifecycle status. Stop polling at `succeeded` or `failed`; Music Video can also require manual action.
  - Allowed values: `queued`, `processing`, `storyboard_ready`, `requires_action`, `editing`, `composing`, `succeeded`, `failed`
- `stage` (enum, required) — Always repeats `status`. Kept for compatibility; read `status`.
  - Allowed values: `queued`, `processing`, `storyboard_ready`, `requires_action`, `editing`, `composing`, `succeeded`, `failed`
- `created_at` (integer, required) — Unix timestamp when BeatAPI accepted the task.
- `updated_at` (integer, required) — Unix timestamp of the latest task update.
- `completed_at` (integer, required, nullable) — Terminal Unix timestamp, or null while work is in progress.
- `output` (QueuedTaskOutput, required, nullable) — Output is null until the task succeeds.
- `request_id` (string, required) — Correlation ID to retain for logs and BeatAPI support.
- `error_code` (string, required, nullable) — Machine-readable terminal failure code, or null when no task failure is recorded. `task_cancelled` marks a task you cancelled while it waited in its model's queue.
- `error_message` (string, required, nullable) — Human-readable terminal failure detail, or null when no task failure is recorded.
- `workflow` (enum, optional) — Present for workflow tasks; identifies the selected BeatAPI workflow.
  - Allowed values: `music-video`, `ecommerce-video`, `video-analysis`
- `effect_id` (string, optional) — Present for Effect tasks; stable selected Effect ID.
- `effect_version` (integer, optional) — Present for Effect tasks; immutable Effect version used for processing.
- `media_type` (enum, optional) — Present when task_kind is image or video.
  - Allowed values: `image`, `video`, `audio`
- `model` (string, optional) — Stable BeatAPI model alias. It is independent from internal execution routing.
- `storyboard` (Storyboard, optional) — Music Video storyboard metadata when available.
- `poll_after_seconds` (integer, optional) — Present while the task is running: how long to wait before the next status call (5 for images, 8 for video and Effects, 10 for workflows and data tasks). Follow it instead of a fixed interval. Absent on a terminal task.
- `typical_seconds` (QueuedTaskTypicalSeconds, optional) — Present while the task is running, when enough recent finishes exist: how long this task's model recently took from accepted to succeeded, measured on this gateway. Past `p90` with no change the task is running long; there is no ETA beyond that.
- `queue` (QueuedTaskQueue, optional) — Present only while the task waits for its model's capacity (read by id, not in the task list). A task still waiting at `deadline` fails with `processing_unavailable` and is refunded. Cancel it with `POST /v1/tasks/{task_id}/cancel`.
- `usage` (TaskUsage, optional) — USD reservation, settlement, refund, and optional billable duration for this task.
- `error` (QueuedTaskError, optional) — Present on a failed task: the terminal failure as one object. Its values are the same as the flat `error_code`, `error_message` and `retryable`, which stay.
- `retryable` (boolean, optional) — Present on a failed task: whether resubmitting could succeed. True when the task failed on our side or timed out (a failed task is not charged); false when it was refused for content or bad input. Same code-to-retryable rule as the error envelope.

### QueuedTaskOutput

Output is null until the task succeeds.

- QueuedTaskOutput0
- QueuedTaskOutput1
- QueuedTaskOutput2

### Storyboard

- `shots` (list of StoryboardShot, required) — Ordered Music Video storyboard shots. The array may be empty before storyboard generation completes.

### QueuedTaskTypicalSeconds

Present while the task is running, when enough recent finishes exist: how long this task's model recently took from accepted to succeeded, measured on this gateway. Past `p90` with no change the task is running long; there is no ETA beyond that.

- `p50` (integer, required) — Median seconds.
- `p90` (integer, required) — Ninetieth-percentile seconds.
- `samples` (integer, required) — Finished tasks the figures rest on.
- `window` (string, required) — The window measured, such as `7d`.

### QueuedTaskQueue

Present only while the task waits for its model's capacity (read by id, not in the task list). A task still waiting at `deadline` fails with `processing_unavailable` and is refunded. Cancel it with `POST /v1/tasks/{task_id}/cancel`.

- `position` (integer, required) — Place in the queue; 1 is next.
- `ahead` (integer, required) — Tasks of the same model ahead of this one.
- `queued_at` (integer, required) — Unix seconds when the task was queued.
- `deadline` (integer, required) — Unix seconds after which the task stops waiting.

### TaskUsage

- `credits_reserved` (double, required) — USD amount reserved for this task. The compatibility field name is retained; 1 Credit equals $1 USD.
- `credits_charged` (double, required) — USD amount charged. `0` on a failed task, because the reserved amount was returned.
- `credits_settled` (double, required) — USD amount settled after successful work.
- `credits_refunded` (double, required) — USD amount returned after a failed task. On a failed task `credits_reserved` is the amount held at create, `credits_charged` and `credits_settled` are `0`, and `credits_refunded` is the amount returned.
- `billable_duration_seconds` (integer, optional) — Server-detected or request-declared billable duration used for USD calculation.

### QueuedTaskError

Present on a failed task: the terminal failure as one object. Its values are the same as the flat `error_code`, `error_message` and `retryable`, which stay.

- `code` (string, required) — Machine-readable failure code, the same value as `error_code`.
- `message` (string, required) — English sentence that states the cause, the same value as `error_message`.
- `retryable` (boolean, optional) — Whether resubmitting could succeed, the same value as `retryable`. Absent when `retryable` is absent.

### QueuedTaskOutput0

- `media` (list of QueuedTaskOutputOneOf0MediaItems, required) — BeatAPI-hosted result assets.
- `url` (string, required) — The primary asset's URL, the one to read when you want a single file (the first video, else the first image). The same value as `r2_url`.
- `r2_url` (string, required, deprecated) — Deprecated — read `url`. The same value as `url`, kept only for clients that already read it.
- `tracks` (list of QueuedTaskOutputOneOf0TracksItems, optional) — Audio tasks only. One entry for each song or stem the call made, beside the files in `media`.
- `data` (any, optional) — Audio tasks only. What an action returns that is not a file, such as lyrics, aligned lyrics, a boosted style, a persona id or MIDI notes.

### QueuedTaskOutput1

- `text` (string, required) — Completed video analysis text.
- `usage` (QueuedTaskOutputOneOf1Usage, required) — Measured token usage used for final USD settlement.
- `finish_reason` (string, required, nullable) — Why the model stopped generating.

### QueuedTaskOutput2

A data task's result: the capability's own result object, such as `web.research` with `research_notes` and `sources` (in a view: `items`).

- `object` (string, required) — The result type, such as `web.research`.
- `request_id` (string, optional) — The ID of the task that produced the result.
- `query` (string, optional) — The question that was researched.
- `status` (enum, optional) — `partial` when part of the research could not be finished; `partial_reasons` says why.
  - Allowed values: `complete`, `partial`
- `research_notes` (string, optional) — The research notes.
- `sources` (list of map from string to any, optional) — The sources behind the notes.
- `partial_reasons` (list of string, optional) — Present when `status` is `partial`.
- `x_search` (map from string to any, optional) — How much X was searched, when the run searched X at all.

### StoryboardShot

- `id` (string, required) — BeatAPI shot id. Use this id for media retrieval, edit, and compose operations.
- `index` (integer, required) — Zero-based shot order in the storyboard.
- `status` (enum, required) — Current lifecycle state for this storyboard shot.
  - Allowed values: `queued`, `processing`, `storyboard_ready`, `requires_action`, `editing`, `composing`, `succeeded`, `failed`
- `created_at` (integer, required) — Unix timestamp when the shot record was created.
- `updated_at` (integer, required) — Unix timestamp when the shot record last changed.
- `duration_seconds` (integer, optional) — Planned or generated shot duration in seconds.
- `prompt` (string, optional) — Creative instruction used to generate this shot.
- `lyric_text` (string, optional) — Lyric segment aligned with this shot when available.
- `media` (StoryboardShotMedia, optional) — Present only after the shot media has been materialized or after a shot edit finishes.

### QueuedTaskOutputOneOf0MediaItems

- `type` (enum, required) — Result asset type.
  - Allowed values: `image`, `video`, `audio`
- `url` (string, required) — BeatAPI-hosted HTTPS result URL.
- `mime_type` (string, required) — Result asset MIME type.

### QueuedTaskOutputOneOf0TracksItems

- `id` (string, required) — The id a follow-up sends as `audio_id`.
- `title` (string, optional) — Song title.
- `name` (string, optional) — Stem name on a split result.
- `tags` (string, optional) — Style tags.
- `lyrics` (string, optional) — Lyrics of the song.
- `duration` (double, optional) — Length in seconds.
- `audio_url` (string, optional) — The song or stem file.
- `image_url` (string, optional) — Cover art.

### QueuedTaskOutputOneOf1Usage

Measured token usage used for final USD settlement.

- `input_tokens` (integer, required) — Tokens consumed by the prompt and video input.
- `output_tokens` (integer, required) — Tokens consumed by visible output and model reasoning.
- `total_tokens` (integer, required) — Total measured input and output tokens.

### StoryboardShotMedia

Present only after the shot media has been materialized or after a shot edit finishes.

- `type` (string, optional) — Hosted media type for the materialized shot.
- `url` (string, optional) — BeatAPI-hosted HTTPS URL for the materialized shot.
- `mime_type` (string, optional) — MIME type of the hosted shot media.

## Examples

### 画像を 4 枚生成する

**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 画像を 4 枚生成する
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 画像を 4 枚生成する
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 画像を 4 枚生成する
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 画像を 4 枚生成する
require 'uri'
require 'net/http'

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

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"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 画像を 4 枚生成する
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.beatapi.io/v1/images/tasks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"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 画像を 4 枚生成する
<?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 画像を 4 枚生成する
using RestSharp;

var client = new RestClient("https://api.beatapi.io/v1/images/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"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 画像を 4 枚生成する
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()
```

### 2 枚の画像をブレンドする

**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 2 枚の画像をブレンドする
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 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":"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 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\": \"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 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\": \"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 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\": \"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 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": "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 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\": \"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 2 枚の画像をブレンドする
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()
```