Skip to content

Application Environment Variables Explainer

This document details the environment variables used in the application, as defined in config/default.py. These variables control infrastructure settings, model versions, storage locations, and feature configurations.

Quick Start: A dotenv.template file is provided in the root directory. To set up your local environment, copy this file to .env and populate the values:

Terminal window
cp dotenv.template .env

These variables define the fundamental operating context of the application.

VariableDefaultDescription
PROJECT_IDNone (Required)The Google Cloud Project ID where resources (Vertex AI, Firestore, Storage) are located.
LOCATIONus-central1The default GCP region for most services (Vertex AI, etc.).
APP_ENV"" (Empty)Defines the environment name (e.g., dev, godemos). This is used as a metadata tag on the Config page.
GMCS_OVERRIDE_PATHNone(Development Only) An absolute path to a directory containing configuration overrides. If a file exists in this path (e.g., config/about_content.json), the app will prioritize it over the local version.
API_BASE_URLhttp://localhost:{PORT}The base URL for the application’s backend APIs.
PORT8080The port the application server listens on.
SERVICE_ACCOUNT_EMAILNoneThe email of the service account used for authentication, if applicable.
GA_MEASUREMENT_IDNoneGoogle Analytics Measurement ID for tracking user interactions.

Controls which versions of the Gemini models are used for various tasks.

VariableDefaultDescription
MODEL_IDgemini-2.5-flashThe primary Gemini model used for general text and reasoning tasks throughout the app.
GEMINI_IMAGE_GEN_MODELgemini-2.5-flash-imageThe specific model used for image generation features.
GEMINI_IMAGE_GEN_LOCATIONglobalThe region for the Gemini Image Generation API.
GEMINI_AUDIO_ANALYSIS_MODEL_IDgemini-2.5-flashThe model used specifically for analyzing audio content.
GEMINI_WRITERS_WORKSHOP_MODEL_IDMODEL_IDThe model used for the Gemini Writers Workshop page. Defaults to MODEL_ID.
GEMINI_CRITIQUE_MODEL_IDgemini-3-flash-previewThe specific model used for the Imagen critique functionality.
GEMINI_CRITIQUE_LOCATIONglobalThe region for the Gemini image critique model.
CHARACTER_CONSISTENCY_GEMINI_MODELMODEL_IDThe model used for Character Consistency tasks.
CHARACTER_CONSISTENCY_GEMINI_LOCATIONglobalThe region for the Character Consistency Gemini model.

Configuration for the Veo video generation models.

VariableDefaultDescription
DEFAULT_VEO_MODEL_NAMEveo-3.1-fast-generate-001The fallback model name for the UI when a user clears their session or deep links.
VEO_LOCATIONus-central1Region for GA Veo API calls.
PREVIEW_LOCATIONglobalRegion for Preview Veo API calls (models with “preview” in their name).
VEO_MODEL_IDveo-3.1-fast-generate-001The standard Veo model version.
VEO_PROJECT_IDPROJECT_IDAllows using a different project for Veo quota if needed.
VEO_EXP_MODEL_IDveo-3.1-generate-001The experimental/newer Veo model version.
VEO_EXP_FAST_MODEL_IDveo-3.1-fast-generate-001The faster, lower-latency experimental Veo model.
VEO_EXP_PROJECT_IDPROJECT_IDProject ID for experimental Veo models.

Settings for Imagen models, including specialized versions for editing and product shots.

VariableDefaultDescription
IMAGEN_GENERATED_SUBFOLDERgenerated_imagesSubfolder in the GCS bucket where generated images are saved.
IMAGEN_EDITED_SUBFOLDERedited_imagesSubfolder for images resulting from editing operations.

Specific configuration for the Virtual Try-On feature.

VariableDefaultDescription
VTO_LOCATIONus-central1Region for the VTO API.
VTO_MODEL_IDvirtual-try-on-001The specific VTO model version.
GENMEDIA_VTO_MODEL_COLLECTION_NAMEgenmedia-vto-modelFirestore collection for VTO model data.
GENMEDIA_VTO_CATALOG_COLLECTION_NAMEgenmedia-vto-catalogFirestore collection for VTO product catalog data.

Configuration for the Lyria music generation model.

VariableDefaultDescription
LYRIA_LOCATIONus-central1Region for Lyria API calls.
LYRIA_MODEL_VERSIONlyria-002The version of the Lyria model to use.
LYRIA_PROJECT_IDPROJECT_IDProject ID for Lyria quota.

Defines where data and media assets are stored.

VariableDefaultDescription
GENMEDIA_FIREBASE_DB(default)The Firestore database ID.
GENMEDIA_COLLECTION_NAMEgenmediaThe main Firestore collection for storing generation metadata.
SESSIONS_COLLECTION_NAMEsessionsFirestore collection for user session data.
GENMEDIA_BUCKET{PROJECT_ID}-assetsThe primary GCS bucket for storing generated media.
VIDEO_BUCKET{PROJECT_ID}-assets/videosSpecific bucket/path for video files.
IMAGE_BUCKET{PROJECT_ID}-assets/imagesSpecific bucket/path for image files.
MEDIA_BUCKET{PROJECT_ID}-assetsUsed by Lyria and potentially other legacy components.
GCS_ASSETS_BUCKETNoneBucket for static assets used in the “About” page.
VariableDefaultDescription
LIBRARY_MEDIA_PER_PAGE15Controls how many items appear per page in the media library.
USE_MEDIA_PROXYtrueIf true, media URLs are proxied to avoid CORS/hotlinking issues.

The application can display detailed build information on the Config page. This is populated from an optional JSON file:

  • File Path: config/build.json (or via GMCS_OVERRIDE_PATH)
  • Format:
    {
    "commit": "a1b2c3d",
    "date": "2026-01-13 14:30:00"
    }
  • If present, these values populate the BUILD_COMMIT and BUILD_DATE fields in the application state.

🏗️ Terraform Configuration & Deployment

Section titled “🏗️ Terraform Configuration & Deployment”

When deploying this application using Terraform (via main.tf), not all environment variables are exposed for configuration. The Terraform setup manages a specific subset of variables, primarily those related to infrastructure and core model IDs.

1. Variables Controllable via variables.tf

Section titled “1. Variables Controllable via variables.tf”

These variables are exposed in variables.tf and directly map to environment variables in the Cloud Run service. You can customize these by setting the corresponding Terraform variable during deployment.

Terraform VariableMaps to App Env VarDefault in Terraform
project_idPROJECT_ID(Required)
regionLOCATIONus-central1
model_idMODEL_IDgemini-2.5-flash
gemini_critique_model_idGEMINI_CRITIQUE_MODEL_IDgemini-3-flash-preview
gemini_critique_locationGEMINI_CRITIQUE_LOCATIONglobal
character_consistency_gemini_locationCHARACTER_CONSISTENCY_GEMINI_LOCATIONglobal
veo_model_idVEO_MODEL_IDveo-3.1-fast-generate-001
veo_exp_model_idVEO_EXP_MODEL_IDveo-3.1-generate-001
lyria_model_idLYRIA_MODEL_VERSIONlyria-002
edit_images_enabledEDIT_IMAGES_ENABLEDtrue

2. Variables Automatically Managed by Terraform

Section titled “2. Variables Automatically Managed by Terraform”

These variables are computed within main.tf based on the resources Terraform creates (e.g., bucket names, service account emails). You generally cannot change these via variables.tf as they ensure the application correctly connects to the provisioned infrastructure.

App Env VarSource in main.tfValue Logic
GENMEDIA_BUCKETlocal.asset_bucket_namecreative-studio-{project_id}-assets
VIDEO_BUCKETlocal.asset_bucket_nameSame as above
MEDIA_BUCKETlocal.asset_bucket_nameSame as above
IMAGE_BUCKETlocal.asset_bucket_nameSame as above
GCS_ASSETS_BUCKETlocal.asset_bucket_nameSame as above
GENMEDIA_FIREBASE_DBResource AttributeName of the created Firestore DB
SERVICE_ACCOUNT_EMAILResource AttributeEmail of the created Service Account
LYRIA_PROJECT_IDvar.project_idForces Lyria to use the main project ID

3. Variables NOT Set by Terraform (Using Python Defaults)

Section titled “3. Variables NOT Set by Terraform (Using Python Defaults)”

The following variables are not explicitly set in the main.tf configuration. This means the application will use the default values defined in config/default.py when deployed via Terraform.

  • Gemini Models: GEMINI_IMAGE_GEN_MODEL, GEMINI_IMAGE_GEN_LOCATION, GEMINI_AUDIO_ANALYSIS_MODEL_ID
  • Veo: DEFAULT_VEO_MODEL_NAME, VEO_LOCATION, PREVIEW_LOCATION, VEO_PROJECT_ID, VEO_EXP_FAST_MODEL_ID, VEO_EXP_PROJECT_ID
  • VTO (Virtual Try-On): VTO_LOCATION, VTO_MODEL_ID, GENMEDIA_VTO_* collection names.
  • Imagen: MODEL_IMAGEN_PRODUCT_RECONTEXT, IMAGEN_GENERATED_SUBFOLDER, IMAGEN_EDITED_SUBFOLDER
  • App Logic: APP_ENV, API_BASE_URL, GA_MEASUREMENT_ID, LIBRARY_MEDIA_PER_PAGE, USE_MEDIA_PROXY
  • Collections: GENMEDIA_COLLECTION_NAME, SESSIONS_COLLECTION_NAME

To change a variable from Group 3 (e.g., GEMINI_IMAGE_GEN_MODEL) when deploying with Terraform:

  1. Modify variables.tf: Add a new variable definition.
    variable "gemini_image_model" {
    description = "Model ID for Gemini Image Generation"
    type = string
    default = "gemini-3-pro-image-preview"
    }
  2. Modify main.tf: Update the locals block to include the new environment variable mapping.
    locals {
    creative_studio_env_vars = {
    # ... existing vars ...
    GEMINI_IMAGE_GEN_MODEL = var.gemini_image_model
    }
    }