Table of contents
Official Content
  • This documentation is valid for:

The image API allows you to generate one or more images from a natural language prompt. Depending on the selected provider and model, you can adjust parameters such as size, quality and aspect ratio.

Check the Glob.AI OS API Reference for generic variables needed to use the API.

Endpoint

Method Path Description
POST /images/generations Generates one or more images from a text prompt.
POST /images/edits Edits an image using a prompt.

POST /images/generations

Generates images from a text description using the selected model and rendering settings.

Request

  • Method: POST
  • Path: $BASE_URL/images/generations
  • Headers:
    • Content-Type: application/json
    • Authorization: Bearer $GEAI_APITOKEN
    • response-file-format: Default (no header, returns the uploaded file metadata, including the repository file ID); url (returns the generated file URL stored in the S3 repository); binary (returns the generated file as binary data).

Request Body

{
  "model": "string",         // e.g. "openai/gpt-image-1"
  "prompt": "string",        // Description of the desired image
  "n": integer,              // Number of images to generate (1-10 depending on model)
  "quality": "string",       // Rendering quality, e.g. "high"
  "size": "string",          // Image dimensions, e.g. "1024x1024"
  "aspectRatio": "string"    // Relationship between an image's width and height (1:1, 9:16, 16:9, 3:4, 4:3). Optional.
  "background": "string",    // transparent or opaque
}

Supported Models

The supported models and their accepted parameters are listed in the following table.

Provider Model Supported Parameters Environment support
OpenAI openai/gpt-image-2 prompt
n: 1-10, default to 1
size: '1024x1024', '1024x1536' or '1536x1024'
quality: 'low', 'medium' or 'high'
Beta, Production
OpenAI openai/gpt-image-1.5 prompt
n: 1-10, default to 1
size: '1024x1024', '1024x1536' or '1536x1024'
quality: 'low', 'medium' or 'high'
background: 'transparent' or 'opaque'
Beta, Production
OpenAI openai/gpt-image-1 prompt
n: 1-10, default to 1
size: '1024x1024', '1024x1536' or '1536x1024'
quality: 'low', 'medium' or 'high'
background: 'transparent' or 'opaque'
Beta, Production
OpenAI openai/gpt-image-1-mini prompt
n: 1-10, default to 1
size: '1024x1024', '1024x1536' or '1536x1024'
quality: 'low', 'medium' or 'high'
background: 'transparent' or 'opaque'
Beta, Production
Azure OpenAI azure/gpt-image-1 prompt
n: 1-10, default to 1
size: '1024x1024', '1024x1536' or '1536x1024'
quality: 'low', 'medium' or 'high'
background: 'transparent' or 'opaque'
Beta, Production
Azure OpenAI azure/gpt-image-1-mini prompt
n: 1-10, default to 1
size: '1024x1024', '1024x1536' or '1536x1024'
quality: 'low', 'medium' or 'high'
background: 'transparent' or 'opaque'
Beta, Production
Microsoft Foundry azure_ai_foundry/gpt-image-2 prompt
n: 1-10, default to 1
size: '1024x1024', '1024x1536' or '1536x1024'
quality: 'low', 'medium' or 'high'
Beta, Production
Vertex AI vertex_ai/gemini-3.1-flash-image (Nano Banana 2) prompt
aspectRatio: '1:1', '3:2', '2:3', '3:4', '4:1', '4:3', '4:5', '5:4', '8:1', '9:16', '16:9', '21:9'
n: 1
Beta, Production
Vertex AI vertex_ai/gemini-2.5-flash-image (Nano Banana) prompt
aspectRatio: '1:1', '9:16', '16:9', '3:4', '4:3', '4:5'
Beta, Production
Vertex AI vertex_ai/gemini-3-pro-image (Nano Banana Pro) prompt
aspectRatio: '1:1', '3:2', '2:3', '3:4', '4:3', '4:5', '5:4', '9:16', '16:9', '21:9'
Beta, Production
xAI xai/grok-imagine-image prompt
n: 1-10, default to 1
Beta, Production
Azure AI Foundry azure_ai_foundry/FLUX.2-pro prompt
n: 1
size: '1024x1024', '1024x1536', '1536x1024' or '2048x2048'
aspectRatio: '21:9', '16:9', '4:3', '1:1', '3:4', '9:16', '9:21'
Beta
Azure AI Foundry azure_ai_foundry/FLUX-1.1-pro prompt
n: 1
size: '1024x1024', '1024x1440' or '1440x1024'
aspectRatio: '21:9', '16:9', '4:3', '1:1', '3:4', '9:16', '9:21'
Beta
Azure AI Foundry azure_ai_foundry/FLUX.1-Kontext-pro prompt
n: 1
size: '1024x1024', '1024x1440' or '1440x1024'
aspectRatio: '21:9', '16:9', '4:3', '1:1', '3:4', '9:16', '9:21'
Beta

Response

{
  "created": integer,                     //  Timestamp (seconds)
  "data": 
    {
      "url": "string",              //  usually empty when using b64_json
      "revised_prompt": "string",   // model's revised prompt if available; may be empty
      "b64_json": "string"          //  base64-encoded image data (PNG or model-defined format)
    }
  ,
  "usage": {
    "total_tokens": integer,              //  Total tokens used
    "total_cost": number,                //  Total cost incurred
    "currency": "string",           // e.g., "USD"
    "prompt_tokens_details": "string",  // object|null
    "completion_tokens_details": "string" // object|null
  }
}
{
  "created": integer,            //  Timestamp (seconds)
  "data": 
    { "url": "string" }             // S3 file URL of the edited image
  
}
{
   200 OK - Download File as Binary
}

cURL Sample

curl -X POST "$BASE_URL/images/generations" \
-H "Authorization: Bearer $GEAI_APITOKEN" \
-H 'Content-Type: application/json' \
-d '{
  "model": "openai/gpt-image-1",
  "prompt": "generate a lovely bath basket with attractive items in it",
  "n": 1,
  "quality": "high",
  "size": "1024x1024"
}'
curl -X POST "$BASE_URL/images/generations" \
-H "Authorization: Bearer $GEAI_APITOKEN" \
-H 'Content-Type: application/json' \
-H "response-file-fornat: binary" \
-d '{
  "model": "openai/gpt-image-1",
  "prompt": "generate a lovely bath basket with attractive items in it",
  "n": 1,
  "quality": "high",
  "size": "1024x1024"
}'
curl -X POST "$BASE_URL/images/edits" \
  -H "Authorization: Bearer $GEAI_APITOKEN" \
  -H "Content-Type: application/json" \
  -H "response-file-fornat: binary" \
  -d '{
    "model": "openai/gpt-image-1",
    "prompt": "remove the ball",
    "image": "https://www.reuters.com/resizer/v2/X4XAFRTDTNLN7FCKZQY663TLUQ.jpg?auth=b33090e2931bc7bd4f74df13155afd9fdba9a6a41bea66da0726b9cdf4f24da0&width=960&quality=80",
    "size": "1024x1024",
    "n": 1
  }'

POST /images/edits

Edits a single image using an AI model, based on a user-provided prompt and (optionally) a mask image. Returns edited images as Amazon Simple Storage Service (S3) URLs.

Request

  • Method: POST
  • Path: $BASE_URL/images/edits
  • Headers:
    • Content-Type: application/json
    • Authorization: Bearer $GEAI_APITOKEN
    • response-file-format: Default (no header, returns the uploaded file metadata, including the repository file ID); url (returns the generated file URL stored in the S3 repository); binary (returns the generated file as binary data).

Request Body

{
  "model": "string",      // e.g., "openai/gpt-image-1", "openai/gpt-image-1-mini"
  "prompt": "string",     // e.g., "remove background people"
  "image": "string",      // URL format e.g., "https://example.com/image.jpg"
  "size": "string",       // Image size in pixels e.g., "1024x1024"
  "n": integer            // Number of images to generate (1-10)
}

Supported Models

The supported models and their accepted parameters are listed in the following table.

Provider Model Supported Parameters Environment support
OpenAI openai/gpt-image-1.5 prompt
quality: 'low', 'medium' or 'high'
Beta, Production
OpenAI openai/gpt-image-1 prompt
n: 1-10, default to 1
size: '1024x1024', '1024x1536' or '1536x1024'
quality: 'low', 'medium' or 'high'
Beta, Production
OpenAI openai/gpt-image-1-mini prompt
n: 1-10, default to 1
size: '1024x1024', '1024x1536' or '1536x1024'
quality: 'low', 'medium' or 'high'
Beta, Production
Vertex AI vertex_ai/gemini-2.5-flash-image prompt
aspectRatio: '1:1', '9:16', '16:9', '3:4', '4:3', '4:5'
Beta, Production
Vertex AI vertex_ai/gemini-3-pro-image prompt
aspectRatio: '1:1', '3:2', '2:3', '3:4', '4:3', '4:5', '5:4', '9:16', '16:9', '21:9'
Beta, Production
Azure AI Foundry azure_ai_foundry/FLUX.2-pro prompt
n: 1
size: '1024x1024', '1024x1536', '1536x1024' or '2048x2048'
aspectRatio: '21:9', '16:9', '4:3', '1:1', '3:4', '9:16', '9:21'
Beta

Response

{
  "created": integer,        // Timestamp
  "data": 
    {
      "url": "string",          // URL to the edited image
      "revised_prompt": "string", // (optional) revised prompt
      "b64_json": "string"      // (optional) base64-encoded image data
    }
// Repeats this node for each edited image
  ,
  "usage": {
    "total_tokens": integer,
    "total_cost": integer,
    "currency": "string",       // e.g., "USD"
    "prompt_tokens_details": "string",     // object or null
    "completion_tokens_details": "string" // object or null
  }
}
{
  "created": 1677649800,            // Unix timestamp (seconds)
  "data": 
    { "url": "string" }             // S3 file URL of the edited image
  
}
{
   200 OK - Download File as Binary
}

cURL Sample

curl -X POST "$BASE_URL/images/edits" \
  -H "Authorization: Bearer $GEAI_APITOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-image-1",
    "prompt": "remove the ball",
    "image": "https://www.reuters.com/resizer/v2/X4XAFRTDTNLN7FCKZQY663TLUQ.jpg?auth=b33090e2931bc7bd4f74df13155afd9fdba9a6a41bea66da0726b9cdf4f24da0&width=960&quality=80",
    "size": "1024x1024",
    "n": 1
  }'
curl -X POST "$BASE_URL/images/edits" \
  -H "Authorization: Bearer $GEAI_APITOKEN" \
  -H "Content-Type: application/json" \
  -H "response-file-fornat: url" \
  -d '{
    "model": "openai/gpt-image-1",
    "prompt": "remove the ball",
    "image": "https://www.reuters.com/resizer/v2/X4XAFRTDTNLN7FCKZQY663TLUQ.jpg?auth=b33090e2931bc7bd4f74df13155afd9fdba9a6a41bea66da0726b9cdf4f24da0&width=960&quality=80",
    "size": "1024x1024",
    "n": 1
  }'
curl -X POST "$BASE_URL/images/edits" \
  -H "Authorization: Bearer $GEAI_APITOKEN" \
  -H "Content-Type: application/json" \
  -H "response-file-fornat: binary" \
  -d '{
    "model": "openai/gpt-image-1",
    "prompt": "remove the ball",
    "image": "https://www.reuters.com/resizer/v2/X4XAFRTDTNLN7FCKZQY663TLUQ.jpg?auth=b33090e2931bc7bd4f74df13155afd9fdba9a6a41bea66da0726b9cdf4f24da0&width=960&quality=80",
    "size": "1024x1024",
    "n": 1
  }'

See Also

Last update: 2026 | © Globant S.A. All rights reserved.