限時特惠:GPT Image 2 最低約 $0.008/張
立即生成
公共 API

GPT Image Hub API 文件

使用 Bearer API 金鑰呼叫圖像生成、模型列表、點數餘額和生成記錄查詢介面。

基礎 URLhttps://www.gptimagehub.com鑑權請求標頭Authorization: Bearer gih_live_...

快速開始

1
建立 API 金鑰

登入後打開帳戶中的 API Keys 頁面,建立金鑰,並妥善保存只顯示一次的原始金鑰。

2
檢查模型和點數

呼叫 /api/v1/models 查看模型能力,再呼叫 /api/v1/credits 查看目前點數餘額。

3
提交生成請求

呼叫 /api/v1/images/generations。長時間生成建議設定 async 為 true,並輪詢返回的 poll_url。

介面

GET/api/v1/modelsNo

列出可用圖像模型、支援的比例、畫質和點數消耗。

GET/api/v1/creditsBearer

讀取該 API 金鑰所屬使用者的點數餘額。

POST/api/v1/images/generationsBearer

根據提示詞生成圖像,可選上傳參考圖;設定 async=true 可建立非同步任務。

GET/api/v1/generations/:generationIdBearer

取得生成日誌以及該次生成保存的圖像。

鑑權

除模型列表外,所有 v1 介面都需要在 Authorization 請求標頭中攜帶 API 金鑰。原始金鑰只會在建立時顯示一次;伺服器只保存雜湊值。

Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

模型

模型介面會返回模型 ID、服務商、支援的畫幅比例、支援的畫質、參考圖限制和每張圖的點數消耗。

curl https://www.gptimagehub.com/api/v1/models

GPT IMAGE 2

gpt-image-2
openai
API 模型 IDgpt-image-2
服務商openai
消耗1K: 8 | 2K: 10 | 4K: 12
預設選項auto, 1K
支援的畫質1K, 2K, 4K
支援的比例auto, 1:1, 4:3, 3:4, 3:2, 2:3, 16:9, 9:16, 5:4, 4:5, 21:9, 9:21, 2:1, 1:2, 3:1, 1:3
參考圖最多張數: 16

請求欄位

欄位備註
modelgpt-image-2必須設定為此 API 模型 ID
size1024x1024OpenAI 相容的輸出尺寸,例如 auto 或 1024x1024
qualityhigh可選畫質: auto, low, medium, high
n1生成數量,範圍 1 到 4
reference_image@./reference.png僅用於 multipart/form-data;數量不能超過模型限制

JSON 呼叫

curl https://www.gptimagehub.com/api/v1/images/generations \
  -H "Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A cinematic product photo with premium studio lighting",
    "size": "1024x1024",
    "quality": "high",
    "n": 1
  }'

參考圖呼叫

curl https://www.gptimagehub.com/api/v1/images/generations \
  -H "Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -F "model=gpt-image-2" \
  -F "prompt=Use the reference image and render it as a premium studio product shot" \
  -F "size=1024x1024" \
  -F "quality=high" \
  -F "n=1" \
  -F "reference_image=@./reference.png"

點數餘額

點數介面會返回該 API 金鑰所屬使用者的餘額、帳戶類型和即將到期的點數資訊。

curl https://www.gptimagehub.com/api/v1/credits \
  -H "Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

生成圖像

圖像生成介面預設會等待生成完成。設定 async 為 true 可以立即取得 generation id,並透過 /api/v1/generations/:generationId 輪詢結果。生成前會扣除點數;如果服務商生成失敗或返回的圖片少於請求數量,會自動退還相應點數。

JSON 請求

curl https://www.gptimagehub.com/api/v1/images/generations \
  -H "Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A cinematic product photo of a transparent perfume bottle on black marble",
    "size": "1024x1024",
    "quality": "high",
    "n": 1
  }'

非同步任務

curl https://www.gptimagehub.com/api/v1/images/generations \
  -H "Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A cinematic product photo with premium studio lighting",
    "size": "1024x1024",
    "quality": "high",
    "n": 1,
    "async": true
  }'
{
  "object": "image_generation",
  "id": "clx_generation_log_id",
  "status": "queued",
  "model": "gpt-image-2",
  "aspect_ratio": "1:1",
  "quality": "1K",
  "created_at": "2026-04-30T08:00:00.000Z",
  "images": [],
  "usage": {
    "credits": 0,
    "credits_requested": 8
  },
  "poll_url": "https://www.gptimagehub.com/api/v1/generations/clx_generation_log_id"
}

參考圖請求

curl https://www.gptimagehub.com/api/v1/images/generations \
  -H "Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -F "model=gpt-image-2" \
  -F "prompt=Use the reference image and render it as a premium studio product shot" \
  -F "size=1024x1024" \
  -F "quality=high" \
  -F "n=1" \
  -F "reference_image=@./reference.png"

回應

{
  "object": "image_generation",
  "id": "clx_generation_log_id",
  "status": "succeeded",
  "model": "gpt-image-2",
  "aspect_ratio": "1:1",
  "quality": "1K",
  "images": [
    {
      "id": "clx_image_id",
      "object": "image",
      "url": "https://cdn.example.com/generations/user/image.png",
      "created_at": "2026-04-30T08:00:00.000Z"
    }
  ],
  "usage": {
    "credits": 8
  },
  "balance": {
    "credits": 112,
    "account_type": "PRO",
    "next_expiration": null
  }
}

查詢生成記錄

使用生成介面返回的 ID 查詢保存的生成日誌和圖片 URL。API 金鑰只能讀取同一使用者名下的生成記錄。

curl https://www.gptimagehub.com/api/v1/generations/clx_generation_log_id \
  -H "Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

錯誤

{
  "error": {
    "message": "Invalid request body",
    "code": "invalid_request"
  }
}
HTTPcode說明
400invalid_request請求體或參數無效。
401missingApiKey缺少 Authorization 請求標頭。
401invalidApiKeyAPI 金鑰不存在或已被撤銷。
401expiredApiKeyAPI 金鑰已過期。
402insufficientCredits帳戶點數不足。
404notFound請求的資源不存在。
500generationFailed圖像生成失敗。

限制

  • 同步生成介面在生產環境最長可執行 800 秒。
  • n 必須介於 1 和 4 之間。
  • 參考圖支援 PNG、JPG、JPEG 和 WebP。單個檔案最大 50MB。
  • 最大參考圖數量由每個模型的 reference_image_limit 決定。
  • 非同步模式會返回 202 和 poll_url。目前版本暫不包含 webhook 或獨立的 API 速率限制。