Image Generation
Generate images from text prompts using OpenAI, Google Imagen, Nano Banana Pro (Gemini), or fal.ai.
Usage
OpenAI (gpt-image-1)
uv run ~/.claude/skills/image-gen/scripts/generate_openai.py \
--prompt "a cat wearing a top hat" \
--output /tmp/cat.png
Options:
--prompt (required): Text description of the image
--output, -o: Output file path (default: ./generated-{timestamp}.png)
--size: Image size (default: 1024x1024, options: 1024x1024, 1024x1792, 1792x1024)
--quality: Image quality (default: auto, options: low, medium, high, auto)
Google Imagen 4
uv run ~/.claude/skills/image-gen/scripts/generate_imagen.py \
--prompt "a cat wearing a top hat" \
--output /tmp/cat.png
Options:
--prompt (required): Text description of the image
--output, -o: Output file path (default: ./generated-{timestamp}.png)
--model: Model to use (default: imagen-4.0-generate-001, options: imagen-4.0-fast-generate-001, imagen-4.0-ultra-generate-001)
Nano Banana Pro (Gemini)
uv run ~/.claude/skills/image-gen/scripts/generate_gemini.py \
--prompt "a cat wearing a top hat" \
--output /tmp/cat.png
Options:
--prompt (required): Text description of the image
--output, -o: Output file path (default: ./generated-{timestamp}.jpg)
--model: Model to use (default: gemini-3-pro-image-preview)
--aspect-ratio, -a: Aspect ratio (default: 1:1, options: 1:1, 16:9, 9:16, 21:9)
--image-size, -s: Output size for Pro model (options: 1K, 2K, 4K)
fal.ai (Flux)
uv run ~/.claude/skills/image-gen/scripts/generate_fal.py \
--prompt "a cat wearing a top hat" \
--output /tmp/cat.png
Options:
--prompt (required): Text description of the image
--output, -o: Output file path (default: ./generated-{timestamp}.png)
--model: Model to use (default: fal-ai/flux/dev)
Provider Comparison
| Provider |
Model |
Speed |
Quality |
Cost |
| OpenAI |
gpt-image-1 |
Medium |
Excellent |
~$0.04/img |
| Google |
Imagen 4 |
Medium |
Excellent |
~$0.04/img |
| Google |
Nano Banana Pro |
Fast |
Excellent |
~$0.13/img (2K) |
| fal.ai |
Flux dev |
Fast |
Very good |
Pay-per-compute |
Environment Variables
| Provider |
Variable |
Required |
| OpenAI |
OPENAI_API_KEY |
Yes |
| Google |
GOOGLE_API_KEY |
Yes |
| fal.ai |
FAL_KEY |
Yes |
Set in ~/.env or export in shell.
Troubleshooting
Getting API Keys
Common Errors
"API key not set"
# Add to ~/.env
echo "GOOGLE_API_KEY=your-key-here" >> ~/.env
# Or export in current shell
export GOOGLE_API_KEY=your-key-here
"API key is invalid"
- Regenerate your key at the provider's dashboard
- Ensure no extra whitespace when copying the key
- Check the key hasn't expired
"Rate limit exceeded"
- Wait 1-2 minutes and retry
- Check your usage quota at the provider's dashboard
"Content blocked"
- The prompt triggered safety filters
- Rephrase to avoid restricted content
"Cannot connect"
- Check your internet connection
- Verify the API service isn't experiencing outages
File Format Notes
- OpenAI: Returns PNG
- Google Imagen: Returns PNG
- Google Gemini: Returns JPEG (scripts auto-correct extension if needed)
- fal.ai Flux: Returns JPEG (scripts auto-correct extension if needed)
Testing
uv run ~/.claude/skills/image-gen/tests/test_image_gen.py --help
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: image-gen-23description: Generate images using AI APIs (OpenAI gpt-image-1, Google Imagen 4, Nano Banana Pro, fal.ai Flux). Use when user asks to generate, create, or make an image. Use when this capability is needed.4---56# Image Generation78Generate images from text prompts using OpenAI, Google Imagen, Nano Banana Pro (Gemini), or fal.ai.910## Usage1112### OpenAI (gpt-image-1)13```bash14uv run ~/.claude/skills/image-gen/scripts/generate_openai.py \15 --prompt "a cat wearing a top hat" \16 --output /tmp/cat.png17```1819Options:20- `--prompt` (required): Text description of the image21- `--output`, `-o`: Output file path (default: `./generated-{timestamp}.png`)22- `--size`: Image size (default: `1024x1024`, options: `1024x1024`, `1024x1792`, `1792x1024`)23- `--quality`: Image quality (default: `auto`, options: `low`, `medium`, `high`, `auto`)2425### Google Imagen 426```bash27uv run ~/.claude/skills/image-gen/scripts/generate_imagen.py \28 --prompt "a cat wearing a top hat" \29 --output /tmp/cat.png30```3132Options:33- `--prompt` (required): Text description of the image34- `--output`, `-o`: Output file path (default: `./generated-{timestamp}.png`)35- `--model`: Model to use (default: `imagen-4.0-generate-001`, options: `imagen-4.0-fast-generate-001`, `imagen-4.0-ultra-generate-001`)3637### Nano Banana Pro (Gemini)38```bash39uv run ~/.claude/skills/image-gen/scripts/generate_gemini.py \40 --prompt "a cat wearing a top hat" \41 --output /tmp/cat.png42```4344Options:45- `--prompt` (required): Text description of the image46- `--output`, `-o`: Output file path (default: `./generated-{timestamp}.jpg`)47- `--model`: Model to use (default: `gemini-3-pro-image-preview`)48- `--aspect-ratio`, `-a`: Aspect ratio (default: `1:1`, options: `1:1`, `16:9`, `9:16`, `21:9`)49- `--image-size`, `-s`: Output size for Pro model (options: `1K`, `2K`, `4K`)5051### fal.ai (Flux)52```bash53uv run ~/.claude/skills/image-gen/scripts/generate_fal.py \54 --prompt "a cat wearing a top hat" \55 --output /tmp/cat.png56```5758Options:59- `--prompt` (required): Text description of the image60- `--output`, `-o`: Output file path (default: `./generated-{timestamp}.png`)61- `--model`: Model to use (default: `fal-ai/flux/dev`)6263## Provider Comparison6465| Provider | Model | Speed | Quality | Cost |66|----------|-------|-------|---------|------|67| OpenAI | gpt-image-1 | Medium | Excellent | ~$0.04/img |68| Google | Imagen 4 | Medium | Excellent | ~$0.04/img |69| Google | Nano Banana Pro | Fast | Excellent | ~$0.13/img (2K) |70| fal.ai | Flux dev | Fast | Very good | Pay-per-compute |7172## Environment Variables7374| Provider | Variable | Required |75|----------|----------|----------|76| OpenAI | `OPENAI_API_KEY` | Yes |77| Google | `GOOGLE_API_KEY` | Yes |78| fal.ai | `FAL_KEY` | Yes |7980Set in `~/.env` or export in shell.8182## Troubleshooting8384### Getting API Keys8586| Provider | Get Key URL |87|----------|-------------|88| OpenAI | https://platform.openai.com/api-keys |89| Google | https://aistudio.google.com/apikey |90| fal.ai | https://fal.ai/dashboard/keys |9192### Common Errors9394**"API key not set"**95```bash96# Add to ~/.env97echo "GOOGLE_API_KEY=your-key-here" >> ~/.env9899# Or export in current shell100export GOOGLE_API_KEY=your-key-here101```102103**"API key is invalid"**104- Regenerate your key at the provider's dashboard105- Ensure no extra whitespace when copying the key106- Check the key hasn't expired107108**"Rate limit exceeded"**109- Wait 1-2 minutes and retry110- Check your usage quota at the provider's dashboard111112**"Content blocked"**113- The prompt triggered safety filters114- Rephrase to avoid restricted content115116**"Cannot connect"**117- Check your internet connection118- Verify the API service isn't experiencing outages119120### File Format Notes121122- **OpenAI**: Returns PNG123- **Google Imagen**: Returns PNG124- **Google Gemini**: Returns JPEG (scripts auto-correct extension if needed)125- **fal.ai Flux**: Returns JPEG (scripts auto-correct extension if needed)126127## Testing128129`uv run ~/.claude/skills/image-gen/tests/test_image_gen.py --help`130131---132> Converted and distributed by [TomeVault](https://tomevault.io/claim/fairchild) — claim your Tome and manage your conversions.133<!-- tomevault:4.0:skill_md:2026-04-13 -->