Imagen Skill Reference
Setup
1. Get a Gemini API Key
- Go to Google AI Studio
- Click "Get API Key"
- Create a new API key or use an existing one
2. Set Environment Variable
Windows (PowerShell):
$env:GEMINI_API_KEY = "your-api-key-here"
# To persist across sessions, add to your PowerShell profile:
Add-Content $PROFILE "`n`$env:GEMINI_API_KEY = 'your-api-key-here'"
Windows (CMD):
set GEMINI_API_KEY=your-api-key-here
# To persist, use System Properties > Environment Variables
macOS/Linux:
export GEMINI_API_KEY="your-api-key-here"
# Add to ~/.zshrc or ~/.bashrc to persist
echo 'export GEMINI_API_KEY="your-api-key-here"' >> ~/.zshrc
API Reference
Model
- Model ID:
gemini-3-pro-image-preview (configurable via --model flag or GEMINI_MODEL env var)
- Endpoint:
https://generativelanguage.googleapis.com/v1beta/models/{model}:streamGenerateContent
Image Sizes
| Size |
Description |
512 |
512x512 pixels - Fast, good for icons/thumbnails |
1K |
1024x1024 pixels - Default, balanced quality/speed |
2K |
2048x2048 pixels - High resolution, slower |
Script Parameters
Python Script (Cross-Platform)
python scripts/generate_image.py <prompt> [output_path] [--size SIZE]
| Parameter |
Required |
Default |
Description |
prompt |
Yes |
- |
Text description of desired image |
output_path |
No |
./generated-image.png |
Where to save the image |
--size |
No |
1K |
Image size (512, 1K, or 2K) |
Environment Variables
| Variable |
Required |
Default |
Description |
GEMINI_API_KEY |
Yes |
- |
Your Google Gemini API key |
IMAGE_SIZE |
No |
1K |
Image size (512, 1K, or 2K) |
Usage Examples
Basic Generation
python scripts/generate_image.py "A serene mountain landscape at dawn"
Custom Output Path
python scripts/generate_image.py "Minimalist logo design" "./assets/logo.png"
High Resolution
python scripts/generate_image.py --size 2K "Detailed portrait" "./high-res.png"
Small/Fast Generation
python scripts/generate_image.py --size 512 "Simple icon" "./icon.png"
Prompt Tips
For Best Results
- Be specific: "A red sports car" vs "A cherry red 1967 Mustang convertible"
- Include style: "in watercolor style", "photorealistic", "minimalist flat design"
- Mention lighting: "golden hour lighting", "soft diffused light", "dramatic shadows"
- Specify composition: "close-up", "wide angle", "from above", "centered"
Advanced Prompting Techniques
These techniques produce significantly better results for photorealistic and professional imagery:
Camera & Lens Specifications
Include specific photography parameters for authentic looks:
- Lens focal length: "85mm f/1.4 lens", "50mm prime", "35mm wide angle"
- Aperture: "shallow depth of field at f/1.8", "deep focus at f/8"
- Camera angle: "eye-level shot", "low angle looking up", "3/4 profile view"
Example: "Portrait shot with 85mm f/1.4 lens, shallow depth of field, subject sharp against soft bokeh background"
Lighting Architecture
Specify complete lighting setups for professional results:
- Three-point lighting: key light, fill light, rim/back light
- Catchlights: reflections in eyes for portraits
- Shadow quality: "soft shadows", "dramatic hard shadows", "subtle rim light"
Example: "Professional headshot with three-point lighting setup, soft key light from left, subtle fill light, rim light for hair separation, visible catchlights in eyes"
Film Stock & Era Aesthetics
Reference specific film stocks or eras for authentic period looks:
- Film stocks: "Kodak Portra 400 color palette", "Fujifilm Pro 400H tones", "Kodak Tri-X grain"
- Era aesthetics: "1990s disposable camera quality", "early-2000s digital camera look", "1970s Polaroid style"
- Grain and texture: "subtle film grain", "realistic sensor noise"
Example: "Casual portrait with Kodak Portra 400 color tones, natural film grain, 1990s aesthetic, soft warm highlights"
Facial Consistency (for portraits/people)
When generating or editing images with faces, explicitly state preservation requirements:
"Keep the facial features exactly consistent"
"Preserve original face structure and proportions"
"Do not alter or change the face"
Material & Texture Details
Add realistic texture specifications:
- Skin: "natural skin texture with visible pores", "subtle skin imperfections"
- Fabric: "fine wool texture visible", "silk sheen and drape"
- Surfaces: "brushed metal finish", "weathered wood grain"
Example: "Close-up portrait showing natural skin texture with visible pores, fine fabric detail on collar, realistic hair strands"
Composition Framing
Be precise about framing and subject positioning:
- Shot types: "chest-up framing", "3/4 body shot", "full body"
- Positioning: "centered subject", "rule of thirds placement", "mirror selfie angle"
- Aspect ratio context: "portrait orientation", "landscape format", "square crop"
Example Prompts by Use Case
UI/Frontend:
- "A modern dashboard UI mockup with dark theme, showing analytics charts"
- "Clean minimalist app icon for a task management app, rounded square shape"
- "Hero image for a SaaS landing page, abstract gradient with geometric shapes"
Documentation:
- "Simple architecture diagram showing microservices connected by arrows"
- "Flowchart illustrating user authentication process"
Placeholders:
- "Professional headshot placeholder, silhouette style, neutral gray background"
- "Product image placeholder, simple box shape with 'Image Coming Soon' text"
Marketing/Creative:
- "Isometric illustration of a modern office workspace"
- "Gradient abstract background suitable for presentation slides"
Professional Portraits (using advanced techniques):
- "Corporate headshot, 85mm f/2.8 lens, three-point studio lighting, navy blue suit, neutral gray backdrop, subtle catchlights, chest-up framing, natural skin texture"
- "Casual lifestyle portrait, Kodak Portra 400 tones, natural window light, soft shadows, 3/4 body shot, authentic film grain, early-2000s digital aesthetic"
E-commerce & Product Photography:
- "Product photo of leather watch, 100mm macro lens, soft diffused lighting, visible leather texture and stitching, clean white background, subtle reflection"
- "Fashion flat-lay, overhead shot, soft natural lighting, fabric texture visible, minimalist composition"
Troubleshooting
"GEMINI_API_KEY not set"
Ensure the environment variable is set in your current shell:
Windows (PowerShell):
echo $env:GEMINI_API_KEY # Should show your key
macOS/Linux:
echo $GEMINI_API_KEY # Should show your key
"API request failed with HTTP status 400"
- Check your prompt for special characters that may break JSON
- Ensure the prompt isn't empty
- Verify API key is valid
"API request failed with HTTP status 429"
- Rate limited - wait a moment and retry
- Consider upgrading your API quota
"No image data found in response"
- The model may have refused the prompt (content policy)
- Try rephrasing the prompt
- Check if the model returned an error message in the response
Image is corrupted/won't open
- Ensure Python 3.6+ is installed
- Check if the full response was received (network issues)
- Verify output path is writable
Windows-specific issues
- Make sure Python is in your PATH
- Use forward slashes or escaped backslashes in paths
API Costs
Check Google AI pricing for current Gemini API costs. Image generation typically costs more than text generation.
Limitations
- Maximum prompt length varies by model
- Some content types may be restricted by Google's content policy
- Generated images are subject to Google's terms of service
- Rate limits apply based on your API tier
1---2name: imagen-skill-reference3description: Example: "Professional headshot with three-point lighting setup, soft key light from left, subtle fill light, rim light for hair separation, visible catchlights in eyes"4---5# Imagen Skill Reference67## Setup89### 1. Get a Gemini API Key10111. Go to [Google AI Studio](https://aistudio.google.com/)122. Click "Get API Key"133. Create a new API key or use an existing one1415### 2. Set Environment Variable1617**Windows (PowerShell):**18```powershell19$env:GEMINI_API_KEY = "your-api-key-here"2021# To persist across sessions, add to your PowerShell profile:22Add-Content $PROFILE "`n`$env:GEMINI_API_KEY = 'your-api-key-here'"23```2425**Windows (CMD):**26```cmd27set GEMINI_API_KEY=your-api-key-here2829# To persist, use System Properties > Environment Variables30```3132**macOS/Linux:**33```bash34export GEMINI_API_KEY="your-api-key-here"3536# Add to ~/.zshrc or ~/.bashrc to persist37echo 'export GEMINI_API_KEY="your-api-key-here"' >> ~/.zshrc38```3940## API Reference4142### Model4344- **Model ID**: `gemini-3-pro-image-preview` (configurable via `--model` flag or `GEMINI_MODEL` env var)45- **Endpoint**: `https://generativelanguage.googleapis.com/v1beta/models/{model}:streamGenerateContent`4647### Image Sizes4849| Size | Description |50|------|-------------|51| `512` | 512x512 pixels - Fast, good for icons/thumbnails |52| `1K` | 1024x1024 pixels - Default, balanced quality/speed |53| `2K` | 2048x2048 pixels - High resolution, slower |5455## Script Parameters5657### Python Script (Cross-Platform)5859```bash60python scripts/generate_image.py <prompt> [output_path] [--size SIZE]61```6263| Parameter | Required | Default | Description |64|-----------|----------|---------|-------------|65| `prompt` | Yes | - | Text description of desired image |66| `output_path` | No | `./generated-image.png` | Where to save the image |67| `--size` | No | `1K` | Image size (512, 1K, or 2K) |6869### Environment Variables7071| Variable | Required | Default | Description |72|----------|----------|---------|-------------|73| `GEMINI_API_KEY` | Yes | - | Your Google Gemini API key |74| `IMAGE_SIZE` | No | `1K` | Image size (512, 1K, or 2K) |7576## Usage Examples7778### Basic Generation7980```bash81python scripts/generate_image.py "A serene mountain landscape at dawn"82```8384### Custom Output Path8586```bash87python scripts/generate_image.py "Minimalist logo design" "./assets/logo.png"88```8990### High Resolution9192```bash93python scripts/generate_image.py --size 2K "Detailed portrait" "./high-res.png"94```9596### Small/Fast Generation9798```bash99python scripts/generate_image.py --size 512 "Simple icon" "./icon.png"100```101102## Prompt Tips103104### For Best Results1051061. **Be specific**: "A red sports car" vs "A cherry red 1967 Mustang convertible"1072. **Include style**: "in watercolor style", "photorealistic", "minimalist flat design"1083. **Mention lighting**: "golden hour lighting", "soft diffused light", "dramatic shadows"1094. **Specify composition**: "close-up", "wide angle", "from above", "centered"110111### Advanced Prompting Techniques112113These techniques produce significantly better results for photorealistic and professional imagery:114115#### Camera & Lens Specifications116Include specific photography parameters for authentic looks:117- **Lens focal length**: "85mm f/1.4 lens", "50mm prime", "35mm wide angle"118- **Aperture**: "shallow depth of field at f/1.8", "deep focus at f/8"119- **Camera angle**: "eye-level shot", "low angle looking up", "3/4 profile view"120121Example: `"Portrait shot with 85mm f/1.4 lens, shallow depth of field, subject sharp against soft bokeh background"`122123#### Lighting Architecture124Specify complete lighting setups for professional results:125- **Three-point lighting**: key light, fill light, rim/back light126- **Catchlights**: reflections in eyes for portraits127- **Shadow quality**: "soft shadows", "dramatic hard shadows", "subtle rim light"128129Example: `"Professional headshot with three-point lighting setup, soft key light from left, subtle fill light, rim light for hair separation, visible catchlights in eyes"`130131#### Film Stock & Era Aesthetics132Reference specific film stocks or eras for authentic period looks:133- **Film stocks**: "Kodak Portra 400 color palette", "Fujifilm Pro 400H tones", "Kodak Tri-X grain"134- **Era aesthetics**: "1990s disposable camera quality", "early-2000s digital camera look", "1970s Polaroid style"135- **Grain and texture**: "subtle film grain", "realistic sensor noise"136137Example: `"Casual portrait with Kodak Portra 400 color tones, natural film grain, 1990s aesthetic, soft warm highlights"`138139#### Facial Consistency (for portraits/people)140When generating or editing images with faces, explicitly state preservation requirements:141- `"Keep the facial features exactly consistent"`142- `"Preserve original face structure and proportions"`143- `"Do not alter or change the face"`144145#### Material & Texture Details146Add realistic texture specifications:147- **Skin**: "natural skin texture with visible pores", "subtle skin imperfections"148- **Fabric**: "fine wool texture visible", "silk sheen and drape"149- **Surfaces**: "brushed metal finish", "weathered wood grain"150151Example: `"Close-up portrait showing natural skin texture with visible pores, fine fabric detail on collar, realistic hair strands"`152153#### Composition Framing154Be precise about framing and subject positioning:155- **Shot types**: "chest-up framing", "3/4 body shot", "full body"156- **Positioning**: "centered subject", "rule of thirds placement", "mirror selfie angle"157- **Aspect ratio context**: "portrait orientation", "landscape format", "square crop"158159### Example Prompts by Use Case160161**UI/Frontend:**162- "A modern dashboard UI mockup with dark theme, showing analytics charts"163- "Clean minimalist app icon for a task management app, rounded square shape"164- "Hero image for a SaaS landing page, abstract gradient with geometric shapes"165166**Documentation:**167- "Simple architecture diagram showing microservices connected by arrows"168- "Flowchart illustrating user authentication process"169170**Placeholders:**171- "Professional headshot placeholder, silhouette style, neutral gray background"172- "Product image placeholder, simple box shape with 'Image Coming Soon' text"173174**Marketing/Creative:**175- "Isometric illustration of a modern office workspace"176- "Gradient abstract background suitable for presentation slides"177178**Professional Portraits (using advanced techniques):**179- "Corporate headshot, 85mm f/2.8 lens, three-point studio lighting, navy blue suit, neutral gray backdrop, subtle catchlights, chest-up framing, natural skin texture"180- "Casual lifestyle portrait, Kodak Portra 400 tones, natural window light, soft shadows, 3/4 body shot, authentic film grain, early-2000s digital aesthetic"181182**E-commerce & Product Photography:**183- "Product photo of leather watch, 100mm macro lens, soft diffused lighting, visible leather texture and stitching, clean white background, subtle reflection"184- "Fashion flat-lay, overhead shot, soft natural lighting, fabric texture visible, minimalist composition"185186## Troubleshooting187188### "GEMINI_API_KEY not set"189Ensure the environment variable is set in your current shell:190191**Windows (PowerShell):**192```powershell193echo $env:GEMINI_API_KEY # Should show your key194```195196**macOS/Linux:**197```bash198echo $GEMINI_API_KEY # Should show your key199```200201### "API request failed with HTTP status 400"202- Check your prompt for special characters that may break JSON203- Ensure the prompt isn't empty204- Verify API key is valid205206### "API request failed with HTTP status 429"207- Rate limited - wait a moment and retry208- Consider upgrading your API quota209210### "No image data found in response"211- The model may have refused the prompt (content policy)212- Try rephrasing the prompt213- Check if the model returned an error message in the response214215### Image is corrupted/won't open216- Ensure Python 3.6+ is installed217- Check if the full response was received (network issues)218- Verify output path is writable219220### Windows-specific issues221- Make sure Python is in your PATH222- Use forward slashes or escaped backslashes in paths223224## API Costs225226Check [Google AI pricing](https://ai.google.dev/pricing) for current Gemini API costs. Image generation typically costs more than text generation.227228## Limitations229230- Maximum prompt length varies by model231- Some content types may be restricted by Google's content policy232- Generated images are subject to Google's terms of service233- Rate limits apply based on your API tier