> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aireiter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# FLUX.2 Pro 画像生成

> - 非同期処理モードで、タスクIDを返し、後続のクエリに使用可能
- テキストから画像、画像から画像への変換をサポートし、image_urlを渡すと自動的に画像から画像への変換に切り替え
- 最大8枚の参考画像に対応し、主体、商品、スタイル、構図の一貫性を保つ
- 7種類の一般的な画像比率をサポート
- 1K / 2K解像度の設定に対応
- 提出されたプロンプトはプラットフォームの禁止ワード／安全審査を通過し、違反コンテンツは即時拒否されます


export const apiKeyUrl = 'https://aireiter.com/keys';

## Authorizations

<ParamField header="Authorization" type="string" required>
  すべてのエンドポイントは Bearer Token による認証が必要です。

  API Key の取得：

  <a href={apiKeyUrl} target="_blank">API Key 管理ページ</a> へアクセスして、ご自身の API Key を取得してください。

  使用時はリクエストヘッダーに以下を追加します：

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Body

<ParamField body="model" type="string" required>
  モデル名。

  固定値：`"flux_2_pro"`
</ParamField>

<ParamField body="params" type="object" required>
  モデルのパラメータオブジェクト。

  <Expandable title="params オブジェクトのプロパティ">
    <ParamField body="prompt" type="string" required>
      画像生成または編集指示、最大 5000 文字まで。

      * 日本語と英語に対応。主体、シーン、構図、照明、素材および保持すべき参照画像の特徴を明確に記述することを推奨します
      * 画像から画像への生成の場合、保持すべき内容と変更すべき内容をプロンプトで明確に指定してください
      * 提出前にプラットフォームの不適切ワード / セキュリティチェックを通過し、違反がある場合はエラーが直接返されます
    </ParamField>

    <ParamField body="image_url" type="string[]">
      参照画像の配列。指定された場合は自動的に画像から画像生成モードが使用され、指定されない場合はテキストから画像生成モードが使用されます。

      * 最大 8 枚の参照画像
      * 1 枚あたり最大 10MB
      * jpeg、png、webp に対応
      * 以下の2つの形式をサポートします：
        1. 公開アクセス可能な URL
        2. 完全な Base64 Data URI 例：`data:image/jpeg;base64,/9j/4AAQ...`

      <Warning>
        URL はインターネット上から直接アクセス可能であり、ログイン、Cookie、または一時ページの認証は不要でなければなりません。
      </Warning>
    </ParamField>

    <ParamField body="aspect_ratio" type="string" default="1:1">
      画像のアスペクト比。

      以下の値に対応します：

      * `1:1` - 正方形（デフォルト）
      * `4:3` / `3:4` - 標準的な横向き / 縦向き
      * `16:9` / `9:16` - ワイド横向き / 縦向き
      * `3:2` / `2:3` - クラシックな横向き / 縦向き

      <Warning>
        `aspect_ratio` はモデルの目標比率を示すものであり、固定ピクセルサイズを保証するものではありません。異なる生成モードで、近い比率のネイティブなモデルサイズが返される場合があります。例えば、実測で 1K の画像から画像生成モード 16:9 は 1344×768、2K のテキストから画像生成モード 16:9 は 1920×1088 を返します。
      </Warning>
    </ParamField>

    <ParamField body="resolution" type="string" default="1K">
      画像の解像度レベル。

      * `1K` - 基本解像度（デフォルト）、1枚あたり約5ポイント消費
      * `2K` - 高解像度、1枚あたり約7ポイント消費
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="out_task_id" type="string" required>
  呼び出し元のカスタムタスクID。冪等性のある送信および結果のクエリに使用します。

  * 長さは1～64文字
  * 英字、数字、アンダースコア、ハイフンのみ許可
  * 同一のAPIキー内で重複使用不可
</ParamField>

## 課金

| 解像度  | 予想消費クレジット | 生成数 |
| ---- | --------: | --: |
| `1K` |         5 | 1 枚 |
| `2K` |         7 | 1 枚 |

送信成功時、レスポンスの `estimated_credits` は予想消費クレジットです。タスク完了後、クエリAPIのレスポンスにある `credits_used` で実際の消費クレジットを確認できます。タスク生成失敗時は、システムが自動的に今回のタスクの仮扣除クレジットを返却します。

## Response

<ResponseField name="out_task_id" type="string">
  コール元のタスクIDで、結果の照会に使えます。
</ResponseField>

<ResponseField name="status" type="string">
  初期状態で、固定値は `"pending"` です。
</ResponseField>

<ResponseField name="estimated_credits" type="number">
  予想消費クレジット。
</ResponseField>

<ResponseField name="created_at" type="string">
  作成日時、ISO 8601形式。
</ResponseField>

## クエリ結果

送信が成功した後、同じ `out_task_id` を使用して以下を呼び出します：

```bash theme={null}
curl --request POST \
  --url https://aireiter.com/api/openapi/query \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "out_task_id": "flux_2_pro_task_001"
  }'
```

タスクのステータスには `pending`、`processing`、`completed`、`failed` があります。タスクが完了すると、結果の画像は `data.output` にあり、実際に消費したクレジットは `data.credits_used` にあります。

<RequestExample>
  ```bash cURL（テキストから画像へ） theme={null}
  curl --request POST \
    --url https://aireiter.com/api/openapi/submit \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "flux_2_pro",
      "params": {
        "prompt": "未来的な電気スポーツカーが現代的なガラス建築の前に停まっている、ブルーモーメント、湿った地面が建物のライトを反射し、商業用カーフォトグラフィー、リアルなマテリアルと自然な影、文字なし、透かしなし",
        "aspect_ratio": "16:9",
        "resolution": "2K"
      },
      "out_task_id": "flux_2_pro_task_001"
    }'
  ```

  ```bash cURL（画像から画像へ） theme={null}
  curl --request POST \
    --url https://aireiter.com/api/openapi/submit \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "flux_2_pro",
      "params": {
        "prompt": "参照商品画像を高級な夜間広告スタイルに変更し、ボトルの形状、比率、スプレーノズル、透明ガラス構造、ラベルのテキストを保持し、ダークグレーの背景とクールな輪郭光を使用し、商品は1つだけ残します",
        "image_url": [
          "https://example.com/product-reference.png"
        ],
        "aspect_ratio": "16:9",
        "resolution": "1K"
      },
      "out_task_id": "flux_2_pro_image_task_001"
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://aireiter.com/api/openapi/submit"

  payload = {
      "model": "flux_2_pro",
      "params": {
          "prompt": "映画風の製品広告写真、黒い石の台に置かれたガラスの香水瓶、リアルな反射と自然な影",
          "aspect_ratio": "16:9",
          "resolution": "1K"
      },
      "out_task_id": "flux_2_pro_python_001"
  }

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

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

  ```javascript JavaScript theme={null}
  const response = await fetch("https://aireiter.com/api/openapi/submit", {
    method: "POST",
    headers: {
      Authorization: "Bearer <token>",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "flux_2_pro",
      params: {
        prompt: "映画風の製品広告写真、黒い石の台に置かれたガラスの香水瓶、リアルな反射と自然な影",
        aspect_ratio: "16:9",
        resolution: "1K"
      },
      out_task_id: "flux_2_pro_javascript_001"
    })
  });

  console.log(await response.json());
  ```

  ```go Go theme={null}
  package main

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

  func main() {
      payload := []byte(`{
        "model":"flux_2_pro",
        "params":{
          "prompt":"映画風の製品広告写真、黒い石の台に置かれたガラスの香水瓶、リアルな反射と自然な影",
          "aspect_ratio":"16:9",
          "resolution":"1K"
        },
        "out_task_id":"flux_2_pro_go_001"
      }`)

      req, _ := http.NewRequest(
          http.MethodPost,
          "https://aireiter.com/api/openapi/submit",
          bytes.NewBuffer(payload),
      )
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")

      response, err := http.DefaultClient.Do(req)
      if err != nil {
          panic(err)
      }
      defer response.Body.Close()

      body, _ := io.ReadAll(response.Body)
      fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;

  public class Main {
      public static void main(String[] args) throws Exception {
          String payload = """
          {
            "model": "flux_2_pro",
            "params": {
              "prompt": "映画風の製品広告写真、黒い石の台に置かれたガラスの香水瓶、リアルな反射と自然な影",
              "aspect_ratio": "16:9",
              "resolution": "1K"
            },
            "out_task_id": "flux_2_pro_java_001"
          }
          """;

          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://aireiter.com/api/openapi/submit"))
              .header("Authorization", "Bearer <token>")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(payload))
              .build();

          HttpResponse<String> response = HttpClient.newHttpClient().send(
              request,
              HttpResponse.BodyHandlers.ofString()
          );
          System.out.println(response.body());
      }
  }
  ```

  ```php PHP theme={null}
  <?php

  $payload = [
      "model" => "flux_2_pro",
      "params" => [
          "prompt" => "映画風の製品広告写真、黒い石の台に置かれたガラスの香水瓶、リアルな反射と自然な影",
          "aspect_ratio" => "16:9",
          "resolution" => "1K"
      ],
      "out_task_id" => "flux_2_pro_php_001"
  ];

  $ch = curl_init("https://aireiter.com/api/openapi/submit");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer <token>",
      "Content-Type: application/json"
  ]);

  echo curl_exec($ch);
  curl_close($ch);
  ?>
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "statusCode": 200,
    "message": "",
    "data": {
      "task_id": "",
      "status": "pending",
      "created_at": "2026-07-22T10:37:44.800Z",
      "out_task_id": "flux_2_pro_task_001",
      "estimated_credits": 5
    },
    "ok": true
  }
  ```

  ```json 400 theme={null}
  {
    "statusCode": 400,
    "message": "Invalid aspect_ratio: \"widescreen\". Allowed: [1:1, 4:3, 3:4, 16:9, 9:16, 3:2, 2:3]",
    "ok": false
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "認証に失敗しました。APIキーを確認してください"
    }
  }
  ```

  ```json 433 theme={null}
  {
    "error": {
      "code": 433,
      "message": "アカウント残高が不足しています。入金してから再試行してください"
    }
  }
  ```

  ```json 500 theme={null}
  {
    "error": {
      "code": 500,
      "message": "サーバー内部エラーが発生しました。後でもう一度お試しください"
    }
  }
  ```
</ResponseExample>
