Skip to main content
POST

概要

POST /flux/v1/\{model\} ネイティブ BFL 形式のリクエストで画像を生成します。リクエストはデフォルトで非同期です。トップレベルのレスポンス id を保存し、次に GET /flux/v1/get_result をそのタスク ID でポーリングします。 同じリクエスト内で画像を待機するには、JSON 本文で "async": false を送信します。同期レスポンスが成功すると、status: "Ready"result.sample の画像 URL が含まれます。 API プレイグラウンドには、FLUX.2 Pro、Flex、Max 向けのテキストから画像へのリクエスト例が含まれています。モデル ID とアカウントの利用可否については、 モデルページ または /v1/models を確認してください。

リクエストフィールド

まず promptwidthheightoutput_format を指定します。seed も送信できます。完了した結果では使用されたシードを報告できますが、このフィールドだけでは再現可能な出力は保証されません。 省略可能な async フィールドは、リクエストの返却方法を制御します。同期生成には JSON のブール値 false を使用します。非同期生成には true を使用するか、このフィールドを省略します。"false" のような文字列は送信しないでください。 参照画像の編集では、input_image に公開 HTTPS 画像 URL を送信します。このフィールドは、上記の 3 つの FLUX.2 モデルでサポートされています。FLUX.2 Pro では input_image_2 に 2 つ目の公開 HTTPS URL も指定できます。input_image を送信する場合は、必ず input_image_2 を含めてください。

同期的に生成する

リクエスト例で 同期テキストから画像へ(FLUX.2 Pro) を選択して "async": false を送信します。画像の生成中は接続を開いたままにしてください。この例ではクライアントのタイムアウトを 300 秒に設定していますが、これはクライアントの設定であり、完了期限ではありません。 レスポンスに status: "Ready" が含まれる場合は、result.sample を直接読み取ります。結果のポーリングは不要です。リクエストが失敗した場合は、結果を読み取る前に HTTP エラーを処理してください。 async: falsewebhook_url または webhook_secret と組み合わせないでください。同期リクエストは結果を直接返し、これらの webhook フィールドを拒否します。

非同期で送信してポーリングする

asynctrue または省略されている場合、生成の継続中に作成レスポンスがタスク ID を返します。CometAPI の結果エンドポイントでは、そのトップレベルの id を使用します。クライアントはレスポンスで提供される polling_url に依存しないでください。 結果エンドポイントが status: "Ready" を返すまでポーリングします。ErrorFailedFailureTask not foundRequest ModeratedContent Moderated は失敗として扱います。その他の状態では、アプリケーションの再試行およびタイムアウトの制限内でポーリングを続行してください。
タスクの準備が完了すると、result.sample は一時的な画像 URL になります。速やかにダウンロードまたは転送し、固定の有効期間を前提としないでください。

承認

Authorization
string
header
必須

Bearer token authentication. Use your CometAPI key.

パスパラメータ

model
string
必須

FLUX.2 model ID in the URL path. Check /v1/models or the Models page for account availability.

ボディ

application/json
prompt
string
必須

Text prompt describing the image or reference-image edit.

:

"A clean editorial photograph of a red ceramic teapot on a pale blue table, soft window light, no text."

async
boolean
デフォルト:true

Controls whether generation returns asynchronously. Set false to wait for the finished image and read result.sample from the successful response. Set true or omit this field to receive a task ID for polling. Use a JSON boolean, not a string. Do not combine false with webhook_url or webhook_secret.

input_image
string

Public HTTPS URL of the first reference image. Replace the example URL with a publicly accessible image. This editing field is available for the FLUX.2 models covered by this reference.

:

"https://your-image-host/reference-one.jpg"

input_image_2
string

Public HTTPS URL of a second reference image for flux-2-pro. Replace the example URL and also send input_image.

:

"https://your-image-host/reference-two.jpg"

seed
integer

Optional seed value. A completed result can report the used seed; that field alone does not establish repeatable output.

width
integer

Requested output width in pixels. Use a dimension supported by the selected model.

:

1280

height
integer

Requested output height in pixels. Use a dimension supported by the selected model.

:

768

output_format
string

Requested output image format supported by the selected model. The examples use png.

:

"png"

レスポンス

200 - application/json

With async: false, successful generation returns status: "Ready" and the image URL in result.sample. With async: true or no async field, save the top-level id and poll the CometAPI result endpoint.

id
string
必須

Task ID to pass to GET /flux/v1/get_result?id=....

status
string
必須

Task state. A successful synchronous response returns Ready. An asynchronous submission can return Pending while generation continues.

result
object | null

Generation result. A successful synchronous response contains the finished image. An asynchronous submission can return an empty or null result.

polling_url
string | null

Response-supplied convenience URL when returned. Clients should poll the documented CometAPI result route by the top-level id.

cost
number | null

Numeric billing coefficient when returned. This field is not documented as a currency or credit amount.

input_mp
number | null

Input image megapixels when returned.

output_mp
number | null

Output image megapixels when returned.

progress
number | null

Task progress when returned.

details
any

Additional task details when returned.

preview
any

Task preview data when returned.

最終更新日 2026年9月21日