.env file in the project root — the server loads it automatically via python-dotenv.
Required
Your Google AI API key. Used for all Gemini calls: product identification, video analysis, and frame editing. Get one at aistudio.google.com.
AI models
Gemini model used for text tasks, including product identification via
/api/identify-product and /api/personalize-prompt.Gemini model used for video scene analysis in
/api/analyze-video. This model receives the uploaded video file and returns a scene breakdown with placement instructions.Comma-separated list of Gemini image models to try for frame editing, in priority order. The server attempts each model in turn and uses the first successful response.
Voice and audio
ElevenLabs API key for voiceover generation. If not set, you must set
ALLOW_SILENT_VOICEOVER=1 or voiceover steps will fail.ElevenLabs voice ID to use when no voice clone reference is available. Defaults to the ElevenLabs “Rachel” voice.
Path to a video or audio file used as the source for ElevenLabs Instant Voice Cloning. If the file exists, the server clones the voice from it before generating the voiceover line. Relative paths are resolved from the project root.
Set to
1, true, or yes to skip voiceover generation entirely and produce a silent ad segment. Useful for development or when no ElevenLabs key is available.Video processing
Maximum allowed size (in megabytes) for video files uploaded to
/api/analyze-video. Requests exceeding this limit are rejected with a 413 response.Duration (in seconds) of the ad segment that replaces the selected window in the original video. The frame edit and voiceover are both fitted to this length.
Fractional position within the selected ad window at which the representative frame is extracted for image editing.
0.2 means 20% into the segment.How long (in seconds) processed video files are cached before being eligible for eviction. Defaults to 30 minutes.
Server
TCP port the Uvicorn server listens on. You can also override this by setting the variable before calling
python run.py:Sample .env file
The following covers the most common configuration for a full setup with ElevenLabs voiceover enabled:.env