Skip to main content
POST
Generate or Edit Images

Generate Images

Generate new images from text prompts or transform existing images using Google Gemini 2.5 Flash Image.

Endpoint

Description

Generate new images from text descriptions or transform existing images. This endpoint supports:
  • Text-to-Image: Generate images from text descriptions
  • Image-to-Image: Transform or edit existing images (upload an image file)
All prompts and responses are automatically processed through SMLTP for audit logging and compliance.

Authentication

Required: API Key

Request Body

This endpoint accepts both multipart/form-data (for file uploads) and application/json formats.

Parameters

Request Examples

Text-to-Image (JSON)

Image-to-Image (Multipart Form Data)

JavaScript/Node.js

Python

Response

Success Response (200)

Response Fields

Image Object

Metadata Object

Error Responses

400 Bad Request

401 Unauthorized

403 Forbidden

413 Payload Too Large

500 Internal Server Error

503 Service Unavailable

Notes

  • Supported image formats for upload: JPEG, PNG, WEBP, GIF
  • Maximum file size: 10MB per image
  • When uploading an image, the prompt describes how to transform it
  • Gemini typically generates 1-4 images per request
  • All requests are processed through SMLTP for security and compliance
  • Use response_format: "b64_json" to receive base64-encoded image data instead of URLs

Autorizaciones

Authorization
string
header
requerido

API key authentication using Bearer token format. Example: Authorization: Bearer sk-your-api-key-here

Cuerpo

prompt
string
requerido

The text prompt describing the image to generate or how to transform the uploaded image

Required string length: 1 - 4000
Ejemplo:

"A beautiful sunset over the ocean with mountains in the background, digital art style"

image
file

Optional image file for image-to-image generation (JPEG, PNG, WEBP, or GIF, max 10MB)

smltp_policy
string
predeterminado:internal

SMLTP security policy to apply (e.g., 'internal', 'public', 'confidential', 'hipaa', 'gdpr')

Ejemplo:

"internal"

response_format
enum<string>
predeterminado:url

The format of the response images

Opciones disponibles:
url,
b64_json
Ejemplo:

"url"

size
string
predeterminado:1024x1024

The size of the generated images (for future use, currently uses default size)

Ejemplo:

"1024x1024"

n
integer
predeterminado:1

Number of images to generate (Gemini typically generates 1-4 images)

Rango requerido: 1 <= x <= 4
Ejemplo:

1

Respuesta

Images generated successfully

success
boolean
Ejemplo:

true

id
string

Unique request identifier

Ejemplo:

"90d3756f-41c3-4f86-a18d-e257bfbc33a3"

object
string
Ejemplo:

"image.generation"

created
integer

Unix timestamp of when the images were created

Ejemplo:

1705312200

data
object[]

Array of generated images

metadata
object