Config
Shared constants and types of the module: Imagen model catalog, storage and database parameters, default Gemini configuration and the base prompt.
On this page
Source: src/image_generation/utils/config.py. This page's original notebook was empty; the content was written from the code.
#Model catalog
IMAGE_MODELS_CATALOG describes what each Imagen model accepts. It is the source used by Params Validator.
| Model | Max. images per prompt | Aspect ratios | Resolutions | MIME types |
|---|---|---|---|---|
imagen-4.0-generate-001 | 4 | 1:1, 3:4, 4:3, 9:16, 16:9 | 1K, 2K | image/png, image/jpeg |
imagen-4.0-fast-generate-001 | 4 | 1:1, 3:4, 4:3, 9:16, 16:9 | 1K | image/png, image/jpeg |
imagen-4.0-ultra-generate-001 | 4 | 1:1, 3:4, 4:3, 9:16, 16:9 | 1K, 2K | image/png, image/jpeg |
#Storage and database
| Constant | Value | Use |
|---|---|---|
BUCKET_NAME | images | Supabase Storage bucket. |
STORAGE_BASE_PATH | image_generations | Base folder inside the bucket. |
ID_PREFIX | img_ | Prefix of each image identifier. |
BASE_URL | Public URL of the bucket, ending in /image_generations | Base of the URLs returned to the client. |
DATABASE_NAME | GenAI | MongoDB database. |
COLLECTION_NAME | ImageGeneration | MongoDB collection. |
#Default Gemini configuration
DEFAULT_CONTENT_CONFIG is the base that Image Generator Service merges with the configuration sent by the user.
| Key | Default |
|---|---|
model | gemini-2.5-flash-image |
temperature | 0.75 |
top_p | 0.85 |
max_output_tokens | 1024 |
aspect_ratio | 1:1 |
number_of_images | 1 |
Next to max_output_tokens, the code carries the annotation that gemini-2.5-flash-image uses 1024 or 2048 and gemini-3-pro-image-preview uses 4096 or 8192.
#Base prompt
BASE_PROMPT is the text, in English, that opens every prompt sent to Gemini. It defines the agent's role (visual creation and transformation) and the constraints: follow the user's request, apply the style of the reference images, preserve what was not asked to change, not add or remove elements without instruction, and prioritize consistency and quality.
#Helper types
| Type | Description |
|---|---|
GeneratedImage | dataclass with image_bytes and mime_type. It is the internal format of the generation output. |
Ratios | Aspect ratios: R1_1, R3_4, R4_3, R9_16, R16_9. |
Resolutions | Resolutions: K1 (1K) and K2 (2K). |
MimeTypes | PNG (image/png) and JPEG (image/jpeg). |
ModelSpecs | Groups id, max_images, ratios, resolutions and mimes of a model. |
Imagen | Shortcuts for the models: Imagen.GENERATE, Imagen.FAST and Imagen.ULTRA. |
from src.image_generation.utils.config import Imagen
# Access the identifier and the options of a model
model_id = Imagen.GENERATE.id
ratio = Imagen.GENERATE.ratios.R16_9
size = Imagen.GENERATE.resolutions.K2Imagen.FAST defines Resolutions(K2=None), because this model only accepts 1K.
#Intro sentences
IMAGE_INTRO_SENTENCES is a list of 50 short sentences in Portuguese ("Aqui está a imagem conforme solicitado." and variations) to introduce a delivered image.
Source: src/image_generation/utils/config.py