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.
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.
https:/ / api.5abeer.ai/ v1/ images/ generationsTwo endpoints#
POST /v1/images/generationsgenerates an image fromprompt, with a JSON body.POST /v1/images/editsedits the image you send, with amultipart/form-databody that carries the file inimage, and optionally amask.
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"}'{
"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.
modelstringrequiredThe image model id, as in the models list.ClaudeRejectedGPTSupportedGeminiRejectedpromptstringrequiredA description of the image, or of the edit.ClaudeRejectedGPTSupportedGeminiRejectedimagefileEdits only: the source image, as a file in a multipart form.ClaudeRejectedGPTSupportedGeminiRejectedmaskfileEdits only: a transparent mask that marks the area to change.ClaudeRejectedGPTSupportedGeminiRejectedsizestringThe size, such as 1024x1024, 1536x1024 or auto.ClaudeRejectedGPTSupportedGeminiRejectedqualitystringThe quality: low, medium, high or auto.ClaudeRejectedGPTSupportedGeminiRejectednintegerThe number of images, at least 1.ClaudeRejectedGPTSupportedGeminiRejectedbackgroundstringThe background: transparent, opaque or auto.ClaudeRejectedGPTSupportedGeminiRejectedoutput_formatstringThe file format: png, jpeg or webp.ClaudeRejectedGPTSupportedGeminiRejectedoutput_compressionintegerCompression from 0 to 100 with jpeg and webp.ClaudeRejectedGPTSupportedGeminiRejectedmoderationstringThe content filter level: auto or low.ClaudeRejectedGPTSupportedGeminiRejectedExamples#
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"
}'{
"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"
}'{
"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"{
"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#
invalid_request_error: a wrong type, such asnas text, ornbelow 1.not_found_error: the key is not for GPT models.INSUFFICIENT_BALANCE: your balance doesn't cover the image.- A large file in an edit can return
413withREQUEST_TOO_LARGE; see Limits.
Image models#
GPT Image 1Input—Output—Context—
GPT Image 1.5Input—Output—Context—
GPT Image 2Input—Output—Context—
GPT Image 2.5 FlareInput—Output—Context—
GPT Image 2.5 SunburstInput—Output—Context—
Gemini 3.1 Flash Image (Nano Banana 2)Input—Output—Context64K
Official price from the provider's page, checked October 19, 2026.
All models and pricesWas this page helpful?