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

# FLUX 3.1 Image

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

Black Forest Labs が 2026 年 12 月に公開した FLUX 3.1。テキストと最大 10 枚の参照画像から画像を生成・編集します。1K、2K、4K に対応し、quality と fast の 2 つのモードがあります。- 非同期：作成リクエストはすぐにタスク ID を返し、タスクが成功すると画像が届きます。
- 1 タスクで 1 枚の画像を生成します。複数枚必要な場合は、タスクを複数作成してください。
- テキストから画像を生成するか、公開 HTTPS リンクで渡した最大 10 枚の参照画像を編集・合成します。
- `quality` で描き方を選びます。`quality`（既定）は細部と文字の描写が最も優れ、`fast` はより速く安価です。どちらも同じフィールドを受け付け、1K、2K、4K で出力できます。
- 料金は `quality` と `resolution` で決まる 1 枚ごとの価格です。参照画像、縦横比、プロンプトの長さで料金は変わりません。
- 失敗したタスクは課金されません。予約額は全額返金されます。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 回失敗すると打ち切られ、まれにイベントが送信されない場合もあります。
3) **結果を保存する** `succeeded` の場合は、すべての `data.output.media[].url` をダウンロードし、必要なファイルを保存してください。結果 URL がいつまで利用できるかは保証されません。`failed` の場合は、`data.error_code` と `data.error_message` を確認してください。仮確保された金額は残高に戻されます。`data.retryable` は、同じリクエストをもう一度送れば成功する可能性があるかどうかを示します。## 入力モード| モード      | 必須の入力                     | 備考                                                                                               |
| -------- | ------------------------- | ------------------------------------------------------------------------------------------------ |
| テキストから画像 | `model`、`prompt`          | `images` は送らないでください。`aspect_ratio` を省略すると正方形（`1:1`）になります。                                        |
| 画像の編集・合成 | `model`、`prompt`、`images` | 1〜10 個の公開 HTTPS 画像リンク。変更・維持・合成する内容を `prompt` で説明してください。`aspect_ratio` を省略すると、結果は 1 枚目の画像の形になります。 |## リクエストパラメーター### `model``string` · 必須実行するモデル。**値**：`flux-3.1-image`**値が正しくない場合**- 指定がない：`"model" is required`
- 不明なモデル ID：`"model" flux-9 is not catalogued`
- 動画モデルをこのエンドポイントに送った：`"model" seedance-2.5 is served by POST /v1/videos/tasks, not this endpoint`### `prompt``string` · 必須描く内容、または参照画像で変更する内容。被写体、スタイル、光、構図、画像に入れる文字を普段の言葉で書くと最もうまくいきます。**長さ**：1–5000 文字- 長さは文字数で数えます（CJK の 1 文字は 1 文字）。
- 画像に入れる語はすべて、表示したいつづりのまま引用符で囲んでください。
- `images` を送るときは、どの画像を何に使うかを書いてください。例：「1 枚目の画像の製品を使い、2 枚目を背景にする」。**値が正しくない場合**- 指定がない：`"prompt" is required`
- 空、または上限を超えた：`"prompt" has an unsupported length`
- 文字列ではない：`"prompt" must be a string`### `images``string[]` · 任意編集・合成する参照画像。このフィールドを送ると、リクエストはテキストから画像ではなく画像編集になります。**要素数**：1–10  \
各要素は公開されている `https://` の URL です。ローカルファイルは先に [アップロード](/quick-guide#upload-an-input-file)（`POST /v1/files`）し、返された `data.url` を渡してください。- 各要素は画像ファイルへの公開 `https://` リンクで、各辺 256 px 以上である必要があります。タスク作成時に BeatAPI が確認するのはリンクの形式だけで、画像のダウンロードや形式・サイズの確認は行いません（制限の下の注記を参照）。
- Web ページ、ログイン画面、期限切れの署名付き URL、直リンク禁止のホストへのリンクは画像を返さず、作成後にタスクが失敗します。
- エラーメッセージ内の位置は 0 始まりです。`images[0]` は最初のリンクです。
- 参照画像は課金されません。10 枚の画像の編集も、同じ `quality` と `resolution` のテキストから画像と同じ料金です。**値が正しくない場合**- 上限を超えた：`"images" accepts at most 10 items`
- 空の配列：`"images" requires at least 1 item`
- https\:// リンクではない：`"images[0]" must be a public HTTPS URL`
- 配列ではない：`"images" must be an array`**例**```json
"images": [
  "https://cdn.beatapi.io/samples/smart-bottle.png",
  "https://cdn.beatapi.io/samples/neon-singer.png"
]
```### `quality``string` · 任意 · デフォルト: `quality`画像の描き方。`quality` は細部と文字の描写が最も優れ、`fast` はより速く安価に描きます。それぞれ解像度ごとに別の料金です。**指定できる値**：`quality`, `fast`  \
**デフォルト**：`quality`* 省略すると `quality` が使われ、Quality の料金で課金されます。
* どちらのモードも受け付けるフィールド、参照画像の枚数、解像度は同じで、違うのは細部、速さ、料金だけです。下の「quality と fast の選び方」を参照してください。> **警告:** `quality` を省略すると高い方の Quality 料金で課金されます。安いモードを使うときは `"quality": "fast"` を送ってください。**値が正しくない場合**- 一覧にない値：`"quality" must be one of: [quality fast]`**例**```json
"quality": "fast"
```### `resolution``string` · 任意 · デフォルト: `1K`画像のサイズ区分：`1K`、`2K`、`4K`。上の区分ほど高く、料金は `quality` によっても変わります。**指定できる値**：`1K`, `2K`, `4K`  \
**デフォルト**：`1K`- 省略すると `1K` が使われます。
- `2048x2048` のようなピクセル指定は受け付けません。正確なピクセル数は `aspect_ratio` によって変わるため、決め打ちせず返されたファイルのサイズを確認してください。**値が正しくない場合**- 一覧にない値：`"resolution" must be one of: [1K 2K 4K]`### `aspect_ratio``string` · 任意 · デフォルト: `1:1`画像の縦横比（幅:高さ）。`21:9`（横長）から `1:2`（縦長）まで。**指定できる値**：`21:9`, `2:1`, `16:9`, `3:2`, `7:5`, `4:3`, `5:4`, `1:1`, `4:5`, `3:4`, `5:7`, `2:3`, `9:16`, `1:2`  \
**デフォルト**：`1:1`- 省略すると、テキストから画像では正方形（`1:1`）、編集では `images` の 1 枚目の画像の形になります。
- `auto` はありません。編集で 1 枚目の画像と違う形にしたいときは、比率を指定してください。**値が正しくない場合**- 一覧にない値（`auto` や `9:21` など）：`"aspect_ratio" must be one of: [21:9 2:1 16:9 3:2 7:5 4:3 5:4 1:1 4:5 3:4 5:7 2:3 9:16 1:2]`### `output_format``string` · 任意 · デフォルト: `jpeg`結果のファイル形式：`jpeg`（既定）または `png`。**指定できる値**：`jpeg`, `png`  \
**デフォルト**：`jpeg`- モデルがもう一方の形式で返した場合、BeatAPI は保存前に変換するため、ファイルは通常指定した形式になります。変換に失敗した場合は届いたまま保存されます。JPEG にすると透明部分は白になります。
- `output.media[].mime_type` には保存された形式が必ず記載されます。**値が正しくない場合**- 一覧にない値（`webp` や `jpg` など）：`"output_format" must be one of: [jpeg png]`### `callback_url``string` · 任意タスクが成功または失敗したときに通知するアドレスです。公開 HTTPS URL で、スキーム・ホスト・ポートが有効な [Webhook エンドポイント](/webhooks)のいずれかと同じである必要があり、そのエンドポイントの `secret` で署名されます。**長さ**：≤ 2048 文字- 先に `POST /v1/webhooks` でエンドポイントを登録してください。BeatAPI は `task.succeeded` または `task.failed` を、アカウントの Webhook と同じ本文・ヘッダー・再試行規則で送ります。そのイベントを購読しているアカウントのエンドポイントにも届き、そのエンドポイントと同じアドレスなら通知は 1 回だけです。
- 10 秒以内に任意の `2xx` を返してください。配信に失敗すると約 1 分後、さらに約 5 分後に再送され、合計 3 回試行します。再送でも同じイベント `id` が使われるので、これで重複を除いてください。イベントを処理する前に `x-beatapi-signature` を検証してください。
- 署名エンドポイントが削除・停止された、または別のホストに変更された場合、このコールバックは無効になります。**値が正しくない場合**- 値が文字列ではない：`"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.`ゲートウェイはタスク作成前に、次の組み合わせも確認します。- `quality` は細部と文字の描写が最も優れ、`fast` はより速く低価格で描きます。どちらも解像度ごとに 1 枚単位で課金されます。
- 1 タスク 1 枚です。`images` は各辺 256 px 以上の公開 HTTPS URL を 1〜10 個で、送るとそれらの画像の編集になります。
- `aspect_ratio` を省略すると、`images` がある場合は 1 枚目の画像の形、ない場合は 1:1 になります。## 入力メディアの上限ゲートウェイはタスク作成前にすべての入力を読み取り、次の上限を超えるものは、その入力を示す `400 bad_request` で拒否します。課金はされません。- 参照画像：公開 HTTPS リンク 1〜10 個。各画像は各辺 256 px 以上。
- タスク作成時に BeatAPI はこれらのリンクをダウンロードせず、形式・サイズ・ピクセル数も確認しません。そのため不正なリンクは事前には拒否されません。
- 取得・読み込みできないリンクは作成後にタスクを失敗させ、タスクは返金されます。ログイン不要でサーバーから直接取得できる通常の画像ファイルへのリンクを使ってください。
- ローカルのファイルは `POST /v1/files` でアップロードし、返された `data.url` を渡してください。## quality と fast の選び方どちらのモードもリクエストは同じです。同じフィールド、最大 10 枚の参照画像、1K・2K・4K。違うのは細部、速さ、料金です。- `quality`（既定）は細部と文字の描写が最も優れています。文字の入ったポスター、パッケージ、看板、インフォグラフィック、細かな質感、複数の参照画像のあいだで一貫性を保つ編集、4K に向いています。
- `fast` はより速く、より安く描きます。下書きやプレビュー、大量の生成と編集、細部の最後の仕上がりより待ち時間が重要な場面に向いています。`fast` の料金は Quality に比べて 1K で半分、2K で 3 分の 2、4K で半分未満です。6 つの価格はすべて「課金」の料金表にあります。よくある使い方は、`fast` の 1K でプロンプトを試し、残す 1 枚を `quality` の 2K か 4K で描くことです。`quality` を省略すると Quality の料金で課金されるため、安いモードを使うときは `"quality": "fast"` を明示してください。## このモデルが受け付けないフィールド画像エンドポイントは、他の画像モデルが使うフィールドもいくつか認識します。ここでそれらを送ると無視されずに拒否されるため、効果のない設定に料金を払うことはありません。- `seed`、`size`、`background`、`enhance_prompt` → `field "seed" is not supported by model flux-3.1-image`（送ったフィールド名が入ります）。
- `n` → `field "n" is not supported by model flux-3.1-image`。`n` はなく、1 タスクで 1 枚です。
- `negative_prompt` などその他の不明なフィールド → `unknown field: negative_prompt`。不正なフィールドが複数ある場合、メッセージが示すのはそのうち 1 つだけです。直して再送してください。## リクエスト例```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": "flux-3.1-image",
  "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
  "quality": "quality",
  "resolution": "1K",
  "aspect_ratio": "3:2"
}'
``````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": "flux-3.1-image",
      "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
      "quality": "quality",
      "resolution": "1K",
      "aspect_ratio": "3:2"
    },
    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": "flux-3.1-image",
    "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
    "quality": "quality",
    "resolution": "1K",
    "aspect_ratio": "3:2"
  }),
});
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);
```### テキストから画像既定の `quality` モードで 1K の画像。ここでは明示しています。```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": "flux-3.1-image",
  "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
  "quality": "quality",
  "resolution": "1K",
  "aspect_ratio": "3:2"
}'
```### 2K の高速下書き`fast` モード：より速く安価で、下書きや大量処理向きです。```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": "flux-3.1-image",
  "prompt": "A cosy reading corner by a rainy window, a cat asleep on a knitted blanket, soft lamp light",
  "quality": "fast",
  "resolution": "2K",
  "aspect_ratio": "16:9"
}'
```### 文字が読める 4K ポスター文字と細部こそ `quality` が生きるところです。入れる語は引用符でそのまま書いてください。```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": "flux-3.1-image",
  "prompt": "A retro travel poster of a coastal city at sunset, bold flat colours, large title text \"SEASIDE\" at the top and a small line \"Ferries daily from Pier 3\" at the bottom",
  "quality": "quality",
  "resolution": "4K",
  "aspect_ratio": "2:3"
}'
```### 1 枚の画像を編集`aspect_ratio` を省略すると、結果は送った画像の形のままです。```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": "flux-3.1-image",
  "prompt": "Keep the bottle exactly as it is. Replace the background with a sunlit kitchen counter and add a soft reflection under the bottle.",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "resolution": "2K"
}'
```### 複数の画像を合成プロンプトでは各参照画像を順番で呼んでください。```bash
curl --request POST \
  --url https://api.beatapi.io/v1/images/tasks \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "flux-3.1-image",
  "prompt": "Place the bottle from the first image on a neon-lit stage like the one in the second image. Keep the bottle label readable.",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ],
  "aspect_ratio": "4:5",
  "resolution": "2K"
}'
```### 超横長の PNG バナー21:9 の Web サイト用ヒーロー画像を PNG で受け取ります。```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": "flux-3.1-image",
  "prompt": "A wide hero banner for an outdoor gear shop: a hiker on a ridge at sunrise, with open sky on the left for a headline",
  "resolution": "2K",
  "aspect_ratio": "21:9",
  "output_format": "png"
}'
```## レスポンス### タスクの作成（201）タスクオブジェクトです。タスクが成功するまで `output` は `null` です。「実行中」と記載されたフィールドは、タスクの完了後に表示されなくなります。```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "flux-3.1-image",
    "capability_version": 1,
    "media_type": "image",
    "model": "flux-3.1-image",
    "status": "queued",
    "stage": "queued",
    "created_at": 1791993600,
    "updated_at": 1791993600,
    "completed_at": null,
    "poll_after_seconds": 5,
    "output": null,
    "usage": {
      "credits_reserved": 0.03,
      "credits_settled": 0,
      "credits_refunded": 0,
      "credits_charged": 0.03
    },
    "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": "flux-3.1-image",
    "capability_version": 1,
    "media_type": "image",
    "model": "flux-3.1-image",
    "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.jpg",
          "mime_type": "image/jpeg"
        }
      ],
      "url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/0.jpg",
      "r2_url": "https://media.beatapi.io/outputs/task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ/0.jpg"
    },
    "usage": {
      "credits_reserved": 0.03,
      "credits_settled": 0.03,
      "credits_refunded": 0,
      "credits_charged": 0.03
    },
    "request_id": "202611260732156684925978268d9d6yOLdMCKV",
    "error_code": null,
    "error_message": null
  }
}
```#### 出力フィールド| フィールド                      | 型          | 説明                                                                     |
| -------------------------- | ---------- | ---------------------------------------------------------------------- |
| `output.media`             | `object[]` | 生成されたファイル。このモデルでは 1 件です。                                               |
| `output.media[].type`      | `string`   | 常に `image`。                                                            |
| `output.media[].url`       | `string`   | 保存された画像の HTTPS リンク。ダウンロードして保管してください。保存期間は保証されません。                      |
| `output.media[].mime_type` | `string`   | 保存されたファイル形式。通常は `output_format` で指定した `image/jpeg` または `image/png` です。 |
| `output.url`               | `string`   | メインのファイル：最初の画像のリンク。結果は `output.url` を読んでください。`media[]` にはすべての出力が並びます。  |
| `output.r2_url`            | `string`   | `output.url` の旧名で、値は同じです。`output.url` を読んでください。                        |### 失敗したタスク失敗したタスクも、`GET /v1/tasks/{task_id}` では HTTP 200 になります。失敗はボディに示されます。仮確保された金額は全額戻されるため、課金されません。```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "flux-3.1-image",
    "capability_version": 1,
    "media_type": "image",
    "model": "flux-3.1-image",
    "status": "failed",
    "stage": "failed",
    "created_at": 1791993600,
    "updated_at": 1791993690,
    "completed_at": 1791993690,
    "output": null,
    "usage": {
      "credits_reserved": 0.03,
      "credits_settled": 0,
      "credits_refunded": 0.03,
      "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": "flux-3.1-image",
  "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
  "quality": "quality",
  "resolution": "1K",
  "aspect_ratio": "3:2"
})
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 枚で、`quality` と `resolution` によって料金が決まります（下表の 6 つの価格）。参照画像、縦横比、出力形式、プロンプトの長さで料金は変わりません。
- `quality` を省略すると Quality の料金で課金されます。安いモードには `"quality": "fast"` を送ってください。
- タスク作成時に料金が残高から予約され、キーに上限額があればそこからも予約されます。タスク作成前に拒否されたリクエストは課金されません。
- 成功したタスクは予約額を確定します。失敗したタスクは全額返金され、`credits_refunded` は `credits_reserved` と等しく、`credits_charged` と `credits_settled` は 0 になります。現在の定価です。[料金](https://beatapi.io/pricing)ページと同じ金額です。割引を個別に契約しているアカウントでは、より低い金額になります。実際に課金された金額は、タスクの `data.usage` で確認できます。| オプション              | 定価（USD） |
| ------------------ | ------- |
| 1 枚 · Fast · 1K    | \$0.015 |
| 1 枚 · Fast · 2K    | \$0.04  |
| 1 枚 · Fast · 4K    | \$0.11  |
| 1 枚 · Quality · 1K | \$0.03  |
| 1 枚 · Quality · 2K | \$0.06  |
| 1 枚 · Quality · 4K | \$0.28  |## よくあるエラー| エラーまたは症状                                                                                          | 原因                                                          | 対処                                                                 |
| ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------ |
| 400 `"aspect_ratio" must be one of: [21:9 2:1 16:9 3:2 7:5 4:3 5:4 1:1 4:5 3:4 5:7 2:3 9:16 1:2]` | `auto`、または `9:21` などこのモデルが描かない形を送った。                        | 一覧の比率を送ってください。編集で 1 枚目の画像の形を保つには、このフィールドを省略してください。                 |
| 400 `"quality" must be one of: [quality fast]`                                                    | `standard` や `pro` など一覧にない値。                                | `quality` か `fast` を送るか、フィールドを省略してください。                            |
| 400 `"resolution" must be one of: [1K 2K 4K]`                                                     | `8K`、または `2048x2048` のようなピクセル指定。                            | `1K`、`2K`、`4K` のいずれかを送るか、フィールドを省略してください。                           |
| 400 `"output_format" must be one of: [jpeg png]`                                                  | `webp`、または `jpeg` の代わりに `jpg` を送った。                         | `jpeg` か `png` を送ってください。                                           |
| 400 `field "n" is not supported by model flux-3.1-image`                                          | 1 タスクで複数枚を求めた。                                              | `n` を削除し、1 枚ごとにタスクを作成してください。                                       |
| 400 `field "seed" is not supported by model flux-3.1-image`                                       | 他の画像モデルのフィールド（`seed`、`size`、`background`、`enhance_prompt`）。 | フィールドを削除してください。                                                    |
| 400 `"images" accepts at most 10 items`                                                           | 参照画像が 10 枚を超えた。                                             | リンクは 10 個までにしてください。                                                |
| 400 `"images[0]" must be a public HTTPS URL`                                                      | `http://` リンク、`data:` URI、ローカルパス。                           | ファイルを HTTPS で公開するか、`POST /v1/files` でアップロードして `data.url` を使ってください。 |
| 参照画像を送った後にタスクが `failed`（`bad_request`）                                                            | リンク先が Web ページ、ログインページ、期限切れの署名付き URL だった、またはホストがダウンロードを拒否した。 | 画像ファイルへ直接リンクするか、`POST /v1/files` でアップロードしてください。課金されません。            |
| 請求額が想定より高い                                                                                        | `quality` を省略したため、Quality の料金で課金された。                        | `"quality": "fast"` を送ってください。タスクの `usage.credits_charged` で確認できます。 |
| タスクが `failed`（`content_policy_violation`）                                                         | プロンプト、参照画像、または生成画像が審査で拒否された。                                | プロンプトや画像を変えてください。そのまま再試行しても失敗します。課金されません。                          |
| タスクが `failed`（`processing_timeout`）                                                               | 処理時間内に画像が完成しなかった。                                           | 再試行してください。失敗したタスクは返金済みです。                                          |
| 一度もチャージしていないアカウントで 403 `forbidden`                                                                | 無料クレジットで使えるのは一部のモデルだけです。                                    | 一度チャージするか、無料クレジットで使えるモデルを使ってください。                                  |## 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`        | 課金はされていません。指数バックオフで再試行してください。                                                    |

Reference: https://docs.beatapi.io/api-reference/image-api/flux-3-1-image

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

- `model` (enum, required) — 実行するモデル。 **値**：`flux-3.1-image` **値が正しくない場合** - 指定がない：`"model" is required` - 不明なモデル ID：`"model" flux-9 is not catalogued` - 動画モデルをこのエンドポイントに送った：`"model" seedance-2.5 is served by POST /v1/videos/tasks, not this endpoint`
  - Allowed values: `flux-3.1-image`
- `prompt` (string, required) — 描く内容、または参照画像で変更する内容。被写体、スタイル、光、構図、画像に入れる文字を普段の言葉で書くと最もうまくいきます。 **長さ**：1–5000 文字 - 長さは文字数で数えます（CJK の 1 文字は 1 文字）。 - 画像に入れる語はすべて、表示したいつづりのまま引用符で囲んでください。 - `images` を送るときは、どの画像を何に使うかを書いてください。例：「1 枚目の画像の製品を使い、2 枚目を背景にする」。 **値が正しくない場合** - 指定がない：`"prompt" is required` - 空、または上限を超えた：`"prompt" has an unsupported length` - 文字列ではない：`"prompt" must be a string`
- `aspect_ratio` (enum, optional, default: 1:1) — 画像の縦横比（幅:高さ）。`21:9`（横長）から `1:2`（縦長）まで。 **指定できる値**：`21:9`, `2:1`, `16:9`, `3:2`, `7:5`, `4:3`, `5:4`, `1:1`, `4:5`, `3:4`, `5:7`, `2:3`, `9:16`, `1:2` **デフォルト**：`1:1` - 省略すると、テキストから画像では正方形（`1:1`）、編集では `images` の 1 枚目の画像の形になります。 - `auto` はありません。編集で 1 枚目の画像と違う形にしたいときは、比率を指定してください。 **値が正しくない場合** - 一覧にない値（`auto` や `9:21` など）：`"aspect_ratio" must be one of: [21:9 2:1 16:9 3:2 7:5 4:3 5:4 1:1 4:5 3:4 5:7 2:3 9:16 1:2]`
  - Allowed values: `21:9`, `2:1`, `16:9`, `3:2`, `7:5`, `4:3`, `5:4`, `1:1`, `4:5`, `3:4`, `5:7`, `2:3`, `9:16`, `1:2`
- `images` (list of string, optional) — 編集・合成する参照画像。このフィールドを送ると、リクエストはテキストから画像ではなく画像編集になります。 **要素数**：1–10 各要素は公開されている `https://` の URL です。ローカルファイルは先に [アップロード](/quick-guide#upload-an-input-file)（`POST /v1/files`）し、返された `data.url` を渡してください。 - 各要素は画像ファイルへの公開 `https://` リンクで、各辺 256 px 以上である必要があります。タスク作成時に BeatAPI が確認するのはリンクの形式だけで、画像のダウンロードや形式・サイズの確認は行いません（制限の下の注記を参照）。 - Web ページ、ログイン画面、期限切れの署名付き URL、直リンク禁止のホストへのリンクは画像を返さず、作成後にタスクが失敗します。 - エラーメッセージ内の位置は 0 始まりです。`images[0]` は最初のリンクです。 - 参照画像は課金されません。10 枚の画像の編集も、同じ `quality` と `resolution` のテキストから画像と同じ料金です。 **値が正しくない場合** - 上限を超えた：`"images" accepts at most 10 items` - 空の配列：`"images" requires at least 1 item` - https:// リンクではない：`"images[0]" must be a public HTTPS URL` - 配列ではない：`"images" must be an array` **例** ```json "images": [ "https://cdn.beatapi.io/samples/smart-bottle.png", "https://cdn.beatapi.io/samples/neon-singer.png" ] ```
- `output_format` (enum, optional, default: jpeg) — 結果のファイル形式：`jpeg`（既定）または `png`。 **指定できる値**：`jpeg`, `png` **デフォルト**：`jpeg` - モデルがもう一方の形式で返した場合、BeatAPI は保存前に変換するため、ファイルは通常指定した形式になります。変換に失敗した場合は届いたまま保存されます。JPEG にすると透明部分は白になります。 - `output.media[].mime_type` には保存された形式が必ず記載されます。 **値が正しくない場合** - 一覧にない値（`webp` や `jpg` など）：`"output_format" must be one of: [jpeg png]`
  - Allowed values: `jpeg`, `png`
- `quality` (enum, optional, default: quality) — 画像の描き方。`quality` は細部と文字の描写が最も優れ、`fast` はより速く安価に描きます。それぞれ解像度ごとに別の料金です。 **指定できる値**：`quality`, `fast` **デフォルト**：`quality` - 省略すると `quality` が使われ、Quality の料金で課金されます。 - どちらのモードも受け付けるフィールド、参照画像の枚数、解像度は同じで、違うのは細部、速さ、料金だけです。下の「quality と fast の選び方」を参照してください。 **備考**：`quality` を省略すると高い方の Quality 料金で課金されます。安いモードを使うときは `"quality": "fast"` を送ってください。 **値が正しくない場合** - 一覧にない値：`"quality" must be one of: [quality fast]` **例** ```json "quality": "fast" ```
  - Allowed values: `quality`, `fast`
- `resolution` (enum, optional, default: 1K) — 画像のサイズ区分：`1K`、`2K`、`4K`。上の区分ほど高く、料金は `quality` によっても変わります。 **指定できる値**：`1K`, `2K`, `4K` **デフォルト**：`1K` - 省略すると `1K` が使われます。 - `2048x2048` のようなピクセル指定は受け付けません。正確なピクセル数は `aspect_ratio` によって変わるため、決め打ちせず返されたファイルのサイズを確認してください。 **値が正しくない場合** - 一覧にない値：`"resolution" must be one of: [1K 2K 4K]`
  - Allowed values: `1K`, `2K`, `4K`
- `callback_url` (string, optional) — タスクが成功または失敗したときに通知するアドレスです。公開 HTTPS URL で、スキーム・ホスト・ポートが有効な [Webhook エンドポイント](/webhooks)のいずれかと同じである必要があり、そのエンドポイントの `secret` で署名されます。 **長さ**：≤ 2048 文字 - 先に `POST /v1/webhooks` でエンドポイントを登録してください。BeatAPI は `task.succeeded` または `task.failed` を、アカウントの Webhook と同じ本文・ヘッダー・再試行規則で送ります。そのイベントを購読しているアカウントのエンドポイントにも届き、そのエンドポイントと同じアドレスなら通知は 1 回だけです。 - 10 秒以内に任意の `2xx` を返してください。配信に失敗すると約 1 分後、さらに約 5 分後に再送され、合計 3 回試行します。再送でも同じイベント `id` が使われるので、これで重複を除いてください。イベントを処理する前に `x-beatapi-signature` を検証してください。 - 署名エンドポイントが削除・停止された、または別のホストに変更された場合、このコールバックは無効になります。 **値が正しくない場合** - 値が文字列ではない：`"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) — 受け付け時または現在の BeatAPI タスクの状態。

## Errors

### 400 Bad Request Error

`bad_request`, `content_policy_violation` リクエストを修正してください。メッセージにフィールド名が示されます。そのまま再試行しないでください。

- `map from string to any`

### 401 Unauthorized Error

`missing_api_key`, `invalid_api_key`（古いクライアントでは `unauthorized` が返ることがあります） 有効なキーを `Authorization: Bearer <key>` で送信してください。

- `map from string to any`

### 402 Payment Required Error

`insufficient_credits` 残高をチャージするか、キーのクォータを引き上げてから、再度送信してください。

- `map from string to any`

### 403 Forbidden Error

`forbidden` このキーまたはアカウントでは、このモデルを利用できない可能性があります（たとえば、無料クレジットは一部のモデルにのみ使えます）。そのまま再試行しないでください。

- `map from string to any`

### 409 Conflict Error

`idempotency_conflict` 新しい `Idempotency-Key` を使うか、同じキーの最初のリクエストが完了するまで待ってください。

- `map from string to any`

### 429 Too Many Requests Error

`rate_limit_exceeded` `Retry-After` の秒数（`error.retry_after_seconds` にも含まれます）だけ待ってから再試行してください。

- `map from string to any`

### 500 Internal Server Error

`internal_error` バックオフを入れて再試行してください。解消しない場合は、`request_id` を添えてサポートにお問い合わせください。

- `map from string to any`

### 503 Service Unavailable Error

`processing_unavailable`, `processing_timeout`, `processing_failed` 課金はされていません。指数バックオフで再試行してください。

- `map from string to any`

## Types

### QueuedTask

- `id` (string, required) — ポーリングとサポートに使用する、安定した BeatAPI タスク ID。
- `object` (enum, required) — オブジェクトの識別値。常に `task`。
  - Allowed values: `task`
- `task_kind` (enum, required) — 含まれる機能固有フィールドを決める、公開タスク種別。`data` はタスクとして実行するデータ機能（`data:web.research`）で、`POST /v1/capabilities/run` からポーリングします。
  - Allowed values: `workflow`, `effect`, `image`, `video`, `audio`, `data`
- `capability_id` (string, required) — タスク受付時に選ばれた、安定した BeatAPI ワークフロー、エフェクト、生成モデル、またはデータ機能（`web.research` など）の ID。
- `capability_version` (integer, required) — 常に `1`。
- `status` (enum, required) — 現在のタスクの進行状態。`succeeded` または `failed` でポーリングを終了してください。ミュージックビデオでは手動操作が必要になる場合もあります。
  - Allowed values: `queued`, `processing`, `storyboard_ready`, `requires_action`, `editing`, `composing`, `succeeded`, `failed`
- `stage` (enum, required) — 常に `status` と同じ値。互換性のために残しており、`status` を読んでください。
  - Allowed values: `queued`, `processing`, `storyboard_ready`, `requires_action`, `editing`, `composing`, `succeeded`, `failed`
- `created_at` (integer, required) — BeatAPI がタスクを受け付けた Unix タイムスタンプ。
- `updated_at` (integer, required) — タスクの最終更新の Unix タイムスタンプ。
- `completed_at` (integer, required, nullable) — 完了時の Unix タイムスタンプ。処理中は null。
- `output` (QueuedTaskOutput, required, nullable) — タスクが成功するまで output は null です。
- `request_id` (string, required) — ログと BeatAPI サポート用に保存する相関 ID。
- `error_code` (string, required, nullable) — 機械可読の最終失敗コード。タスクの失敗が記録されていない場合は null。 `task_cancelled` は、モデルのキューで待機中にキャンセルしたタスクを示します。
- `error_message` (string, required, nullable) — 人向けの最終失敗の詳細。タスクの失敗が記録されていない場合は null。
- `workflow` (enum, optional) — ワークフロータスクに含まれ、選択した BeatAPI ワークフローを示します。
  - Allowed values: `music-video`, `ecommerce-video`, `video-analysis`
- `effect_id` (string, optional) — エフェクトタスクに含まれる、選択したエフェクトの安定した ID。
- `effect_version` (integer, optional) — エフェクトタスクに含まれる、処理に使用した変更不可のエフェクトバージョン。
- `media_type` (enum, optional) — task_kind が image または video の場合に含まれます。
  - Allowed values: `image`, `video`, `audio`
- `model` (string, optional) — 安定した BeatAPI モデルエイリアス。内部の実行ルーティングから独立しています。
- `storyboard` (Storyboard, optional) — 利用可能な場合に返す、ミュージックビデオの絵コンテのメタデータ。
- `poll_after_seconds` (integer, optional) — 実行中に返します。次の状態確認まで待つ秒数です（画像は 5、動画・エフェクトは 8、ワークフロー・データタスクは 10）。固定間隔ではなくこの値に従ってください。終了済みタスクには含まれません。
- `typical_seconds` (QueuedTaskTypicalSeconds, optional) — 実行中で、最近の完了件数が十分にある場合に返します。このゲートウェイで同じモデルのタスクが受付から succeeded になるまでに最近かかった時間です。状態が変わらず `p90` を過ぎた場合は通常より長くかかっています。それ以降の完了予定時間は示しません。
- `queue` (QueuedTaskQueue, optional) — タスクがモデルの処理枠を待っている間だけ含まれます（ID で取得した場合のみで、タスク一覧には含まれません）。`deadline` を過ぎても待っているタスクは `processing_unavailable` で失敗し、返金されます。`POST /v1/tasks/{task_id}/cancel` でキャンセルできます。
- `usage` (TaskUsage, optional) — このタスクの USD 予約、精算、返金、および任意の課金対象時間。
- `error` (QueuedTaskError, optional) — 失敗したタスクにのみ含まれます。最終的な失敗を 1 つのオブジェクトにまとめたもので、値は平らな `error_code`、`error_message`、`retryable` と同じです。平らなフィールドも引き続き返ります。
- `retryable` (boolean, optional) — 失敗したタスクに含まれ、再送信で成功する可能性があるかを示します。弊社側のエラーまたはタイムアウトなら true（失敗タスクは課金しません）、内容や入力の不備による拒否なら false です。コードと retryable の対応はエラーオブジェクトと同じです。

### QueuedTaskOutput

タスクが成功するまで output は null です。

- QueuedTaskOutput0
- QueuedTaskOutput1
- QueuedTaskOutput2

### Storyboard

- `shots` (list of StoryboardShot, required) — 順序付きのミュージックビデオの絵コンテのショット。絵コンテ生成の完了前は空の配列の場合があります。

### QueuedTaskTypicalSeconds

実行中で、最近の完了件数が十分にある場合に返します。このゲートウェイで同じモデルのタスクが受付から succeeded になるまでに最近かかった時間です。状態が変わらず `p90` を過ぎた場合は通常より長くかかっています。それ以降の完了予定時間は示しません。

- `p50` (integer, required) — 中央値（秒）。
- `p90` (integer, required) — 90 パーセンタイル（秒）。
- `samples` (integer, required) — 統計の基となった完了タスク数。
- `window` (string, required) — 計測期間。例: `7d`。

### QueuedTaskQueue

タスクがモデルの処理枠を待っている間だけ含まれます（ID で取得した場合のみで、タスク一覧には含まれません）。`deadline` を過ぎても待っているタスクは `processing_unavailable` で失敗し、返金されます。`POST /v1/tasks/{task_id}/cancel` でキャンセルできます。

- `position` (integer, required) — キュー内の順番。1 が次です。
- `ahead` (integer, required) — このタスクより前にある同じモデルのタスク数。
- `queued_at` (integer, required) — タスクがキューに入った時刻（Unix 秒）。
- `deadline` (integer, required) — タスクが待機をやめる時刻（Unix 秒）。

### TaskUsage

- `credits_reserved` (double, required) — タスクのために予約した USD 金額。フィールド名は互換性のために保持します。1 Credit は $1 USD です。
- `credits_charged` (double, required) — 課金した USD 金額。失敗タスクでは予約額が返されるため `0` です。
- `credits_settled` (double, required) — 正常終了後に確定した USD 金額。
- `credits_refunded` (double, required) — タスク失敗後に返した USD 金額。失敗タスクの `credits_reserved` は作成時の予約額、`credits_charged` と `credits_settled` は `0`、`credits_refunded` は返却額です。
- `billable_duration_seconds` (integer, optional) — USD 金額の計算に使う課金対象時間。サーバーの検出値またはリクエストの申告値です。

### QueuedTaskError

失敗したタスクにのみ含まれます。最終的な失敗を 1 つのオブジェクトにまとめたもので、値は平らな `error_code`、`error_message`、`retryable` と同じです。平らなフィールドも引き続き返ります。

- `code` (string, required) — 機械可読の失敗コードです。`error_code` と同じ値です。
- `message` (string, required) — 原因を述べる英語の文です。`error_message` と同じ値です。
- `retryable` (boolean, optional) — 再送信で成功する可能性があるかを示します。`retryable` と同じ値で、`retryable` がないときはこれもありません。

### QueuedTaskOutput0

- `media` (list of QueuedTaskOutputOneOf0MediaItems, required) — BeatAPI がホストする結果素材。
- `url` (string, required) — 主要アセットの URL です。1 つのファイルだけ読みたいときはこれを読みます（最初の動画、動画がなければ最初の画像）。`r2_url` と同じ値です。
- `r2_url` (string, required, deprecated) — 非推奨です。`url` を読んでください。`url` と同じ値で、すでにこれを読んでいるクライアントのためだけに残しています。
- `tracks` (list of QueuedTaskOutputOneOf0TracksItems, optional) — 音楽タスクのみ。呼び出しで生成された曲またはステムごとに 1 件で、`media` のファイルと並んで返されます。
- `data` (any, optional) — タスクが返すファイル以外の結果です。音楽タスク：歌詞、タイムスタンプ付き歌詞、強化されたスタイル、ペルソナ ID、MIDI ノート。Midjourney：結果が受け付ける後続操作。Seedream 5.5（`layers: true`）：`layers`。`media` の各項目と同じ順序で 1 件ずつ対応し、`index`、`z_index`、`background`、`name`、`description`、`size`、`bounding_box` を含みます。

### QueuedTaskOutput1

- `text` (string, required) — 完了した動画分析のテキスト。
- `usage` (QueuedTaskOutputOneOf1Usage, required) — USD の最終精算に使用する、実測のトークン使用量。
- `finish_reason` (string, required, nullable) — モデルが生成を終了した理由。

### QueuedTaskOutput2

データタスクの結果。その機能固有の結果オブジェクトです。例: `research_notes` と `sources`（表示形式によっては `items`）を含む `web.research`。

- `object` (string, required) — 結果の種類。例: `web.research`。
- `request_id` (string, optional) — この結果を生成したタスクの ID です。
- `query` (string, optional) — 調査した質問です。
- `status` (enum, optional) — 調査の一部を完了できなかった場合は `partial` で、理由は `partial_reasons` に入ります。
  - Allowed values: `complete`, `partial`
- `research_notes` (string, optional) — 調査ノートです。
- `sources` (list of map from string to any, optional) — ノートの根拠となる情報源です。
- `partial_reasons` (list of string, optional) — `status` が `partial` のときに含まれます。
- `x_search` (map from string to any, optional) — 実行が X を検索した場合に、どの程度検索したかを示します。

### StoryboardShot

- `id` (string, required) — BeatAPI のショット ID。素材の取得、編集、合成に使用します。
- `index` (integer, required) — 絵コンテ内のショットの順番。0 から数えます。
- `status` (enum, required) — この絵コンテのショットの現在の進行状態。
  - Allowed values: `queued`, `processing`, `storyboard_ready`, `requires_action`, `editing`, `composing`, `succeeded`, `failed`
- `created_at` (integer, required) — ショットレコード作成時の Unix タイムスタンプ。
- `updated_at` (integer, required) — ショットレコード最終更新時の Unix タイムスタンプ。
- `duration_seconds` (integer, optional) — 予定または生成されたショットの長さ（秒）。
- `prompt` (string, optional) — このショットの生成に使った演出指示。
- `lyric_text` (string, optional) — 利用可能な場合に返す、このショットに対応する歌詞の部分。
- `media` (StoryboardShotMedia, optional) — ショット素材が保存済みになった後、またはショットの編集が完了した後にのみ含まれます。

### QueuedTaskOutputOneOf0MediaItems

- `type` (enum, required) — 結果素材の種類。
  - Allowed values: `image`, `video`, `audio`
- `url` (string, required) — BeatAPI がホストする結果の HTTPS URL。
- `mime_type` (string, required) — 結果素材の MIME タイプ。

### QueuedTaskOutputOneOf0TracksItems

- `id` (string, required) — 後続の操作が `audio_id` として送る ID。
- `title` (string, optional) — 曲のタイトル。
- `name` (string, optional) — 分離結果でのステム名。
- `tags` (string, optional) — スタイルタグ。
- `lyrics` (string, optional) — 曲の歌詞。
- `duration` (double, optional) — 長さ（秒）。
- `audio_url` (string, optional) — 曲またはステムのファイル。
- `image_url` (string, optional) — カバーアート。

### QueuedTaskOutputOneOf1Usage

USD の最終精算に使用する、実測のトークン使用量。

- `input_tokens` (integer, required) — プロンプトと入力動画で消費したトークン。
- `output_tokens` (integer, required) — 表示される出力とモデルの推論で消費したトークン。
- `total_tokens` (integer, required) — 実測の入力・出力トークンの合計。

### StoryboardShotMedia

ショット素材が保存済みになった後、またはショットの編集が完了した後にのみ含まれます。

- `type` (string, optional) — 保存済みショットのホストされたメディア種別。
- `url` (string, optional) — BeatAPI がホストする保存済みショットの HTTPS URL。
- `mime_type` (string, optional) — ホストされたショット素材の MIME タイプ。

## Examples

### テキストから画像

**Request**

```json
{
  "model": "flux-3.1-image",
  "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
  "aspect_ratio": "3:2",
  "quality": "quality",
  "resolution": "1K"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "flux-3.1-image",
    "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": "flux-3.1-image",
    "poll_after_seconds": 5,
    "usage": {
      "credits_reserved": 0.03,
      "credits_charged": 0.03,
      "credits_settled": 0,
      "credits_refunded": 0
    }
  }
}
```

**SDK Code**

```python テキストから画像
import requests

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

payload = {
    "model": "flux-3.1-image",
    "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
    "aspect_ratio": "3:2",
    "quality": "quality",
    "resolution": "1K"
}
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":"flux-3.1-image","prompt":"A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement","aspect_ratio":"3:2","quality":"quality","resolution":"1K"}'
};

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\": \"flux-3.1-image\",\n  \"prompt\": \"A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement\",\n  \"aspect_ratio\": \"3:2\",\n  \"quality\": \"quality\",\n  \"resolution\": \"1K\"\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\": \"flux-3.1-image\",\n  \"prompt\": \"A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement\",\n  \"aspect_ratio\": \"3:2\",\n  \"quality\": \"quality\",\n  \"resolution\": \"1K\"\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\": \"flux-3.1-image\",\n  \"prompt\": \"A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement\",\n  \"aspect_ratio\": \"3:2\",\n  \"quality\": \"quality\",\n  \"resolution\": \"1K\"\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": "flux-3.1-image",
  "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
  "aspect_ratio": "3:2",
  "quality": "quality",
  "resolution": "1K"
}',
  '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\": \"flux-3.1-image\",\n  \"prompt\": \"A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement\",\n  \"aspect_ratio\": \"3:2\",\n  \"quality\": \"quality\",\n  \"resolution\": \"1K\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift テキストから画像
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "flux-3.1-image",
  "prompt": "A cinematic storefront campaign image at blue hour, warm light spilling from the windows onto wet pavement",
  "aspect_ratio": "3:2",
  "quality": "quality",
  "resolution": "1K"
] 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()
```

### 2K の高速下書き

**Request**

```json
{
  "model": "flux-3.1-image",
  "prompt": "A cosy reading corner by a rainy window, a cat asleep on a knitted blanket, soft lamp light",
  "aspect_ratio": "16:9",
  "quality": "fast",
  "resolution": "2K"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "flux-3.1-image",
    "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": "flux-3.1-image",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python 2K の高速下書き
import requests

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

payload = {
    "model": "flux-3.1-image",
    "prompt": "A cosy reading corner by a rainy window, a cat asleep on a knitted blanket, soft lamp light",
    "aspect_ratio": "16:9",
    "quality": "fast",
    "resolution": "2K"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript 2K の高速下書き
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"flux-3.1-image","prompt":"A cosy reading corner by a rainy window, a cat asleep on a knitted blanket, soft lamp light","aspect_ratio":"16:9","quality":"fast","resolution":"2K"}'
};

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

```go 2K の高速下書き
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"model\": \"flux-3.1-image\",\n  \"prompt\": \"A cosy reading corner by a rainy window, a cat asleep on a knitted blanket, soft lamp light\",\n  \"aspect_ratio\": \"16:9\",\n  \"quality\": \"fast\",\n  \"resolution\": \"2K\"\n}")

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

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

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

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

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

}
```

```ruby 2K の高速下書き
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\": \"flux-3.1-image\",\n  \"prompt\": \"A cosy reading corner by a rainy window, a cat asleep on a knitted blanket, soft lamp light\",\n  \"aspect_ratio\": \"16:9\",\n  \"quality\": \"fast\",\n  \"resolution\": \"2K\"\n}"

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

```java 2K の高速下書き
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\": \"flux-3.1-image\",\n  \"prompt\": \"A cosy reading corner by a rainy window, a cat asleep on a knitted blanket, soft lamp light\",\n  \"aspect_ratio\": \"16:9\",\n  \"quality\": \"fast\",\n  \"resolution\": \"2K\"\n}")
  .asString();
```

```php 2K の高速下書き
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "flux-3.1-image",
  "prompt": "A cosy reading corner by a rainy window, a cat asleep on a knitted blanket, soft lamp light",
  "aspect_ratio": "16:9",
  "quality": "fast",
  "resolution": "2K"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp 2K の高速下書き
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\": \"flux-3.1-image\",\n  \"prompt\": \"A cosy reading corner by a rainy window, a cat asleep on a knitted blanket, soft lamp light\",\n  \"aspect_ratio\": \"16:9\",\n  \"quality\": \"fast\",\n  \"resolution\": \"2K\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 2K の高速下書き
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "flux-3.1-image",
  "prompt": "A cosy reading corner by a rainy window, a cat asleep on a knitted blanket, soft lamp light",
  "aspect_ratio": "16:9",
  "quality": "fast",
  "resolution": "2K"
] as [String : Any]

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

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

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

dataTask.resume()
```

### 文字が読める 4K ポスター

**Request**

```json
{
  "model": "flux-3.1-image",
  "prompt": "A retro travel poster of a coastal city at sunset, bold flat colours, large title text \"SEASIDE\" at the top and a small line \"Ferries daily from Pier 3\" at the bottom",
  "aspect_ratio": "2:3",
  "quality": "quality",
  "resolution": "4K"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "flux-3.1-image",
    "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": "flux-3.1-image",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python 文字が読める 4K ポスター
import requests

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

payload = {
    "model": "flux-3.1-image",
    "prompt": "A retro travel poster of a coastal city at sunset, bold flat colours, large title text \"SEASIDE\" at the top and a small line \"Ferries daily from Pier 3\" at the bottom",
    "aspect_ratio": "2:3",
    "quality": "quality",
    "resolution": "4K"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript 文字が読める 4K ポスター
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"flux-3.1-image","prompt":"A retro travel poster of a coastal city at sunset, bold flat colours, large title text \"SEASIDE\" at the top and a small line \"Ferries daily from Pier 3\" at the bottom","aspect_ratio":"2:3","quality":"quality","resolution":"4K"}'
};

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

```go 文字が読める 4K ポスター
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"model\": \"flux-3.1-image\",\n  \"prompt\": \"A retro travel poster of a coastal city at sunset, bold flat colours, large title text \\\"SEASIDE\\\" at the top and a small line \\\"Ferries daily from Pier 3\\\" at the bottom\",\n  \"aspect_ratio\": \"2:3\",\n  \"quality\": \"quality\",\n  \"resolution\": \"4K\"\n}")

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

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

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

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

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

}
```

```ruby 文字が読める 4K ポスター
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\": \"flux-3.1-image\",\n  \"prompt\": \"A retro travel poster of a coastal city at sunset, bold flat colours, large title text \\\"SEASIDE\\\" at the top and a small line \\\"Ferries daily from Pier 3\\\" at the bottom\",\n  \"aspect_ratio\": \"2:3\",\n  \"quality\": \"quality\",\n  \"resolution\": \"4K\"\n}"

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

```java 文字が読める 4K ポスター
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\": \"flux-3.1-image\",\n  \"prompt\": \"A retro travel poster of a coastal city at sunset, bold flat colours, large title text \\\"SEASIDE\\\" at the top and a small line \\\"Ferries daily from Pier 3\\\" at the bottom\",\n  \"aspect_ratio\": \"2:3\",\n  \"quality\": \"quality\",\n  \"resolution\": \"4K\"\n}")
  .asString();
```

```php 文字が読める 4K ポスター
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "flux-3.1-image",
  "prompt": "A retro travel poster of a coastal city at sunset, bold flat colours, large title text \\"SEASIDE\\" at the top and a small line \\"Ferries daily from Pier 3\\" at the bottom",
  "aspect_ratio": "2:3",
  "quality": "quality",
  "resolution": "4K"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp 文字が読める 4K ポスター
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\": \"flux-3.1-image\",\n  \"prompt\": \"A retro travel poster of a coastal city at sunset, bold flat colours, large title text \\\"SEASIDE\\\" at the top and a small line \\\"Ferries daily from Pier 3\\\" at the bottom\",\n  \"aspect_ratio\": \"2:3\",\n  \"quality\": \"quality\",\n  \"resolution\": \"4K\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 文字が読める 4K ポスター
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "flux-3.1-image",
  "prompt": "A retro travel poster of a coastal city at sunset, bold flat colours, large title text \"SEASIDE\" at the top and a small line \"Ferries daily from Pier 3\" at the bottom",
  "aspect_ratio": "2:3",
  "quality": "quality",
  "resolution": "4K"
] as [String : Any]

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

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

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

dataTask.resume()
```

### 1 枚の画像を編集

**Request**

```json
{
  "model": "flux-3.1-image",
  "prompt": "Keep the bottle exactly as it is. Replace the background with a sunlit kitchen counter and add a soft reflection under the bottle.",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png"
  ],
  "resolution": "2K"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "flux-3.1-image",
    "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": "flux-3.1-image",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python 1 枚の画像を編集
import requests

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

payload = {
    "model": "flux-3.1-image",
    "prompt": "Keep the bottle exactly as it is. Replace the background with a sunlit kitchen counter and add a soft reflection under the bottle.",
    "images": ["https://cdn.beatapi.io/samples/smart-bottle.png"],
    "resolution": "2K"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript 1 枚の画像を編集
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"flux-3.1-image","prompt":"Keep the bottle exactly as it is. Replace the background with a sunlit kitchen counter and add a soft reflection under the bottle.","images":["https://cdn.beatapi.io/samples/smart-bottle.png"],"resolution":"2K"}'
};

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

```go 1 枚の画像を編集
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"model\": \"flux-3.1-image\",\n  \"prompt\": \"Keep the bottle exactly as it is. Replace the background with a sunlit kitchen counter and add a soft reflection under the bottle.\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"resolution\": \"2K\"\n}")

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

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

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

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

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

}
```

```ruby 1 枚の画像を編集
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\": \"flux-3.1-image\",\n  \"prompt\": \"Keep the bottle exactly as it is. Replace the background with a sunlit kitchen counter and add a soft reflection under the bottle.\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"resolution\": \"2K\"\n}"

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

```java 1 枚の画像を編集
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\": \"flux-3.1-image\",\n  \"prompt\": \"Keep the bottle exactly as it is. Replace the background with a sunlit kitchen counter and add a soft reflection under the bottle.\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"resolution\": \"2K\"\n}")
  .asString();
```

```php 1 枚の画像を編集
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

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

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

```csharp 1 枚の画像を編集
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\": \"flux-3.1-image\",\n  \"prompt\": \"Keep the bottle exactly as it is. Replace the background with a sunlit kitchen counter and add a soft reflection under the bottle.\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\"\n  ],\n  \"resolution\": \"2K\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 1 枚の画像を編集
import Foundation

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

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

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

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

dataTask.resume()
```

### 複数の画像を合成

**Request**

```json
{
  "model": "flux-3.1-image",
  "prompt": "Place the bottle from the first image on a neon-lit stage like the one in the second image. Keep the bottle label readable.",
  "aspect_ratio": "4:5",
  "images": [
    "https://cdn.beatapi.io/samples/smart-bottle.png",
    "https://cdn.beatapi.io/samples/neon-singer.png"
  ],
  "resolution": "2K"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "flux-3.1-image",
    "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": "flux-3.1-image",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python 複数の画像を合成
import requests

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

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

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

print(response.json())
```

```javascript 複数の画像を合成
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"flux-3.1-image","prompt":"Place the bottle from the first image on a neon-lit stage like the one in the second image. Keep the bottle label readable.","aspect_ratio":"4:5","images":["https://cdn.beatapi.io/samples/smart-bottle.png","https://cdn.beatapi.io/samples/neon-singer.png"],"resolution":"2K"}'
};

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

```go 複数の画像を合成
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"model\": \"flux-3.1-image\",\n  \"prompt\": \"Place the bottle from the first image on a neon-lit stage like the one in the second image. Keep the bottle label readable.\",\n  \"aspect_ratio\": \"4:5\",\n  \"images\": [\n    \"https://cdn.beatapi.io/samples/smart-bottle.png\",\n    \"https://cdn.beatapi.io/samples/neon-singer.png\"\n  ],\n  \"resolution\": \"2K\"\n}")

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

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

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

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

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

}
```

```ruby 複数の画像を合成
require 'uri'
require 'net/http'

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

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

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

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

```java 複数の画像を合成
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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

```php 複数の画像を合成
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

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

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

```csharp 複数の画像を合成
using RestSharp;

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

```swift 複数の画像を合成
import Foundation

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

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

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

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

dataTask.resume()
```

### 超横長の PNG バナー

**Request**

```json
{
  "model": "flux-3.1-image",
  "prompt": "A wide hero banner for an outdoor gear shop: a hiker on a ridge at sunrise, with open sky on the left for a headline",
  "aspect_ratio": "21:9",
  "output_format": "png",
  "resolution": "2K"
}
```

**Response**

```json
{
  "data": {
    "id": "task_7Qm2Xc9LpR4vT8sKa1Nf6YbH3eWdJ0uZ",
    "object": "task",
    "task_kind": "image",
    "capability_id": "flux-3.1-image",
    "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": "flux-3.1-image",
    "poll_after_seconds": 5
  }
}
```

**SDK Code**

```python 超横長の PNG バナー
import requests

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

payload = {
    "model": "flux-3.1-image",
    "prompt": "A wide hero banner for an outdoor gear shop: a hiker on a ridge at sunrise, with open sky on the left for a headline",
    "aspect_ratio": "21:9",
    "output_format": "png",
    "resolution": "2K"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript 超横長の PNG バナー
const url = 'https://api.beatapi.io/v1/images/tasks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"flux-3.1-image","prompt":"A wide hero banner for an outdoor gear shop: a hiker on a ridge at sunrise, with open sky on the left for a headline","aspect_ratio":"21:9","output_format":"png","resolution":"2K"}'
};

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

```go 超横長の PNG バナー
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"model\": \"flux-3.1-image\",\n  \"prompt\": \"A wide hero banner for an outdoor gear shop: a hiker on a ridge at sunrise, with open sky on the left for a headline\",\n  \"aspect_ratio\": \"21:9\",\n  \"output_format\": \"png\",\n  \"resolution\": \"2K\"\n}")

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

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

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

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

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

}
```

```ruby 超横長の PNG バナー
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\": \"flux-3.1-image\",\n  \"prompt\": \"A wide hero banner for an outdoor gear shop: a hiker on a ridge at sunrise, with open sky on the left for a headline\",\n  \"aspect_ratio\": \"21:9\",\n  \"output_format\": \"png\",\n  \"resolution\": \"2K\"\n}"

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

```java 超横長の PNG バナー
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\": \"flux-3.1-image\",\n  \"prompt\": \"A wide hero banner for an outdoor gear shop: a hiker on a ridge at sunrise, with open sky on the left for a headline\",\n  \"aspect_ratio\": \"21:9\",\n  \"output_format\": \"png\",\n  \"resolution\": \"2K\"\n}")
  .asString();
```

```php 超横長の PNG バナー
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.beatapi.io/v1/images/tasks', [
  'body' => '{
  "model": "flux-3.1-image",
  "prompt": "A wide hero banner for an outdoor gear shop: a hiker on a ridge at sunrise, with open sky on the left for a headline",
  "aspect_ratio": "21:9",
  "output_format": "png",
  "resolution": "2K"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp 超横長の PNG バナー
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\": \"flux-3.1-image\",\n  \"prompt\": \"A wide hero banner for an outdoor gear shop: a hiker on a ridge at sunrise, with open sky on the left for a headline\",\n  \"aspect_ratio\": \"21:9\",\n  \"output_format\": \"png\",\n  \"resolution\": \"2K\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 超横長の PNG バナー
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "flux-3.1-image",
  "prompt": "A wide hero banner for an outdoor gear shop: a hiker on a ridge at sunrise, with open sky on the left for a headline",
  "aspect_ratio": "21:9",
  "output_format": "png",
  "resolution": "2K"
] as [String : Any]

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

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

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

dataTask.resume()
```