> ## 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 分辨率档位
- 提交的 prompt 会经过平台敏感词 / 安全审核，违规内容会被直接拒绝


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 张参考图
      * 单张图片最大 10MB
      * 支持 jpeg、png、webp
      * 支持以下两种格式：
        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` - 基础分辨率（默认），每张预计消耗 5 积分
      * `2K` - 高清分辨率，每张预计消耗 7 积分
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="out_task_id" type="string" required>
  调用方自定义任务 ID，用于幂等提交和查询结果。

  * 长度为 1-64 个字符
  * 只允许字母、数字、下划线和连字符
  * 同一个 API Key 下不能重复使用
</ParamField>

## 计费

| resolution | 预计消耗积分 | 生成数量 |
| ---------- | -----: | ---: |
| `1K`       |      5 |  1 张 |
| `2K`       |      7 |  1 张 |

提交成功时，响应中的 `estimated_credits` 为预估消耗积分。任务完成后，可通过查询接口响应中的 `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": "将参考商品图改为高级夜间广告风格，保持瓶身形状、比例、喷头、透明玻璃结构和标签文字，使用深灰背景与冷色轮廓光，只保留一个商品",
        "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>
