GPT Image Hub API Tài liệu
Sử dụng các phím Bearer API để gọi việc tạo hình ảnh, danh sách mô hình, số dư tín dụng và điểm cuối tra cứu thế hệ.
https://www.gptimagehub.comTiêu đề xác thựcAuthorization: Bearer gih_live_...Bắt đầu nhanh
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.
Điểm cuối
/api/v1/modelsNoLiệt kê các mô hình hình ảnh có sẵn, tỷ lệ được hỗ trợ, chất lượng và chi phí tín dụng.
/api/v1/creditsBearerĐọc số dư tín dụng của người dùng sở hữu khóa API.
/api/v1/images/generationsBearerGenerate images from a prompt, or set async=true to queue a background task.
/api/v1/generations/:generationIdBearerTìm nạp nhật ký thế hệ và hình ảnh được lưu cho thế hệ đó.
Xác thực
Tất cả các điểm cuối v1 ngoại trừ danh sách mô hình đều yêu cầu khóa API trong tiêu đề Authorization. Khóa thô được hiển thị một lần tại thời điểm tạo; máy chủ chỉ lưu trữ một hàm băm.
Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNgười mẫu
Điểm cuối của mô hình trả về ID mô hình, nhà cung cấp, tỷ lệ khung hình được hỗ trợ, chất lượng được hỗ trợ, giới hạn hình ảnh tham chiếu và tín dụng cho mỗi hình ảnh.
curl https://www.gptimagehub.com/api/v1/modelsGPT IMAGE 2
gpt-image-2Các trường yêu cầu
| trường | Giá trị | Ghi chú |
|---|---|---|
model | gpt-image-2 | Phải được đặt thành ID mẫu này |
size | 1024x1024 | OpenAI-compatible output size, for example auto or 1024x1024 |
quality | high | Phẩm chất sẵn có: auto, low, medium, high |
n | 1 | Số lượng hình ảnh, từ 1 đến 4 |
reference_image | @./reference.png | Chỉ dành cho multipart/form-data; số lượng không thể vượt quá giới hạn mô hình |
JSON gọi
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
}'Cuộc gọi hình ảnh tham khảo
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"Tín dụng
Điểm cuối tín dụng trả về số dư, loại tài khoản và thời hạn tín dụng sắp hết hạn cho người dùng sở hữu khóa API.
curl https://www.gptimagehub.com/api/v1/credits \
-H "Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"Tạo hình ảnh
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 yêu cầu
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"
}Yêu cầu hình ảnh tham khảo
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"phản hồi
{
"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
}
}Truy xuất thế hệ
Sử dụng id được điểm cuối tạo trả về để truy xuất nhật ký và hình ảnh đã lưu của nó URLs. Khóa API chỉ có thể đọc các thế hệ thuộc sở hữu của cùng một người dùng.
curl https://www.gptimagehub.com/api/v1/generations/clx_generation_log_id \
-H "Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"Lỗi
{
"error": {
"message": "Invalid request body",
"code": "invalid_request"
}
}| HTTP | code | Mô tả |
|---|---|---|
| 400 | invalid_request | Nội dung hoặc thông số yêu cầu không hợp lệ. |
| 401 | missingApiKey | Tiêu đề Authorization bị thiếu. |
| 401 | invalidApiKey | Khóa API không tồn tại hoặc đã bị thu hồi. |
| 401 | expiredApiKey | Khóa API đã hết hạn. |
| 402 | insufficientCredits | Tài khoản không có đủ tín dụng. |
| 404 | notFound | Không tìm thấy tài nguyên được yêu cầu. |
| 500 | generationFailed | Tạo hình ảnh không thành công. |
Giới hạn
- 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.