โปรโมชันจำกัดเวลา: GPT Image 2 เริ่มที่ $0.008 ต่อภาพ
ลองเลย
สาธารณะ API

GPT Image Hub API เอกสาร

ใช้คีย์ Bearer API เพื่อเรียกการสร้างอิมเมจ รายการโมเดล ยอดเครดิตคงเหลือ และจุดสิ้นสุดการค้นหาการสร้าง

ฐาน URLhttps://www.gptimagehub.comส่วนหัวการรับรองความถูกต้องAuthorization: Bearer gih_live_...

เริ่มต้นอย่างรวดเร็ว

1
Create an API key

Sign in, open API Keys in your account, create a key, and store the one-time secret.

2
Check models and credits

Call /api/v1/models for model capabilities, then /api/v1/credits for your balance.

3
Submit a generation request

Call /api/v1/images/generations. For long-running calls, set async to true and poll the returned poll_url.

จุดสิ้นสุด

GET/api/v1/modelsNo

แสดงรายการโมเดลรูปภาพที่มีอยู่ อัตราส่วนที่รองรับ คุณภาพ และต้นทุนเครดิต

GET/api/v1/creditsBearer

อ่านยอดเครดิตสำหรับผู้ใช้ที่เป็นเจ้าของคีย์ API

POST/api/v1/images/generationsBearer

Generate images from a prompt, or set async=true to queue a background task.

GET/api/v1/generations/:generationIdBearer

ดึงบันทึกการสร้างและรูปภาพที่บันทึกไว้สำหรับรุ่นนั้น

การรับรองความถูกต้อง

ตำแหน่งข้อมูล v1 ทั้งหมดยกเว้นรายการโมเดลจำเป็นต้องมีคีย์ API ในส่วนหัว Authorization คีย์ดิบจะแสดงหนึ่งครั้งในเวลาที่สร้าง เซิร์ฟเวอร์เก็บเฉพาะแฮชเท่านั้น

Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

โมเดล

จุดสิ้นสุดของโมเดลส่งคืน ID โมเดล ผู้ให้บริการ อัตราส่วนภาพที่รองรับ คุณภาพที่รองรับ ขีดจำกัดรูปภาพอ้างอิง และเครดิตต่อรูปภาพ

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

GPT IMAGE 2

gpt-image-2
openai
API รหัสรุ่นgpt-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ต้องตั้งค่าเป็นรหัสรุ่นนี้
size1024x1024OpenAI-compatible output size, for example auto or 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"

สร้างภาพ

The image generation endpoint waits for completion by default. Set async to true to receive a generation id immediately and poll /api/v1/generations/:generationId for the result. Credits are charged before provider generation and refunded automatically when the provider fails or returns fewer images than requested.

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
  }'

Async task

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
  }
}

ดึงข้อมูลรุ่น

ใช้รหัสที่ส่งคืนโดยจุดสิ้นสุดการสร้างเพื่อดึงบันทึกและรูปภาพ URLs ที่บันทึกไว้ คีย์ 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 หายไป
401invalidApiKeyไม่มีคีย์ API หรือถูกเพิกถอนแล้ว
401expiredApiKeyคีย์ API หมดอายุแล้ว
402insufficientCreditsบัญชีมีเครดิตไม่เพียงพอ
404notFoundไม่พบทรัพยากรที่ร้องขอ
500generationFailedการสร้างอิมเมจล้มเหลว

ขีดจำกัด

  • Synchronous generation can run for up to 800 seconds on production.
  • n must be between 1 and 4.
  • Reference images support PNG, JPG, JPEG, and WebP. Each file can be up to 50MB.
  • The maximum reference image count is defined by each model's reference_image_limit.
  • Async mode returns 202 with poll_url. Webhooks and a separate API rate limit are not included yet.