Ưu đãi có thời hạn: GPT Image 2 từ $0.008 mỗi ảnh
Thử ngay
Công khai API

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ệ.

Cơ sở URLhttps://www.gptimagehub.comTiêu đề xác thựcAuthorization: Bearer gih_live_...

Bắt đầu nhanh

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.

Điểm cuối

GET/api/v1/modelsNo

Liệ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.

GET/api/v1/creditsBearer

Đọc số dư tín dụng của người dùng sở hữu khóa 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

Tì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_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Ngườ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/models

GPT IMAGE 2

gpt-image-2
openai
API ID mẫugpt-image-2
nhà cung cấpopenai
Tín dụng1K: 8 | 2K: 10 | 4K: 12
Tùy chọn mặc địnhauto, 1K
Phẩm chất được hỗ trợ1K, 2K, 4K
Tỷ lệ được hỗ trợ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
Hình ảnh tham khảoHình ảnh tối đa: 16

Các trường yêu cầu

trườngGiá trịGhi chú
modelgpt-image-2Phải được đặt thành ID mẫu này
size1024x1024OpenAI-compatible output size, for example auto or 1024x1024
qualityhighPhẩm chất sẵn có: auto, low, medium, high
n1Số lượng hình ảnh, từ 1 đến 4
reference_image@./reference.pngChỉ 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"
  }
}
HTTPcodeMô tả
400invalid_requestNội dung hoặc thông số yêu cầu không hợp lệ.
401missingApiKeyTiêu đề Authorization bị thiếu.
401invalidApiKeyKhóa API không tồn tại hoặc đã bị thu hồi.
401expiredApiKeyKhóa API đã hết hạn.
402insufficientCreditsTài khoản không có đủ tín dụng.
404notFoundKhông tìm thấy tài nguyên được yêu cầu.
500generationFailedTạ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.