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

# 画像生成

> DALL-E 3、Stable Diffusion、Flux などのモデルを使用してテキストプロンプトから画像を生成します。ARouter は単一の統合エンドポイントを通じて画像生成リクエストをルーティングします。

ARouter は OpenAI 互換の `/v1/images/generations` エンドポイントを通じて画像生成をサポートします。

## クイックスタート

```bash theme={null}
curl https://api.arouter.ai/v1/images/generations \
  -H "Authorization: Bearer lr_live_xxxx" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/dall-e-3", "prompt": "A futuristic city skyline at sunset, photorealistic", "n": 1, "size": "1024x1024"}'
```

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    from openai import OpenAI
    client = OpenAI(base_url="https://api.arouter.ai/v1", api_key="lr_live_xxxx")
    response = client.images.generate(
        model="openai/dall-e-3",
        prompt="A futuristic city skyline at sunset, photorealistic",
        n=1, size="1024x1024", quality="hd"
    )
    print(response.data[0].url)
    ```
  </Tab>

  <Tab title="Node.js">
    ```typescript theme={null}
    import OpenAI from "openai";
    const client = new OpenAI({ baseURL: "https://api.arouter.ai/v1", apiKey: "lr_live_xxxx" });
    const response = await client.images.generate({
      model: "openai/dall-e-3",
      prompt: "A futuristic city skyline at sunset, photorealistic",
      n: 1, size: "1024x1024", quality: "hd"
    });
    console.log(response.data[0].url);
    ```
  </Tab>
</Tabs>

## リクエストパラメータ

| パラメータ             | 型         | 説明                                                          |
| ----------------- | --------- | ----------------------------------------------------------- |
| `model`           | `string`  | 画像生成モデル ID                                                  |
| `prompt`          | `string`  | 生成したい画像のテキスト説明。DALL-E 3 は最大 4,000 文字、DALL-E 2 は最大 1,000 文字。 |
| `n`               | `integer` | 生成する画像の数（デフォルト `1`）。DALL-E 3 は `n=1` のみサポート。                |
| `size`            | `string`  | 画像サイズ（モデルによって異なる）                                           |
| `quality`         | `string`  | `"standard"` または `"hd"`（DALL-E 3 のみ、デフォルト `"standard"`）     |
| `style`           | `string`  | `"vivid"`（超リアル）または `"natural"`（DALL-E 3 のみ）                 |
| `response_format` | `string`  | `"url"`（デフォルト）または `"b64_json"`                              |

## レスポンス形式

```json theme={null}
{
  "created": 1234567890,
  "data": [
    {"url": "https://...", "revised_prompt": "A photorealistic futuristic city skyline at sunset..."}
  ]
}
```

## 画像サイズ

### DALL-E 3

| サイズ         | アスペクト比   |
| ----------- | -------- |
| `1024x1024` | 正方形（1:1） |
| `1792x1024` | 横長（16:9） |
| `1024x1792` | 縦長（9:16） |

## 対応モデル

| モデル                                  | プロバイダー       | 解像度          | スタイル制御        |
| ------------------------------------ | ------------ | ------------ | ------------- |
| `openai/dall-e-3`                    | OpenAI       | 最大 1792×1024 | `style` パラメータ |
| `openai/dall-e-2`                    | OpenAI       | 最大 1024×1024 | —             |
| `stability/stable-diffusion-3-large` | Stability AI | 最大 1024×1024 | —             |
| `black-forest-labs/flux-1-pro`       | Replicate    | 柔軟           | —             |

## 料金

| モデル                      | サイズ                     | コスト     |
| ------------------------ | ----------------------- | ------- |
| `openai/dall-e-3` スタンダード | 1024×1024               | \$0.040 |
| `openai/dall-e-3` スタンダード | 1024×1792 または 1792×1024 | \$0.080 |
| `openai/dall-e-3` HD     | 1024×1024               | \$0.080 |
| `openai/dall-e-3` HD     | 1024×1792 または 1792×1024 | \$0.120 |
| `openai/dall-e-2`        | 1024×1024               | \$0.020 |

<Note>
  ARouter が返す画像 URL は 1 時間後に期限切れになります。保存したい画像はダウンロードして保管してください。
</Note>
