> ## 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.

# 通用圖形介面

## 介面說明

為了方便開發者呼叫不同的圖像生成模型，Aihubmix 提供了統一的圖形介面，支援以下多種主流模型：

* [OpenAI 系列](#openai)
* [Ideogram V3](#ideogram-v3)
* [Stability SD 3.5 Large](#stability)
* [Google Imagen 系列](#google-imagen)

**介面規格：**

```shell Curl theme={null}
curl https://aihubmix.com/v1/models/<model_path>/predictions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer sk-***" \
    -d '{
  "input": {
    "prompt": "your prompt"
  }
}'
```

**其中：**

* `https://aihubmix.com/v1/models/` 為固定前綴
* `<model_path>` 為模型路徑，支援：
  * `openai/gpt-image-2`
  * `opanai/gpt-image-1`
  * `opanai/dall-e-3`
  * `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`
  * `flux-kontext-max`
  * `flux-kontext-pro`
  * `FLUX.1-Kontext-pro`
  * `FLUX-1.1-pro`
  * `ideogram/V3`
  * `stability/Stable-Diffusion-3-5-Large`
* `sk-***` 為你在 Aihubmix 生成的 API Key

***

下面是各個模型的呼叫方法。

## OpenAI

### 支援的模型：

* [gpt-image-2](https://aihubmix.com/model/gpt-image-2)（支援透過 OpenAI 相容圖片編輯端點呼叫，模型 ID 必須寫成 `gpt-image-2`，不可簡寫為 `image2`）
* gpt-image-1
* dall-e-3

### 呼叫方法：

<CodeGroup>
  ```shell Curl gpt-image-1 theme={null}
  curl https://aihubmix.com/v1/models/opanai/gpt-image-1/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"
    }
  }'
  ```

  ```shell Curl dall-e-3 theme={null}
  curl https://aihubmix.com/v1/models/opanai/dall-e-3/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
    }
  }'
  ```
</CodeGroup>

### gpt-image-2

這是 OpenAI 圖片編輯模型，呼叫時請填寫完整模型名 `gpt-image-2`，不可簡寫為 `image2`。該端點返回 `b64_json` 時，可按下面範例保存為 `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=把背景換成藍天白雲" `
    -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", "把背景換成藍天白雲");
  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>

## Ideogram V3

### 支援的模型：

* V3

<Note>
  1. V3 以下版本（V\_2、V\_1 等）為舊介面，暫不支援
  2. 返回的連結需要開啟代理網路才能取得
</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>

## Stability

### 支援的模型：

* Stable-Diffusion-3-5-Large

### 呼叫方法：

<CodeGroup>
  ```shell Curl theme={null}
  curl https://aihubmix.com/v1/models/stability/Stable-Diffusion-3-5-Large/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",
      "n": 1
    }
  }'
  ```
</CodeGroup>

## Google Imagen

### 支援的模型：

* 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

<Note>
  不支援 gemini 系列
</Note>

### 呼叫方法：

<CodeGroup>
  ```shell Curl theme={null}
  curl https://aihubmix.com/v1/models/google/imagen-3.0-generate-002/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>

***

最後更新：2026-06-01
