Image

GPT Image 2 image

OpenAI GPT Image 2 — text-to-image with optional references. Quality low/medium/high; 1K/2K/4K. Returns one image per request.

Category: Create · gpt-image-2

How to use & limits

Capabilities

What this model supports, straight from the schema — no pricing, no infrastructure detail.

CapabilityValue
n_max Max variations per job1
create_image Text-to-imageYes
allowed_quality Quality levelslow, medium, high
reference_images Reference imagesYes
max_prompt_length Max prompt length20000
allowed_resolutions Allowed resolutions1K, 2K, 4K
max_reference_images Max reference images16

Parameters

Fields accepted in params (or first-class, where applicable) for POST /generations.

NameLabelTypeRequiredDefaultOptionsMin / MaxDescription
promptPrompttextareaRequiredImage description, up to 20,000 characters. Required.
qualityQualityselectOptionallowlow · medium · highOutput quality: low, medium or high. Default low.
image_urlsOptional referencesmulti_selectOptionalOptional references to guide generation.
sizeSizeselectOptionalautoauto · 1:1 · 2:3 · 3:2 · 4:3 · 3:4 · 4:5 · 5:4 · 16:9 · 9:16 · 21:9auto or aspect ratio (1:1, 2:3, 3:2, 4:3, 3:4, 4:5, 5:4, 16:9, 9:16, 21:9). Default auto.
resolutionResolutionselectOptional1K1K · 2K · 4KResolution: 1K, 2K or 4K. Default 1K. size=auto forces 1K.
output_formatOutput formatselectOptionalpngjpeg · png · webpFile format: jpeg, png or webp. Default png.
backgroundBackgroundselectOptionalautoauto · transparent · opaqueBackground: auto, transparent or opaque. Default auto.

Example request

bash
curl -X POST https://caranguejo.art/api/v1/dev/generations \
  -H "Authorization: Bearer $CK" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-image-2",
  "prompt": "Premium product photo of a silver espresso machine on a white background.",
  "params": {
    "quality": "high",
    "size": "16:9",
    "resolution": "4K"
  }
}'
javascript
const res = await fetch("https://caranguejo.art/api/v1/dev/generations", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.CK,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "gpt-image-2",
    "prompt": "Premium product photo of a silver espresso machine on a white background.",
    "params": {
      "quality": "high",
      "size": "16:9",
      "resolution": "4K"
    }
  }),
});
const { data } = await res.json();

Example response

json
{
  "id": "9f0c1a7e-…",
  "object": "generation",
  "model": "gpt-image-2",
  "type": "image",
  "status": "completed",
  "output": {
    "assets": [
      {
        "url": "https://media.caranguejo.art/outputs/example.png",
        "type": "image"
      }
    ],
    "images": [
      {
        "url": "https://media.caranguejo.art/outputs/example.png"
      }
    ]
  }
}
The job's real cost is returned as credits_charged on the completed response — check GET /balance for the account balance.

Common errors for this job type:

insufficient_creditsAccount balance can't cover the job cost.
content_policy_violationPrompt or media rejected by content policy.
generation_timeoutThe job exceeded the maximum processing time.
rate_limitedToo many requests per minute.
invalid_inputA required parameter is missing or outside the model's schema.
generation_failedGeneric processing failure.