Oferta ograniczona czasowo: GPT Image 2 od $0.008 za obraz
Wypróbuj teraz
Publiczne API

GPT Image Hub API Dokumentacja

Użyj kluczy Bearer API, aby wywołać generowanie obrazu, listę modeli, saldo kredytowe i punkty końcowe wyszukiwania generacji.

Baza URLhttps://www.gptimagehub.comNagłówek uwierzytelnianiaAuthorization: Bearer gih_live_...

Szybki start

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.

Punkty końcowe

GET/api/v1/modelsNo

Lista dostępnych modeli obrazów, obsługiwanych współczynników, jakości i kosztów kredytu.

GET/api/v1/creditsBearer

Odczytaj saldo kredytu użytkownika będącego właścicielem klucza 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

Pobierz dziennik generacji i obrazy zapisane dla tej generacji.

Uwierzytelnianie

Wszystkie punkty końcowe w wersji 1 z wyjątkiem listy modeli wymagają klucza API w nagłówku Authorization. Surowy klucz jest wyświetlany raz w momencie tworzenia; serwer przechowuje tylko skrót.

Authorization: Bearer gih_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Modele

Punkt końcowy modeli zwraca identyfikatory modeli, dostawców, obsługiwane współczynniki proporcji, obsługiwane jakości, limity obrazów referencyjnych i kredyty na obraz.

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

GPT IMAGE 2

gpt-image-2
openai
API identyfikator modelugpt-image-2
Dostawcaopenai
Kredyty1K: 8 | 2K: 10 | 4K: 12
Opcje domyślneauto, 1K
Obsługiwane cechy1K, 2K, 4K
Obsługiwane współczynnikiauto, 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
Obrazy referencyjneMaks. obrazów: 16

Pola żądania

PoleWartośćNotatki
modelgpt-image-2Musi być ustawiony na ten identyfikator modelu
size1024x1024OpenAI-compatible output size, for example auto or 1024x1024
qualityhighDostępne jakości: auto, low, medium, high
n1Liczba obrazów, od 1 do 4
reference_image@./reference.pngTylko dla multipart/form-data; liczba nie może przekroczyć limitu modelu

JSON zadzwoń

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

Wywołanie obrazu referencyjnego

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"

Kredyty

Punkt końcowy kredytów zwraca saldo, typ konta i zbliżającą się wygaśnięcie kredytu dla użytkownika będącego właścicielem klucza API.

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

Generuj obrazy

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 żądanie

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

Żądanie obrazu referencyjnego

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"

Odpowiedź

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

Odzyskaj generację

Użyj identyfikatora zwróconego przez punkt końcowy generacji, aby pobrać zapisany dziennik i obraz URLs. Klucze API mogą odczytywać tylko generacje należące do tego samego użytkownika.

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

Błędy

{
  "error": {
    "message": "Invalid request body",
    "code": "invalid_request"
  }
}
HTTPcodeOpis
400invalid_requestTreść żądania lub parametry są nieprawidłowe.
401missingApiKeyBrak nagłówka Authorization.
401invalidApiKeyKlucz API nie istnieje lub został unieważniony.
401expiredApiKeyKlucz API wygasł.
402insufficientCreditsNa koncie nie ma wystarczającej liczby kredytów.
404notFoundNie znaleziono żądanego zasobu.
500generationFailedWygenerowanie obrazu nie powiodło się.

Limity

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