Skip to content

Image generation API with the GPT image models

Generate and edit images with the GPT image models in the OpenAI Images format, with every option, examples and errors, and where Gemini images fit.

Updated October 2, 2026
On this page

Generate an image from a description, or edit an image you send. This endpoint serves the GPT image models with a key for GPT models; a Claude or Gemini key gets not_found_error. The Gemini image models generate images through generateContent.

POSThttps://api.5abeer.ai/v1/images/generations

Two endpoints#

  • POST /v1/images/generations generates an image from prompt, with a JSON body.
  • POST /v1/images/edits edits the image you send, with a multipart/form-data body that carries the file in image, and optionally a mask.

Both answer with data, a list of images as Base64 in b64_json. Decode it and save it as a file in the format you chose in output_format.

Authentication#

Send your key in the Authorization header as Bearer followed by the key, with the OpenAI-compatible base URL. The OpenAI libraries call these endpoints with client.images.generate and client.images.edit.

Quick example#

curl --request POST "https://api.5abeer.ai/v1/images/generations" \
  --header "Authorization: Bearer $KHABEER_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"model":"gpt-image-1","prompt":"Write a product idea in one sentence.","size":"1024x1024","quality":"medium"}'
Response
{
  "created": 1759400000,
  "data": [
    {
      "b64_json": "iVBORw0KGgo…"
    }
  ]
}

The key is read from KHABEER_API_KEY, so it never appears in your code.

Parameters#

Supported means we pass it to the image model; rejected means the request fails, here because the key is for another provider.

ParameterDescriptionClaudeGPTGemini
modelstringrequiredThe image model id, as in the models list.ClaudeRejectedGPTSupportedGeminiRejected
promptstringrequiredA description of the image, or of the edit.ClaudeRejectedGPTSupportedGeminiRejected
imagefileEdits only: the source image, as a file in a multipart form.ClaudeRejectedGPTSupportedGeminiRejected
maskfileEdits only: a transparent mask that marks the area to change.ClaudeRejectedGPTSupportedGeminiRejected
sizestringThe size, such as 1024x1024, 1536x1024 or auto.ClaudeRejectedGPTSupportedGeminiRejected
qualitystringThe quality: low, medium, high or auto.ClaudeRejectedGPTSupportedGeminiRejected
nintegerThe number of images, at least 1.ClaudeRejectedGPTSupportedGeminiRejected
backgroundstringThe background: transparent, opaque or auto.ClaudeRejectedGPTSupportedGeminiRejected
output_formatstringThe file format: png, jpeg or webp.ClaudeRejectedGPTSupportedGeminiRejected
output_compressionintegerCompression from 0 to 100 with jpeg and webp.ClaudeRejectedGPTSupportedGeminiRejected
moderationstringThe content filter level: auto or low.ClaudeRejectedGPTSupportedGeminiRejected

Examples#

Generating an image#

curl https://api.5abeer.ai/v1/images/generations \
  -H "Authorization: Bearer $KHABEER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A minimal orange logo for a note-taking app.",
    "size": "1024x1024",
    "quality": "medium"
  }'
Response shape
{
  "created": 1790000000,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
    }
  ],
  "usage": {
    "input_tokens": 14,
    "output_tokens": 272,
    "total_tokens": 286
  }
}

Transparent background and file format#

curl https://api.5abeer.ai/v1/images/generations \
  -H "Authorization: Bearer $KHABEER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A minimal orange logo for a note-taking app.",
    "size": "1024x1024",
    "quality": "high",
    "n": 1,
    "background": "transparent",
    "output_format": "webp",
    "output_compression": 80,
    "moderation": "auto"
  }'
Response shape
{
  "created": 1790000000,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
    }
  ],
  "usage": {
    "input_tokens": 14,
    "output_tokens": 272,
    "total_tokens": 286
  }
}

Editing an image#

curl https://api.5abeer.ai/v1/images/edits \
  -H "Authorization: Bearer $KHABEER_API_KEY" \
  -F "model=gpt-image-2" \
  -F "prompt=Make the background light blue." \
  -F "image=@logo.png" \
  -F "mask=@mask.png" \
  -F "size=1024x1024"
Response shape
{
  "created": 1790000000,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
    }
  ],
  "usage": {
    "input_tokens": 14,
    "output_tokens": 272,
    "total_tokens": 286
  }
}

The request above was run on the local test stack on 2026-10-02; the reply shows the shape, and its text is an example.

Errors#

Image models#

per 1M tokens

Official price from the provider's page, checked October 19, 2026.

All models and prices