---
title: AI 圖像生成 API | RunAPI
description: 透過一個 API 使用圖像模型，生成、編輯、放大並移除背景。
url: https://runapi.ai/zh-TW/image.md
canonical: https://runapi.ai/zh-TW/image
locale: zh-TW
site: RunAPI
image: https://runapi.ai/assets/opengraph-bfaaa0f0.png
alternates:
  en: https://runapi.ai/image
  zh-CN: https://runapi.ai/zh-CN/image
  es: https://runapi.ai/es/image
  ja: https://runapi.ai/ja/image
  de: https://runapi.ai/de/image
  fr: https://runapi.ai/fr/image
  pt-BR: https://runapi.ai/pt-BR/image
  ko: https://runapi.ai/ko/image
  it: https://runapi.ai/it/image
  nl: https://runapi.ai/nl/image
  pl: https://runapi.ai/pl/image
  tr: https://runapi.ai/tr/image
  zh-TW: https://runapi.ai/zh-TW/image
  zh-HK: https://runapi.ai/zh-HK/image
  ar: https://runapi.ai/ar/image
  x-default: https://runapi.ai/image
---

> HTML version: https://runapi.ai/zh-TW/image
> Site index for agents: https://runapi.ai/llms.txt


圖像 API

# AI 圖像生成 API

透過一個 API 使用 Flux、Midjourney、Ideogram、GPT Image 和 Imagen 生成、編輯、放大並移除背景。

- [取得 API 金鑰](https://runapi.ai/zh-TW/login)
- [瀏覽模型](https://runapi.ai/zh-TW/models.md)

57 個圖像模型 - 依張計費

- 圖像模型: 57
- 低於官方價格: —
- 中位延遲: 21s

## Playground

- Flux Pro 1.1: ≈ $0.05 / 張
- GPT Image 2: ≈ $0.02 / 百萬像素
- Midjourney v7: ≈ $0.08 / 張

提示詞: 冷調晨光下，磨砂陶瓷杯置於髮絲紋鋼板上的編輯風格產品照，單顆柔光箱打光

- 尺寸: 1024 x 1024
- 風格: 寫實攝影
- 批次: 4 張圖像
- 模式: text_to_image

預估費用: ≈ $0.05 / 張

範例

## 圖片範例

### 人物肖像

![人物肖像](https://cdn.runapi.ai/public/homepage/media-showcase/b331927cb3fcf76a-runapi.ai-flux-pro.jpg)


### 金剛鸚鵡

![金剛鸚鵡](https://cdn.runapi.ai/public/homepage/media-showcase/b1ff27fb20bffd98-runapi.ai-midjourney-v7.jpg)




## 圖像端點能做到的一切

- **文字轉圖像** - 一句提示詞，一次呼叫。尺寸、風格與批次數量都是同一端點上的簡單參數。
- **圖像編輯** - 對既有圖像進行指令式編輯——更換材質、顏色或整個背景。
- **局部重繪** - 標記一個區域並只重新生成該區域，其餘畫面像素保持完全一致。


## 一組金鑰，串接所有圖像模型

| Model | Provider | Price |
| --- | --- | --- |
| Flux/flux-2-klein | Black Forest Labs | $0.03 / image |
| Flux/flux-dev | Black Forest Labs | $0.06 / image |
| Flux/flux-pro | Black Forest Labs | $0.07 / image |
| Flux 2/flux-2-flex-remix-image | Black Forest Labs | $0.14-$0.24 / image |
| Flux 2/flux-2-flex-text-to-image | Black Forest Labs | $0.14-$0.24 / image |
| Flux 2/flux-2-max-remix-image | Black Forest Labs | $0.15 / image |
| Flux 2/flux-2-max-text-to-image | Black Forest Labs | $0.15 / image |
| Flux 2/flux-2-pro-remix-image | Black Forest Labs | $0.06-$0.07 / image |


[查看全部 57 個圖像模型](https://runapi.ai/zh-TW/models.md)


## 快速入門

### 生成一張圖像

#### curl

```bash
curl https://runapi.ai/api/v1/flux/text_to_image \
  -H "Authorization: Bearer $RUNAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"flux-2-klein","prompt":"A cobalt vase on white marble."}'
```

#### Python

```python
import json
import os
import requests

response = requests.post(
    "https://runapi.ai/api/v1/flux/text_to_image",
    headers={"Authorization": f"Bearer {os.environ['RUNAPI_API_KEY']}"},
    json=json.loads("{\"model\":\"flux-2-klein\",\"prompt\":\"A cobalt vase on white marble.\"}")
)
response.raise_for_status()
print(response.json())
```

#### Node.js

```javascript
const response = await fetch("https://runapi.ai/api/v1/flux/text_to_image", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.RUNAPI_API_KEY,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({"model":"flux-2-klein","prompt":"A cobalt vase on white marble."})
});
console.log(await response.json());
```

#### Go

```go
package main

import (
    "io"
    "net/http"
    "os"
    "strings"
)

func main() {
    payload := strings.NewReader("{\"model\":\"flux-2-klein\",\"prompt\":\"A cobalt vase on white marble.\"}")
    request, err := http.NewRequest("POST", "https://runapi.ai/api/v1/flux/text_to_image", payload)
    if err != nil { panic(err) }
    request.Header.Set("Authorization", "Bearer "+os.Getenv("RUNAPI_API_KEY"))
    request.Header.Set("Content-Type", "application/json")
    response, err := http.DefaultClient.Do(request)
    if err != nil { panic(err) }
    defer response.Body.Close()
    io.Copy(os.Stdout, response.Body)
}
```

#### 回應

```json
{
  "id": "tsk_example",
  "status": "processing"
}
```



## 四步驟完成首次生成

**使用方式**

1. **取得 API 金鑰** - 一組金鑰即可用於全部 57 個圖像模型。
2. **選擇模型** - Flux、Midjourney、GPT Image、Ideogram、Recraft——依風格或速度挑選。
3. **送出請求** - POST 到 /api/v1/flux/text_to_image。我們會以最低價格路由到最佳供應商。
4. **下載結果** - 回應內含 CDN URL。圖像通常在 3-15 秒內就緒。



## 開發者選擇 RunAPI 的理由

- **一組金鑰，串接所有模型** - 不用再管理多組 API 金鑰。一次整合即可透過所有供應商存取 57 個圖像模型。
- **節省 15-25% 成本** - 我們與供應商的批量協議帶來低於直接採購的價格，且不額外加價。
- **自動故障切換** - 供應商發生故障時，我們會將請求路由到下一個最佳選項，讓你的應用程式持續運作。
- **相容 OpenAI** - 可直接取代 OpenAI SDK。只需修改一行程式碼即可存取任何模型。
- **即時計費** - 只為實際使用付費。按請求計價、沒有最低消費，並可按模型和專案追蹤成本。
- **資料隱私** - 隱私政策說明了請求資料和生成內容的處理與保存方式。



### 探索更多

## 更多 AI API

- [影片 API](https://runapi.ai/zh-TW/models.md?modality=video) - 使用 76 個模型生成、編輯及放大影片 [了解更多](https://runapi.ai/zh-TW/models.md?modality=video)
- [音樂 API](https://runapi.ai/zh-TW/models.md?modality=audio_music) - 用 AI 創作原創音樂 [了解更多](https://runapi.ai/zh-TW/models.md?modality=audio_music)
- [音訊 API](https://runapi.ai/zh-TW/models.md?modality=audio_music) - 使用 32 種聲音進行文字轉語音 [了解更多](https://runapi.ai/zh-TW/models.md?modality=audio_music)
- [LLM API](https://runapi.ai/zh-TW/models.md?modality=text) - 使用 66 個語言模型完成對話生成 [了解更多](https://runapi.ai/zh-TW/models.md?modality=text)



## 團隊用它打造的內容

- **商品型錄** - 為數千個 SKU 生成符合品牌調性的產品照，並在同一條流程中移除背景。
- **廣告素材** - 依渠道與畫面比例批次生成變體，不必更動請求程式碼即可切換模型。
- **應用程式功能** - 以每組金鑰設定消費上限的方式，將頭像、貼圖或縮圖生成上線為產品功能。
- **設計系統** - 用圖像轉提示詞維持系列一致性，再透過局部重繪的遮罩持續迭代。



## RunAPI 與替代方案比較

| 功能 | RunAPI | 直接串接 API | Replicate |
| --- | --- | --- | --- |
| 圖像模型數量 | 57 | 1 家供應商 | 約 20 個 |
| 價格 | 低於官方價格 15-25% | 官方價格 | 市場價格 + GPU 加價 |
| 回應時間 | 通常 3-15 秒 | 依供應商而定 | 有冷啟動延遲 |
| 統一帳單 | ✓ | ✗ | ✓ |
| MCP server | ✓ | ✗ | ✗ |
| 供應商故障切換 | ✓ | ✗ | ✗ |


## 圖像 API 常見問題

### 圖像生成如何計費？

依模型不同，以每張圖或每百萬像素計費。目錄會在每個價格旁列出確切的計費單位。

### 可以編輯我已有的圖像嗎？

可以。傳入你的圖像並指定 task_type 為 image_edit 或 inpaint，再附上指令或遮罩。

### Midjourney 真的能透過 API 使用嗎？

可以，透過 RunAPI 的代管整合即可使用，其請求結構與其他圖像模型完全相同。

### 最高解析度是多少？

原生解析度取決於所選模型；在支援的情況下，專用放大模型可產出 4K 輸出。

### 你們會保留我的圖像嗎？

輸出保留原則依當前端點合約而定。RunAPI 不會將提示詞或輸出用於模型訓練。

### 可以設定每個專案的消費上限嗎？

可以。為每個專案建立獨立的 API 金鑰，並設定其可用額度與重置週期。

## 為你的產品加入圖像生成功能

57 個模型，共用一種 OpenAI 格式的請求。免費開始，不需信用卡。

- [取得 API 金鑰](https://runapi.ai/zh-TW/login)
- [閱讀文件](https://runapi.ai/zh-TW/docs/guides)




---

## More from RunAPI

- [Home](https://runapi.ai/zh-TW/.md)
### 產品
- [模型目錄](https://runapi.ai/zh-TW/models.md)
- [價格](https://runapi.ai/zh-TW/pricing.md)
- [提供商](https://runapi.ai/zh-TW/models#all-models)
### 開發者
- [文件](https://runapi.ai/zh-TW/docs/guides)
- [SDK](https://runapi.ai/zh-TW/sdk.md)
- [CLI](https://runapi.ai/zh-TW/cli.md)
- [MCP Server](https://runapi.ai/zh-TW/mcp.md)
### 指南
- [Claude Code 與 Cursor](https://runapi.ai/zh-TW/claude-code-vs-cursor.md)
- [Cursor API 設定](https://runapi.ai/zh-TW/cursor-api-setup.md)
- [RunAPI 與 OpenRouter](https://runapi.ai/zh-TW/openrouter-alternative.md)
### 公司
- [企業版](https://runapi.ai/zh-TW/contact.md)
- [聯絡我們](https://runapi.ai/zh-TW/contact.md)
### 法律
- [服務條款](https://runapi.ai/zh-TW/terms.md)
- [隱私權](https://runapi.ai/zh-TW/privacy.md)
- [Site index for agents](https://runapi.ai/llms.txt)

Contact: contact@runapi.ai

## Structured data

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-TW",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-TW",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/zh-TW/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-TW",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-TW",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/zh-TWicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-TW",
    "@type": "SoftwareApplication",
    "name": "RunAPI",
    "applicationCategory": "DeveloperApplication",
    "description": "透過一個 API 使用圖像模型，生成、編輯、放大並移除背景。",
    "url": "https://runapi.ai/zh-TW/image"
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-TW",
    "@type": "BreadcrumbList",
    "itemListElement": [
      {
        "@type": "ListItem",
        "position": 1,
        "name": "首頁",
        "item": "https://runapi.ai/zh-TW"
      },
      {
        "@type": "ListItem",
        "position": 2,
        "name": "RunAPI",
        "item": "https://runapi.ai/zh-TW/image"
      }
    ]
  }
]
```
