Image Generation / Utils

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.

    ModelMax. images per promptAspect ratiosResolutionsMIME types
    imagen-4.0-generate-00141:1, 3:4, 4:3, 9:16, 16:91K, 2Kimage/png, image/jpeg
    imagen-4.0-fast-generate-00141:1, 3:4, 4:3, 9:16, 16:91Kimage/png, image/jpeg
    imagen-4.0-ultra-generate-00141:1, 3:4, 4:3, 9:16, 16:91K, 2Kimage/png, image/jpeg

    #Storage and database

    ConstantValueUse
    BUCKET_NAMEimagesSupabase Storage bucket.
    STORAGE_BASE_PATHimage_generationsBase folder inside the bucket.
    ID_PREFIXimg_Prefix of each image identifier.
    BASE_URLPublic URL of the bucket, ending in /image_generationsBase of the URLs returned to the client.
    DATABASE_NAMEGenAIMongoDB database.
    COLLECTION_NAMEImageGenerationMongoDB collection.

    #Default Gemini configuration

    DEFAULT_CONTENT_CONFIG is the base that Image Generator Service merges with the configuration sent by the user.

    KeyDefault
    modelgemini-2.5-flash-image
    temperature0.75
    top_p0.85
    max_output_tokens1024
    aspect_ratio1:1
    number_of_images1

    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

    TypeDescription
    GeneratedImagedataclass with image_bytes and mime_type. It is the internal format of the generation output.
    RatiosAspect ratios: R1_1, R3_4, R4_3, R9_16, R16_9.
    ResolutionsResolutions: K1 (1K) and K2 (2K).
    MimeTypesPNG (image/png) and JPEG (image/jpeg).
    ModelSpecsGroups id, max_images, ratios, resolutions and mimes of a model.
    ImagenShortcuts 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.K2

    Imagen.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

    Esc
    ↑↓navigate Enteropen