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

# Image Generation API

> To facilitate developers in calling different image generation models, AIHubMix provides a unified image generation API.

## Available Model List

<Tip>
  For Nano Banana series, consulte: [https://docs.aihubmix.com/en/api/Gemini-Guides](https://docs.aihubmix.com/en/api/Gemini-Guides)
</Tip>

### OpenAI Models

* [gpt-image-2](https://aihubmix.com/model/gpt-image-2) - Compatível com o endpoint de edição de imagens no formato OpenAI. Use o ID completo `gpt-image-2`; `image2` não é um ID de modelo válido.
* [gpt-image-1.5](https://aihubmix.com/model/gpt-image-1.5) - OpenAI's latest image generation model, featuring improved instruction adherence and prompt execution capabilities.
* [gpt-image-1](https://aihubmix.com/model/gpt-image-1) - A multimodal language model that accepts text and image inputs, generating image outputs.
* [gpt-image-1-mini](https://aihubmix.com/model/gpt-image-1-mini) - An economical version of gpt-image-1.
* [dall-e-3](https://aihubmix.com/model/dall-e-3) - Capable of creating realistic images and artworks based on natural language descriptions, supporting the creation of new images in specified dimensions based on prompts.

### Imagen Models

* imagen-4.0-ultra-generate-001
* imagen-4.0-generate-001
* imagen-4.0-fast-generate-001
* imagen-4.0-fast-generate-preview-06-06
* imagen-3.0-generate-002

### Qwen Models

* [qwen-image](https://aihubmix.com/model/qwen-image) - A foundational image generation model no Qwen series that has made significant progress in complex text rendering and precise image editing.
* [qwen-image-edit](https://aihubmix.com/model/qwen-image-edit) - Qwen image editing model.

### Doubao Models

* [doubao-seedream-4-5](https://aihubmix.com/model/doubao-seedream-4-5) - ByteDance's latest multimodal image model, integrating capabilities for text-to-image, image-to-image, and composite image outputs.
* [doubao-seedream-4-0](https://aihubmix.com/model/doubao-seedream-4-0) - ByteDance's SOTA multimodal image creation model, supporting diverse functionalities como multi-image fusion creation, image editing, and composite image generation.

### Flux Models

* [flux-2-flex](https://aihubmix.com/model/flux-2-flex) - Designed for real-world creative production workflows, generating high-quality images while maintaining character and style consistency among multiple references.
* [flux-2-pro](https://aihubmix.com/model/flux-2-flex) - An image generation and editing model developed by Black Forest Labs, supporting complex text reading and writing.
* [FLUX.1-Kontext-pro](FLUX.1-Kontext-pro) - A multimodal flow matching model developed by Black Forest Labs, supporting both text-to-image generation and image editing in context.

### iRAG Models

* [irag-1.0](https://aihubmix.com/model/irag-1.0) - Baidu's self-developed image generation model capable of producing ultra-realistic images.
* [ernie-irag-edit](https://aihubmix.com/model/ernie-irag-edit) - Baidu's self-developed image editing model, supporting operations like erase, repaint, and variation based on images.

### Ideogram Models

* [V3](https://aihubmix.com/model/V3) - Ideogram AI's image generation model, capable of quickly generating images.

## API Interface

### Request URL

```shellscript theme={null}
POST https://aihubmix.com/v1/models/<model_path>/predictions
```

<Tip>
  \<model\_path> is \<provider/model\_id>, por exemplo, \<openai/gpt-image-1.5>, \<qianfan/qwen-image>.
</Tip>

### Headers da Requisição

```shellscript theme={null}
Authorization: Bearer $AIHUBMIX_API_KEY
Content-Type: application/json
```

### Parâmetros da Requisição

#### General Parameters

| Parameter | Type    | Required | Description                                                                                                                                                                                         |
| --------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| prompt    | string  | Sim      | Prompt words                                                                                                                                                                                        |
| size      | string  | Não      | Image size, suporta `1K` (not supported in Doubao-4-5 series), `2K`, `4K`, `auto` (default). Qwen series supports: `512*1024`, `768*512`, `768*1024`, `1024*576`, `576*1024`, `1024*1024` (default) |
| image     | string  | Não      | Reference image path                                                                                                                                                                                |
| n         | integer | Não      | Number of images to generate, suporta 1-10, default is 1                                                                                                                                            |
| quality   | string  | Não      | Rendering quality, suporta `low`, `medium`, and `high`; higher quality takes longer time                                                                                                            |

#### OpenAI Model Parameters

| Parameter       | Type   | Required | Description                                                                                                                                  |
| --------------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| input\_fidelity | string | Não      | Fidelity, suporta `high` and `low` (default)                                                                                                 |
| moderation      | string | Não      | Content moderation strictness, suporta `auto` (default, standard filtering) and `low` (less filtering), not supported in image-to-image mode |
| output\_format  | string | Não      | Output image format, suporta `png`, `jpeg` (default) , `webp`                                                                                |

#### Flux Model Parameters

| Parameter         | Type    | Required | Description                                                                                 |
| ----------------- | ------- | -------- | ------------------------------------------------------------------------------------------- |
| safety\_tolerance | integer | Não      | Audit leniency, higher values indicate more leniency. Range `0<=x<=5`, default value is `2` |
| aspect\_ratio     | string  | Não      | Desired aspect ratio for the image, suporta `16:9` (default), `1:1`, `4:3`                  |
| seed              | integer | Não      | Random number seed                                                                          |
| raw               | boolean | Não      | Whether to enable raw mode for a more natural visual effect, default `false`                |

#### Qwen Model Parameters

| Parameter | Type    | Required | Description                                                                             |
| --------- | ------- | -------- | --------------------------------------------------------------------------------------- |
| watermark | boolean | Não      | Whether to add a watermark to the generated image, suporta `true` (default) and `false` |
| seed      | integer | Não      | Random number seed, range `[0,2147483647]`                                              |

#### Doubao Model Parameters

| Parameter                              | Type    | Required | Description                                                                                                                                                     |
| -------------------------------------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| sequential\_image\_generation          | string  | Não      | Control whether to disable composite image functionality                                                                                                        |
| sequential\_image\_generation\_options | object  | Não      | Composite image configuration, effective only when `sequential_image_generation` is `auto`. Currently suporta `max_images`, range \[1, 15], default value is 15 |
| watermark                              | boolean | Não      | Whether to add a watermark to the generated image, suporta `true` (default) and `false`                                                                         |
| seed                                   | integer | Não      | Random number seed, range \[-1, 2147483647], default value is -1                                                                                                |
| response\_format                       | string  | Não      | Return format for the generated image, suporta `url` (link valid for 24 hours after image generation, please download promptly) or `base64_json`                |

<Tip>
  The actual number of images that can be generated is influenced not only by `max_images` but also by the number of reference images provided. The number of input reference images + the final number of generated images ≤ 15.
</Tip>

## Usage Examples

### OpenAI

<CodeGroup>
  ```shellscript Text-to-Image theme={null}
  curl https://aihubmix.com/v1/models/openai/gpt-image-1.5/predictions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-***" \
      -d '{
    "input": {
      "prompt": "A deer drinking in the lake, Sakura petals falling, green and clean water, japanese temple, dappled sunlight, cinematic lighting, expansive view, peace",
      "size": "1024x1024", 
      "n": 1,
      "quality": "high",
      "moderation": "low",
      "background": "auto"
    }
  }'
  ```

  ```shellscript Image-to-Image theme={null}
  curl https://aihubmix.com/v1/images/edits \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -F "model=gpt-image-1.5" \
    -F "prompt=Change the background to blue sky and white clouds." \
    -F "image=@test.png" \
    -F "size=1024x1024"
  ```
</CodeGroup>

#### gpt-image-2

Este é um modelo de edição de imagens da OpenAI. Use o nome completo `gpt-image-2`; `image2` não é um ID de modelo válido. Quando o endpoint retorna `b64_json`, os exemplos abaixo salvam o resultado como `edited.png`.

<CodeGroup>
  ```powershell PowerShell theme={null}
  curl.exe -sS -X POST "https://aihubmix.com/v1/images/edits" `
    -H "Authorization: Bearer YOUR_API_KEY" `
    -F "model=gpt-image-2" `
    -F "prompt=Altere o fundo para céu azul e nuvens brancas." `
    -F "image=@test.png" `
    -F "size=1024x1024" `
    -D headers.txt `
    -o response.json `
    -w "HTTP_CODE:%{http_code}`nTOTAL:%{time_total}`n"

  $b64 = (Get-Content .\response.json -Raw | ConvertFrom-Json).data[0].b64_json
  [IO.File]::WriteAllBytes(".\edited.png", [Convert]::FromBase64String($b64))
  ```

  ```typescript TypeScript theme={null}
  import { readFile, writeFile } from "node:fs/promises";

  const apiKey = process.env.AIHUBMIX_API_KEY;
  if (!apiKey) {
    throw new Error("Set AIHUBMIX_API_KEY first.");
  }

  const form = new FormData();
  form.append("model", "gpt-image-2");
  form.append("prompt", "Altere o fundo para céu azul e nuvens brancas.");
  form.append("image", new Blob([await readFile("test.png")], { type: "image/png" }), "test.png");
  form.append("size", "1024x1024");

  const response = await fetch("https://aihubmix.com/v1/images/edits", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${apiKey}`,
    },
    body: form,
  });

  if (!response.ok) {
    throw new Error(`${response.status} ${await response.text()}`);
  }

  const result = (await response.json()) as {
    data: Array<{ b64_json: string }>;
  };

  await writeFile("edited.png", Buffer.from(result.data[0].b64_json, "base64"));
  ```
</CodeGroup>

### Google Imagen

<CodeGroup>
  ```shell Curl theme={null}
  curl https://aihubmix.com/v1/models/google/imagen-4.0-fast-generate-001/predictions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-***" \
      -d '{
    "input": {
      "prompt": "A deer drinking in the lake, Sakura petals falling, green and clean water, japanese temple, dappled sunlight, cinematic lighting, expansive view, peace",
      "numberOfImages": 1
    }
  }'
  ```
</CodeGroup>

### Qwen

<CodeGroup>
  ```shellscript Qwen-Image theme={null}
  curl https://aihubmix.com/v1/models/qianfan/qwen-image/predictions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-***" \
    -d '{
      "input": {
        "prompt": "A beautiful sunset over a calm ocean",
        "refer_image": "",
        "n": 1,
        "size": "1024x1024",
        "watermark": false
      }
    }'
  ```

  ```shellscript Qwen-Image-Edit theme={null}
  curl https://aihubmix.com/v1/models/qianfan/qwen-image-edit/predictions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-***" \
      -d '{
    "input": {
      "prompt": "Put this bear sitting under the moon (represented by a light gray crescent outline on a white background), holding a guitar, with small stars and speech bubbles like 'Be Kind' floating around.",
      "image": "https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/4766809571/p999719.png",
      "n": 1,
      "size": "1024x1024",
      "watermark": false,
      "seed": 0
    }
  }'
  ```
</CodeGroup>

### Doubao

<CodeGroup>
  ```shellscript Text-to-Image theme={null}
  curl https://aihubmix.com/v1/models/doubao/doubao-seedream-4-0/predictions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer sk-***" \
    -d '{
      "input": {
        "prompt": "Interstellar, black hole, a vintage train bursting out of a black hole, vying for visual impact, cinematic blockbuster, apocalyptic feel, dynamic, contrasting colors, oc rendering, ray tracing, motion blur, depth of field, surrealism, deep blue, the scene is shaped by delicate rich color layers creating the subject and scene, realistic texture, the lighting effects of a dark background create an atmosphere, combining artistic fantasy, exaggerated wide-angle perspective, glare, reflection, extreme light and shadow, strong gravity, devouring",
        "size": "2K",
        "sequential_image_generation": "disabled",
        "stream": false,
        "response_format": "url",
        "watermark": true
      }
    }'
  ```

  ```shellscript Image-to-Image theme={null}
  curl https://aihubmix.com/v1/models/doubao/doubao-seedream-4-5/predictions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer sk-***" \
    -d '{
      "input": {
          "model": "doubao-seedream-4-5",
          "prompt": "Keep the model's pose and the flowing shape of the liquid clothing unchanged. Change the clothing material from silver metal to completely transparent clear water (or glass). Through the liquid flow, the model's skin details can be seen. The light and shadow change from reflection to refraction.",
          "image": "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_5_imageToimage.png",
          "size": "2K",
          "watermark": false
      }
    }'
  ```

  ```shellscript Multi-Image Fusion theme={null}
  curl https://aihubmix.com/v1/models/doubao/doubao-seedream-4-5/predictions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer sk-***" \
    -d '{
      "input": {
          "model": "doubao-seedream-4-5",
          "prompt": "Change the clothing in image 1 to the clothing in image 2",
          "image": ["https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimage_1.png", "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_5_imagesToimage_2.png"],
          "sequential_image_generation": "disabled",
          "size": "2K",
          "watermark": false
      }
    }'
  ```

  ```shellscript Multiple Reference Image Generation theme={null}
  curl https://aihubmix.com/v1/models/doubao/doubao-seedream-4-5/predictions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer sk-***" \
    -d '{
      "input": {
          "model": "doubao-seedream-4-5",
          "prompt": "Generate 3 images of a girl and a cow toy happily riding a roller coaster in an amusement park, covering morning, noon, and evening",
          "image": ["https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimages_1.png", "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimages_2.png"],
          "sequential_image_generation": "auto",
          "sequential_image_generation_options": {
              "max_images": 3
          },
          "size": "2K",
          "watermark": false
      }
    }'
  ```
</CodeGroup>

### Flux

<Note>
  * `flux-2-flex` and `flux-2-pro` are asynchronous endpoints, requiring a two-step request. This series is extremely fast, almost instantaneous.
  * `FLUX.1-Kontext-pro` uses a general interface, providing a one-step process.
</Note>

#### **FLUX One-Step Drawing**

```shellscript theme={null}
curl https://aihubmix.com/v1/images/generations \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer sk-***" \
    -d '{
  "model": "FLUX.1-Kontext-pro",
  "prompt": "a cat in the garden, cute cartoon",
  "safety_tolerance": 6
}' \
| jq -r '.data[0].b64_json' \
| base64 -D > "$HOME/Desktop/image_extract.png"
```

#### **Flux Asynchronous Drawing**

**Passo 1: Send Drawing Request**

<CodeGroup>
  ```shell Text-to-Image theme={null}
  curl https://aihubmix.com/v1/models/bfl/flux-kontext-max/predictions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-***" \
      -d '{
    "input": {
      "prompt": "A deer drinking in the lake, Sakura petals falling, green and clean water, japanese temple, dappled sunlight, cinematic lighting, expansive view, peace. reference style as the given image:",
      "aspect_ratio": "2:3",
      "safety_tolerance": 6
    }
  }'
  ```

  ```shell Image-to-Image theme={null}
  curl https://aihubmix.com/v1/models/bfl/flux-kontext-max/predictions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-***" \
      -d '{
    "input": {
      "prompt": "A deer drinking in the lake, Sakura petals falling, green and clean water, japanese temple, dappled sunlight, cinematic lighting, expansive view, peace. reference style as the given image:",
      "aspect_ratio": "2:3",
      "safety_tolerance": 2,
      "input_image": "https://assets.aihubmix.com/docs/ghibli.png"
    }
  }'
  ```
</CodeGroup>

Output result example:

```shell theme={null}
{
  "output": [
    {
      "taskId": "api.us1.***",
      "polling_url": "https://api.us1.bfl.ai/v1/get_result?id=f9821dbf-f134-41c2-aaa8-5405fb665c76"
    }
  ]
}
```

**Passo 2: Get Gered Image Link**

```shell Get Image theme={null}
curl https://api.aihubmix.com/v1/tasks/<taskId> \
    -H "Authorization: Bearer sk-***" \
    -X GET
```

### Ideogram V3

<Note>
  1. Versions below V3 (V\_2, V\_1, etc.) are old interfaces and are not supported.
  2. The returned links require a proxy network to access.
</Note>

<CodeGroup>
  ```shell Curl theme={null}
  curl https://aihubmix.com/v1/models/ideogram/V3/predictions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-***" \
      -d '{
    "input": {
      "prompt": "A deer drinking in the lake, Sakura petals falling, green and clean water, japanese temple, dappled sunlight, cinematic lighting, expansive view, peace, in the style of Pixar 3D",
      "rendering_speed": "QUALITY",
      "aspect_ratio": "2x1"
    }
  }'
  ```
</CodeGroup>

### iRAG

<CodeGroup>
  ```bash ERNIE iRAG theme={null}
  curl https://aihubmix.com/v1/models/qianfan/irag-1.0/predictions\
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-***" \
    -d '{
      "input": {
        "prompt": "A beautiful sunset over a calm ocean",
        "refer_image": "",
        "n": 1,
        "size": "1024x1024",
        "guidance": 7.5,
        "watermark": false
      }
    }'
  ```

  ```bash ERNIE iRAG Edit theme={null}
  curl https://aihubmix.com/v1/models/qianfan/ernie-irag-edit/predictions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-***" \
      -d '{
    "input": {
      "prompt": "Add a flying pig",
      "image": "http://***"
    }
  }'
  ```
</CodeGroup>

***

Última atualização: 2026-06-01
