Public API

GPT Image Hub API Docs

Use Bearer API keys to call image generation, model listing, credit balance, and generation lookup endpoints.

Base URLhttps://your-domain.comAuthentication headerAuthorization: Bearer gih_live_...

Quickstart

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 and read image URLs plus credit usage from the response.

Endpoints

GET/api/v1/modelsNo

List available image models, supported ratios, qualities, and credit cost.

GET/api/v1/creditsBearer

Read the credit balance for the user that owns the API key.

POST/api/v1/images/generationsBearer

Synchronously generate images from a prompt, with optional reference images.

GET/api/v1/generations/:generationIdBearer

Fetch a generation log and the images saved for that generation.

Authentication

All v1 endpoints except model listing require an API key in the Authorization header. The raw key is shown once at creation time; the server stores only a hash.

Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Models

The models endpoint returns model IDs, providers, supported aspect ratios, supported qualities, reference image limits, and credits per image.

curl https://your-domain.com/api/v1/models

GPT IMAGE 2

gpt-image-2
openai
API model IDgpt-image-2
Provideropenai
Provider modelgpt-image-2
Credits1 / image
Default optionsauto, 1K
Supported qualities1K, 2K, 4K
Supported ratiosauto, 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
Reference imagesMax images: 16

Request fields

FieldValueNotes
modelgpt-image-2Must be set to this model ID
aspect_ratioautoCan be any aspect ratio supported by this model
quality1KAvailable qualities: 1K, 2K, 4K
n1Image count, from 1 to 4
reference_image@./reference.pngOnly for multipart/form-data; count cannot exceed the model limit

JSON call

curl https://your-domain.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",
    "aspect_ratio": "auto",
    "quality": "1K",
    "n": 1
  }'

Reference image call

curl https://your-domain.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 "aspect_ratio=auto" \
  -F "quality=1K" \
  -F "n=1" \
  -F "reference_image=@./reference.png"

Credits

The credits endpoint returns the balance, account type, and upcoming credit expiration for the user that owns the API key.

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

Generate images

The image generation endpoint is synchronous. Credits are charged before generation and refunded automatically when the provider fails. Use JSON for text-only generation and multipart/form-data for reference images.

JSON request

curl https://your-domain.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",
    "aspect_ratio": "1:1",
    "quality": "1K",
    "n": 1
  }'

Reference image request

curl https://your-domain.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 "aspect_ratio=1:1" \
  -F "quality=1K" \
  -F "n=1" \
  -F "reference_image=@./reference.png"

Response

{
  "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": 1
  },
  "balance": {
    "credits": 119,
    "account_type": "PRO",
    "next_expiration": null
  }
}

Retrieve generation

Use the id returned by the generation endpoint to retrieve its saved log and image URLs. API keys can only read generations owned by the same user.

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

Errors

{
  "error": {
    "message": "Invalid request body",
    "code": "invalid_request"
  }
}
HTTPcodeDescription
400invalid_requestThe request body or parameters are invalid.
401missingApiKeyThe Authorization header is missing.
401invalidApiKeyThe API key does not exist or has been revoked.
401expiredApiKeyThe API key is expired.
402insufficientCreditsThe account does not have enough credits.
404notFoundThe requested resource was not found.
500generationFailedImage generation failed.

Limits

  • The generation endpoint is synchronous and has a maximum duration of 600 seconds.
  • 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.
  • This version does not include webhooks, async job queues, or a separate API rate limit.