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

# Qwen Image 2.0 画像生成

>  - 非同期処理モード、後続のクエリ用にタスクIDを返します
- テキストから画像、画像から画像など複数の生成モードをサポート
- 1K/2K解像度レベルをサポート、最大6枚の画像を生成 

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.apimart.ai/v1/images/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "qwen-image-2.0",
      "prompt": "日差しの中でうたた寝するかわいい茶トラ猫"
    }'
  ```

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

  url = "https://api.apimart.ai/v1/images/generations"

  payload = {
      "model": "qwen-image-2.0",
      "prompt": "日差しの中でうたた寝するかわいい茶トラ猫"
  }

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

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

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api.apimart.ai/v1/images/generations";

  const payload = {
    model: "qwen-image-2.0",
    prompt: "日差しの中でうたた寝するかわいい茶トラ猫",
  };

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

  fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload),
  })
    .then((response) => response.json())
    .then((data) => console.log(data))
    .catch((error) => console.error("Error:", error));
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": [
      {
        "status": "submitted",
        "task_id": "task_01JGXYZ1234567890ABCDEF"
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "リクエストパラメータが無効です",
      "type": "invalid_request_error"
    }
  }
  ```

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

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "残高不足です、チャージしてください",
      "type": "payment_required"
    }
  }
  ```
</ResponseExample>

## サポートされているモデル

| モデル名                 | 説明                             | 最大枚数 | 課金方式 |
| -------------------- | ------------------------------ | ---- | ---- |
| `qwen-image-2.0`     | 標準版、品質とパフォーマンスのバランス            | 6枚   | 固定価格 |
| `qwen-image-2.0-pro` | Pro版、テキストレンダリングが強力、リアルな質感がより繊細 | 6枚   | 固定価格 |

## 認証

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

  API Keyの取得：

  [API Key管理ページ](https://apimart.ai/keys)でAPI Keyを取得してください

  リクエストヘッダーに追加：

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

## Body

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

  * `qwen-image-2.0` - 標準版、品質とパフォーマンスのバランス
  * `qwen-image-2.0-pro` - Pro版、テキストレンダリングが強力、リアルな質感がより繊細
</ParamField>

<ParamField body="prompt" type="string" required>
  画像生成のテキスト説明、最大800文字
</ParamField>

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

  サポートされているアスペクト比：

  * `1:1` - 正方形（デフォルト）
  * `4:3` - 横向き 4:3
  * `3:4` - 縦向き 3:4
  * `16:9` - 横向きワイドスクリーン
  * `9:16` - 縦向き
  * `3:2` - 横向き 3:2
  * `2:3` - 縦向き 2:3
</ParamField>

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

  * `1K` - 標準解像度（デフォルト）
  * `2K` - 高精細解像度
</ParamField>

<ParamField body="n" type="integer" default="1">
  生成する画像の枚数

  範囲：1-6
</ParamField>

<ParamField body="negative_prompt" type="string">
  ネガティブプロンプト（表示させたくないコンテンツ）、最大500文字
</ParamField>

<ParamField body="image_urls" type="array">
  参照画像URL配列（画像から画像モード）

  **制限：**

  * 公開アクセス可能なURLである必要があります
  * Base64形式はサポートされていません
</ParamField>

## 解像度対照表

`size`（比率）+ `resolution`（解像度レベル）の組み合わせで出力サイズを制御します。

| 比率     | 1Kレベル     | 2Kレベル     |
| ------ | --------- | --------- |
| `1:1`  | 1024×1024 | 2048×2048 |
| `4:3`  | 1152×864  | 2048×1536 |
| `3:4`  | 864×1152  | 1536×2048 |
| `16:9` | 1280×720  | 2048×1152 |
| `9:16` | 720×1280  | 1152×2048 |
| `3:2`  | 1248×832  | 2048×1360 |
| `2:3`  | 832×1248  | 1360×2048 |

* `size`のみ → デフォルト1Kレベル：`{"size": "16:9"}` → 1280×720
* `size` + `resolution` → 指定レベル：`{"size": "16:9", "resolution": "2K"}` → 2048×1152

## 使用例

**テキストから画像（最小リクエスト）**

```json theme={null}
{
  "model": "qwen-image-2.0",
  "prompt": "日差しの中でうたた寝するかわいい茶トラ猫"
}
```

**比率と枚数を指定**

```json theme={null}
{
  "model": "qwen-image-2.0-pro",
  "prompt": "サイバーパンク風の未来都市の夜景、ネオンライトが点滅",
  "size": "16:9",
  "n": 4
}
```

**高精細2Kレベル**

```json theme={null}
{
  "model": "qwen-image-2.0-pro",
  "prompt": "精巧なフードフォトグラフィー、寿司盛り合わせ",
  "size": "4:3",
  "resolution": "2K",
  "n": 2
}
```

**画像から画像（参照画像 + テキスト説明）**

```json theme={null}
{
  "model": "qwen-image-2.0",
  "prompt": "背景を海辺の夕日に変更",
  "image_urls": ["https://example.com/my-photo.jpg"]
}
```

## Response

<ResponseField name="code" type="integer">
  レスポンスステータスコード
</ResponseField>

<ResponseField name="data" type="array">
  レスポンスデータ配列

  <Expandable title="属性">
    <ResponseField name="status" type="string">
      タスクステータス

      * `submitted` - 送信済み
    </ResponseField>

    <ResponseField name="task_id" type="string">
      タスク一意識別子
    </ResponseField>
  </Expandable>
</ResponseField>

## 注意事項

1. **非同期処理**：送信後に`task_id`が返されます、結果を取得するには`/v1/tasks/{task_id}`をポーリングしてください
2. **画像保存**：生成された画像はプラットフォームCDNにミラーリングされ、長期間有効です
3. **課金ルール**：正常に生成された画像の枚数に応じて課金、失敗した場合は課金されません
4. **画像URL要件**：入力画像は公開アクセス可能なURLである必要があります、base64はサポートされていません
