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

Autorizações

Authorization
string
header
obrigatório

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

Corpo

prompt
string
obrigatório

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

Required string length: 1 - 4000
Exemplo:

"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
padrão:internal

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

Exemplo:

"internal"

response_format
enum<string>
padrão:url

The format of the response images

Opções disponíveis:
url,
b64_json
Exemplo:

"url"

size
string
padrão:1024x1024

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

Exemplo:

"1024x1024"

n
integer
padrão:1

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

Intervalo necessário: 1 <= x <= 4
Exemplo:

1

Resposta

Images generated successfully

success
boolean
Exemplo:

true

id
string

Unique request identifier

Exemplo:

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

object
string
Exemplo:

"image.generation"

created
integer

Unix timestamp of when the images were created

Exemplo:

1705312200

data
object[]

Array of generated images

metadata
object