A Python-based file generator script that creates videos and images via Gemini API using Google's Veo3, Veo2, and Imagen 3 and 4 models.
gemini_generator.py: The main script for generating files.
The Gemini Generator creates videos and images using Google's Veo and Imagen models. You must specify either --video or --image to indicate the content type you want to generate.
The generator requires a prompt. This can be provided via stdin, setting the -p value, or both.
-p, --prompt(optional): Text prompt describing what you want to generate. Can be combined with stdin content.--videoor--image(required): Choose content type - mutually exclusive flags-i, --image_path(optional): Path to input image file for image-to-video generation-np, --negative_prompt(optional): What you don't want in the output (default includes text overlays, watermarks, etc.)-m, --model(optional): Generation model to use:- Video models:
veo3gp,veo3fgp(default),veo2 - Image models:
imagen-4.0-generate-preview-06-06,imagen-4.0-ultra-generate-preview-06-06,imagen-3.0-generate-002
- Video models:
-o, --output_filename(optional): Custom filename without extension-d, --destination_directory(optional): Output directory (default:./generated)--dimension(optional): Aspect ratio -16:9/landscape(default) or9:16/portrait(Veo2 only)-n, --num(optional): Number of outputs to generate (1-4 for images, 1-2 for Veo2 videos, 1 for other video models)
Generate a video:
python gemini_generator.py --video -p "A serene sunset over a mountain lake with gentle ripples"Generate an image:
python gemini_generator.py --image -p "A futuristic cityscape at night with neon lights"Generate video with custom settings:
python gemini_generator.py --video -p "A cat playing in a garden" -m veo2 --dimension portrait -n 2 -o my_cat_videoGenerate image-to-video:
python gemini_generator.py --video -p "Make this image come alive with gentle movement" -i path/to/image.jpgUse clipboard content as prompt (macOS):
python gemini_generator.py --video -p "$(pbpaste)"Read prompt from stdin:
echo "A serene sunset over a mountain lake" | python gemini_generator.py --videoCombine stdin and -p prompt:
echo "Base scene: A peaceful forest" | python gemini_generator.py --video -p "with gentle morning mist"Pipe from file:
cat my_prompt.txt | python gemini_generator.py --imageFor detailed help and all available options:
python gemini_generator.py --help- Python 3.x
uv(install withpip install uvorbrew install uv)
- Create a virtual environment and install dependencies using
uv:uv venv uv pip install -e . - Activate the virtual environment:
source .venv/bin/activate
Before using the Gemini Generator, you need to set up your Google Gemini API key:
-
Get your Gemini API key:
- Go to Google AI Studio
- Sign in with your Google account
- Click "Create API Key" to generate a new key
- Copy the generated API key
-
Create a
.envfile in the project root:touch .env
-
Add your API key to the
.envfile:GEMINI_API_KEY=your_api_key_here DEFAULT_GENERATED_DIR=./generatedReplace
your_api_key_herewith the actual API key you obtained from Google AI Studio.The
DEFAULT_GENERATED_DIRvariable sets the default directory for generated files. If not specified, it defaults to./generated.
Note: The .env file is already included in .gitignore to prevent accidentally committing your API key to version control.
(If tests are implemented, instructions would go here)
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature-name). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/your-feature-name). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE.md file for details.