GPT Image Hub API เอกสาร
ใช้คีย์ Bearer API เพื่อเรียกการสร้างอิมเมจ รายการโมเดล ยอดเครดิตคงเหลือ และจุดสิ้นสุดการค้นหาการสร้าง
https://www.gptimagehub.comส่วนหัวการรับรองความถูกต้องAuthorization: Bearer gih_live_...เริ่มต้นอย่างรวดเร็ว
Sign in, open API Keys in your account, create a key, and store the one-time secret.
Call /api/v1/models for model capabilities, then /api/v1/credits for your balance.
Call /api/v1/images/generations. For long-running calls, set async to true and poll the returned poll_url.
จุดสิ้นสุด
/api/v1/modelsNoแสดงรายการโมเดลรูปภาพที่มีอยู่ อัตราส่วนที่รองรับ คุณภาพ และต้นทุนเครดิต
/api/v1/creditsBearerอ่านยอดเครดิตสำหรับผู้ใช้ที่เป็นเจ้าของคีย์ API
/api/v1/images/generationsBearerGenerate images from a prompt, or set async=true to queue a background task.
/api/v1/generations/:generationIdBearerดึงบันทึกการสร้างและรูปภาพที่บันทึกไว้สำหรับรุ่นนั้น
การรับรองความถูกต้อง
ตำแหน่งข้อมูล v1 ทั้งหมดยกเว้นรายการโมเดลจำเป็นต้องมีคีย์ API ในส่วนหัว Authorization คีย์ดิบจะแสดงหนึ่งครั้งในเวลาที่สร้าง เซิร์ฟเวอร์เก็บเฉพาะแฮชเท่านั้น
Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxโมเดล
จุดสิ้นสุดของโมเดลส่งคืน ID โมเดล ผู้ให้บริการ อัตราส่วนภาพที่รองรับ คุณภาพที่รองรับ ขีดจำกัดรูปภาพอ้างอิง และเครดิตต่อรูปภาพ
curl https://www.gptimagehub.com/api/v1/modelsGPT IMAGE 2
gpt-image-2ฟิลด์คำขอ
| สนาม | ความคุ้มค่า | หมายเหตุ |
|---|---|---|
model | gpt-image-2 | ต้องตั้งค่าเป็นรหัสรุ่นนี้ |
size | 1024x1024 | OpenAI-compatible output size, for example auto or 1024x1024 |
quality | high | คุณภาพที่มีอยู่: auto, low, medium, high |
n | 1 | จำนวนภาพตั้งแต่ 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"
}
}| HTTP | code | คำอธิบาย |
|---|---|---|
| 400 | invalid_request | เนื้อหาคำขอหรือพารามิเตอร์ไม่ถูกต้อง |
| 401 | missingApiKey | ส่วนหัว Authorization หายไป |
| 401 | invalidApiKey | ไม่มีคีย์ API หรือถูกเพิกถอนแล้ว |
| 401 | expiredApiKey | คีย์ API หมดอายุแล้ว |
| 402 | insufficientCredits | บัญชีมีเครดิตไม่เพียงพอ |
| 404 | notFound | ไม่พบทรัพยากรที่ร้องขอ |
| 500 | generationFailed | การสร้างอิมเมจล้มเหลว |
ขีดจำกัด
- 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.