AI Multimodal Processing Skill
Process audio, images, videos, documents, and generate images using Google Gemini's multimodal API. Unified interface for all multimedia content understanding and generation.
Core Capabilities
Audio Processing
- Transcription with timestamps (up to 9.5 hours)
- Audio summarization and analysis
- Speech understanding and speaker identification
- Music and environmental sound analysis
- Text-to-speech generation with controllable voice
Image Understanding
- Image captioning and description
- Object detection with bounding boxes (2.0+)
- Pixel-level segmentation (2.5+)
- Visual question answering
- Multi-image comparison (up to 3,600 images)
- OCR and text extraction
Video Analysis
- Scene detection and summarization
- Video Q&A with temporal understanding
- Transcription with visual descriptions
- YouTube URL support
- Long video processing (up to 6 hours)
- Frame-level analysis
Document Extraction
- Native PDF vision processing (up to 1,000 pages)
- Table and form extraction
- Chart and diagram analysis
- Multi-page document understanding
- Structured data output (JSON schema)
- Format conversion (PDF to HTML/JSON)
Image Generation
- Text-to-image generation
- Image editing and modification
- Multi-image composition (up to 3 images)
- Iterative refinement
- Multiple aspect ratios (1:1, 16:9, 9:16, 4:3, 3:4)
- Controllable style and quality
Capability Matrix
| Task |
Audio |
Image |
Video |
Document |
Generation |
| Transcription |
✓ |
- |
✓ |
- |
- |
| Summarization |
✓ |
✓ |
✓ |
✓ |
- |
| Q&A |
✓ |
✓ |
✓ |
✓ |
- |
| Object Detection |
- |
✓ |
✓ |
- |
- |
| Text Extraction |
- |
✓ |
- |
✓ |
- |
| Structured Output |
✓ |
✓ |
✓ |
✓ |
- |
| Creation |
TTS |
- |
- |
- |
✓ |
| Timestamps |
✓ |
- |
✓ |
- |
- |
| Segmentation |
- |
✓ |
- |
- |
- |
Model Selection Guide
Gemini 3.0 Series (Latest)
- gemini-3-pro-image-preview: Best for image generation with text labels
- Superior text rendering in generated images
- Ideal for: architecture diagrams, infographics, technical illustrations
- Supports: 1:1, 16:9, 21:9, 3:4, 4:3, 9:16 aspect ratios
- Max prompt: 480 tokens
Gemini 2.5 Series (Recommended)
- gemini-2.5-pro: Highest quality, all features, 1M-2M context
- gemini-2.5-flash: Best balance, all features, 1M-2M context
- gemini-2.5-flash-lite: Lightweight, segmentation support
- gemini-2.5-flash-image: Image generation only
Gemini 2.0 Series
- gemini-2.0-flash: Fast processing, object detection
- gemini-2.0-flash-lite: Lightweight option
Feature Requirements
- Segmentation: Requires 2.5+ models
- Object Detection: Requires 2.0+ models
- Multi-video: Requires 2.5+ models
- Image Generation: Requires flash-image model
Context Windows
- 2M tokens: ~6 hours video (low-res) or ~2 hours (default)
- 1M tokens: ~3 hours video (low-res) or ~1 hour (default)
- Audio: 32 tokens/second (1 min = 1,920 tokens)
- PDF: 258 tokens/page (fixed)
- Image: 258-1,548 tokens based on size
Quick Start
Prerequisites
API Key Setup: Supports both Google AI Studio and Vertex AI.
The skill checks for GEMINI_API_KEY in this order:
- Process environment:
export GEMINI_API_KEY="your-key"
- Project root:
.env
.claude/.env
.claude/skills/.env
.claude/skills/ai-multimodal/.env
Get API key: https://aistudio.google.com/apikey
For Vertex AI:
export GEMINI_USE_VERTEX=true
export VERTEX_PROJECT_ID=your-gcp-project-id
export VERTEX_LOCATION=us-central1 # Optional
Install SDK (auto-managed via venv):
# The wrapper script auto-creates and manages a virtual environment
# No manual installation needed - just run the scripts via run.sh
Common Patterns
Use the wrapper script scripts/run.sh which auto-manages the venv:
Transcribe Audio:
./scripts/run.sh gemini_batch_process.py \
--files audio.mp3 \
--task transcribe \
--model gemini-2.5-flash
Analyze Image:
./scripts/run.sh gemini_batch_process.py \
--files image.jpg \
--task analyze \
--prompt "Describe this image" \
--output docs/assets/<output-name>.md \
--model gemini-2.5-flash
Process Video:
./scripts/run.sh gemini_batch_process.py \
--files video.mp4 \
--task analyze \
--prompt "Summarize key points with timestamps" \
--output docs/assets/<output-name>.md \
--model gemini-2.5-flash
Extract from PDF:
./scripts/run.sh gemini_batch_process.py \
--files document.pdf \
--task extract \
--prompt "Extract table data as JSON" \
--output docs/assets/<output-name>.md \
--format json
Generate Image:
./scripts/run.sh gemini_batch_process.py \
--task generate \
--prompt "A futuristic city at sunset" \
--output docs/assets/<output-file-name> \
--model gemini-2.5-flash-image \
--aspect-ratio 16:9
Generate Architecture Diagram (best with gemini-3-pro-image-preview):
./scripts/run.sh gemini_batch_process.py \
--task generate \
--prompt "Create an architecture diagram showing [system name] for developers.
Topic: [What to visualize]
Layout: Isometric view with clear layers
Visual Style: Flat vector art, modern tech aesthetic
Format: 16:9
Key Elements: [Component list with icons]
Text Labels: [Exact labels to include]
Color Coding: Blue=core, Green=data, Orange=external" \
--output docs/assets/architecture-diagram \
--model gemini-3-pro-image-preview \
--aspect-ratio 16:9
Tip: For best text label results, keep labels short (max 15 chars) and generate a legend backup.
Optimize Media:
# Prepare large video for processing
python scripts/media_optimizer.py \
--input large-video.mp4 \
--output docs/assets/<output-file-name> \
--target-size 100MB
# Batch optimize multiple files
python scripts/media_optimizer.py \
--input-dir ./videos \
--output-dir docs/assets/optimized \
--quality 85
Convert Documents to Markdown:
# Convert to PDF
python scripts/document_converter.py \
--input document.docx \
--output docs/assets/document.md
# Extract pages
python scripts/document_converter.py \
--input large.pdf \
--output docs/assets/chapter1.md \
--pages 1-20
Supported Formats
Audio
- WAV, MP3, AAC, FLAC, OGG Vorbis, AIFF
- Max 9.5 hours per request
- Auto-downsampled to 16 Kbps mono
Images
- PNG, JPEG, WEBP, HEIC, HEIF
- Max 3,600 images per request
- Resolution: ≤384px = 258 tokens, larger = tiled
Video
- MP4, MPEG, MOV, AVI, FLV, MPG, WebM, WMV, 3GPP
- Max 6 hours (low-res) or 2 hours (default)
- YouTube URLs supported (public only)
Documents
- PDF only for vision processing
- Max 1,000 pages
- TXT, HTML, Markdown supported (text-only)
Size Limits
- Inline: <20MB total request
- File API: 2GB per file, 20GB project quota
- Retention: 48 hours auto-delete
Reference Navigation
For detailed implementation guidance, see:
Audio Processing
references/audio-processing.md - Transcription, analysis, TTS
- Timestamp handling and segment analysis
- Multi-speaker identification
- Non-speech audio analysis
- Text-to-speech generation
Image Understanding
references/vision-understanding.md - Captioning, detection, OCR
- Object detection and localization
- Pixel-level segmentation
- Visual question answering
- Multi-image comparison
Video Analysis
references/video-analysis.md - Scene detection, temporal understanding
- YouTube URL processing
- Timestamp-based queries
- Video clipping and FPS control
- Long video optimization
Document Extraction
references/document-extraction.md - PDF processing, structured output
- Table and form extraction
- Chart and diagram analysis
- JSON schema validation
- Multi-page handling
Image Generation
references/image-generation.md - Text-to-image, editing
- Prompt engineering strategies
- Image editing and composition
- Aspect ratio selection
- Safety settings
Cost Optimization
Token Costs
Input Pricing:
- Gemini 2.5 Flash: $1.00/1M input, $0.10/1M output
- Gemini 2.5 Pro: $3.00/1M input, $12.00/1M output
- Gemini 1.5 Flash: $0.70/1M input, $0.175/1M output
Token Rates:
- Audio: 32 tokens/second (1 min = 1,920 tokens)
- Video: ~300 tokens/second (default) or ~100 (low-res)
- PDF: 258 tokens/page (fixed)
- Image: 258-1,548 tokens based on size
TTS Pricing:
- Flash TTS: $10/1M tokens
- Pro TTS: $20/1M tokens
Best Practices
- Use
gemini-2.5-flash for most tasks (best price/performance)
- Use File API for files >20MB or repeated queries
- Optimize media before upload (see
media_optimizer.py)
- Process specific segments instead of full videos
- Use lower FPS for static content
- Implement context caching for repeated queries
- Batch process multiple files in parallel
Rate Limits
Free Tier:
- 10-15 RPM (requests per minute)
- 1M-4M TPM (tokens per minute)
- 1,500 RPD (requests per day)
YouTube Limits:
- Free tier: 8 hours/day
- Paid tier: No length limits
- Public videos only
Storage Limits:
- 20GB per project
- 2GB per file
- 48-hour retention
Error Handling
Common errors and solutions:
- 400: Invalid format/size - validate before upload
- 401: Invalid API key - check configuration
- 403: Permission denied - verify API key restrictions
- 404: File not found - ensure file uploaded and active
- 429: Rate limit exceeded - implement exponential backoff
- 500: Server error - retry with backoff
Scripts Overview
All scripts support unified API key detection and error handling:
gemini_batch_process.py: Batch process multiple media files
- Supports all modalities (audio, image, video, PDF)
- Progress tracking and error recovery
- Output formats: JSON, Markdown, CSV
- Rate limiting and retry logic
- Dry-run mode
media_optimizer.py: Prepare media for Gemini API
- Compress videos/audio for size limits
- Resize images appropriately
- Split long videos into chunks
- Format conversion
- Quality vs size optimization
document_converter.py: Convert documents to PDF
- Convert DOCX, XLSX, PPTX to PDF
- Extract page ranges
- Optimize PDFs for Gemini
- Extract images from PDFs
- Batch conversion support
Run any script with --help for detailed usage.
Resources
1---2name: ai-multimodal3description: Process and generate multimedia content using Google Gemini API. Capabilities include analyze audio files (transcription with timestamps, summarization, speech understanding, music/sound analysis up to 9.5 hours), understand images (captioning, object detection, OCR, visual Q&A, segmentation), process videos (scene detection, Q&A, temporal analysis, YouTube URLs, up to 6 hours), extract from documents (PDF tables, forms, charts, diagrams, multi-page), generate images (text-to-image, editing, composition, refinement). Use when working with audio/video files, analyzing images or screenshots, processing PDF documents, extracting structured data from media, creating images from text prompts, or implementing multimodal AI features. Supports multiple models (Gemini 2.5/2.0) with context windows up to 2M tokens.4license: MIT5---67# AI Multimodal Processing Skill89Process audio, images, videos, documents, and generate images using Google Gemini's multimodal API. Unified interface for all multimedia content understanding and generation.1011## Core Capabilities1213### Audio Processing14- Transcription with timestamps (up to 9.5 hours)15- Audio summarization and analysis16- Speech understanding and speaker identification17- Music and environmental sound analysis18- Text-to-speech generation with controllable voice1920### Image Understanding21- Image captioning and description22- Object detection with bounding boxes (2.0+)23- Pixel-level segmentation (2.5+)24- Visual question answering25- Multi-image comparison (up to 3,600 images)26- OCR and text extraction2728### Video Analysis29- Scene detection and summarization30- Video Q&A with temporal understanding31- Transcription with visual descriptions32- YouTube URL support33- Long video processing (up to 6 hours)34- Frame-level analysis3536### Document Extraction37- Native PDF vision processing (up to 1,000 pages)38- Table and form extraction39- Chart and diagram analysis40- Multi-page document understanding41- Structured data output (JSON schema)42- Format conversion (PDF to HTML/JSON)4344### Image Generation45- Text-to-image generation46- Image editing and modification47- Multi-image composition (up to 3 images)48- Iterative refinement49- Multiple aspect ratios (1:1, 16:9, 9:16, 4:3, 3:4)50- Controllable style and quality5152## Capability Matrix5354| Task | Audio | Image | Video | Document | Generation |55|------|:-----:|:-----:|:-----:|:--------:|:----------:|56| Transcription | ✓ | - | ✓ | - | - |57| Summarization | ✓ | ✓ | ✓ | ✓ | - |58| Q&A | ✓ | ✓ | ✓ | ✓ | - |59| Object Detection | - | ✓ | ✓ | - | - |60| Text Extraction | - | ✓ | - | ✓ | - |61| Structured Output | ✓ | ✓ | ✓ | ✓ | - |62| Creation | TTS | - | - | - | ✓ |63| Timestamps | ✓ | - | ✓ | - | - |64| Segmentation | - | ✓ | - | - | - |6566## Model Selection Guide6768### Gemini 3.0 Series (Latest)69- **gemini-3-pro-image-preview**: Best for image generation with text labels70 - Superior text rendering in generated images71 - Ideal for: architecture diagrams, infographics, technical illustrations72 - Supports: 1:1, 16:9, 21:9, 3:4, 4:3, 9:16 aspect ratios73 - Max prompt: 480 tokens7475### Gemini 2.5 Series (Recommended)76- **gemini-2.5-pro**: Highest quality, all features, 1M-2M context77- **gemini-2.5-flash**: Best balance, all features, 1M-2M context78- **gemini-2.5-flash-lite**: Lightweight, segmentation support79- **gemini-2.5-flash-image**: Image generation only8081### Gemini 2.0 Series82- **gemini-2.0-flash**: Fast processing, object detection83- **gemini-2.0-flash-lite**: Lightweight option8485### Feature Requirements86- **Segmentation**: Requires 2.5+ models87- **Object Detection**: Requires 2.0+ models88- **Multi-video**: Requires 2.5+ models89- **Image Generation**: Requires flash-image model9091### Context Windows92- **2M tokens**: ~6 hours video (low-res) or ~2 hours (default)93- **1M tokens**: ~3 hours video (low-res) or ~1 hour (default)94- **Audio**: 32 tokens/second (1 min = 1,920 tokens)95- **PDF**: 258 tokens/page (fixed)96- **Image**: 258-1,548 tokens based on size9798## Quick Start99100### Prerequisites101102**API Key Setup**: Supports both Google AI Studio and Vertex AI.103104The skill checks for `GEMINI_API_KEY` in this order:1051. Process environment: `export GEMINI_API_KEY="your-key"`1062. Project root: `.env`1073. `.claude/.env`1084. `.claude/skills/.env`1095. `.claude/skills/ai-multimodal/.env`110111**Get API key**: https://aistudio.google.com/apikey112113**For Vertex AI**:114```bash115export GEMINI_USE_VERTEX=true116export VERTEX_PROJECT_ID=your-gcp-project-id117export VERTEX_LOCATION=us-central1 # Optional118```119120**Install SDK** (auto-managed via venv):121```bash122# The wrapper script auto-creates and manages a virtual environment123# No manual installation needed - just run the scripts via run.sh124```125126### Common Patterns127128**Use the wrapper script** `scripts/run.sh` which auto-manages the venv:129130**Transcribe Audio**:131```bash132./scripts/run.sh gemini_batch_process.py \133 --files audio.mp3 \134 --task transcribe \135 --model gemini-2.5-flash136```137138**Analyze Image**:139```bash140./scripts/run.sh gemini_batch_process.py \141 --files image.jpg \142 --task analyze \143 --prompt "Describe this image" \144 --output docs/assets/<output-name>.md \145 --model gemini-2.5-flash146```147148**Process Video**:149```bash150./scripts/run.sh gemini_batch_process.py \151 --files video.mp4 \152 --task analyze \153 --prompt "Summarize key points with timestamps" \154 --output docs/assets/<output-name>.md \155 --model gemini-2.5-flash156```157158**Extract from PDF**:159```bash160./scripts/run.sh gemini_batch_process.py \161 --files document.pdf \162 --task extract \163 --prompt "Extract table data as JSON" \164 --output docs/assets/<output-name>.md \165 --format json166```167168**Generate Image**:169```bash170./scripts/run.sh gemini_batch_process.py \171 --task generate \172 --prompt "A futuristic city at sunset" \173 --output docs/assets/<output-file-name> \174 --model gemini-2.5-flash-image \175 --aspect-ratio 16:9176```177178**Generate Architecture Diagram** (best with `gemini-3-pro-image-preview`):179```bash180./scripts/run.sh gemini_batch_process.py \181 --task generate \182 --prompt "Create an architecture diagram showing [system name] for developers.183184Topic: [What to visualize]185Layout: Isometric view with clear layers186Visual Style: Flat vector art, modern tech aesthetic187Format: 16:9188Key Elements: [Component list with icons]189Text Labels: [Exact labels to include]190Color Coding: Blue=core, Green=data, Orange=external" \191 --output docs/assets/architecture-diagram \192 --model gemini-3-pro-image-preview \193 --aspect-ratio 16:9194```195**Tip**: For best text label results, keep labels short (max 15 chars) and generate a legend backup.196197**Optimize Media**:198```bash199# Prepare large video for processing200python scripts/media_optimizer.py \201 --input large-video.mp4 \202 --output docs/assets/<output-file-name> \203 --target-size 100MB204205# Batch optimize multiple files206python scripts/media_optimizer.py \207 --input-dir ./videos \208 --output-dir docs/assets/optimized \209 --quality 85210```211212**Convert Documents to Markdown**:213```bash214# Convert to PDF215python scripts/document_converter.py \216 --input document.docx \217 --output docs/assets/document.md218219# Extract pages220python scripts/document_converter.py \221 --input large.pdf \222 --output docs/assets/chapter1.md \223 --pages 1-20224```225226## Supported Formats227228### Audio229- WAV, MP3, AAC, FLAC, OGG Vorbis, AIFF230- Max 9.5 hours per request231- Auto-downsampled to 16 Kbps mono232233### Images234- PNG, JPEG, WEBP, HEIC, HEIF235- Max 3,600 images per request236- Resolution: ≤384px = 258 tokens, larger = tiled237238### Video239- MP4, MPEG, MOV, AVI, FLV, MPG, WebM, WMV, 3GPP240- Max 6 hours (low-res) or 2 hours (default)241- YouTube URLs supported (public only)242243### Documents244- PDF only for vision processing245- Max 1,000 pages246- TXT, HTML, Markdown supported (text-only)247248### Size Limits249- **Inline**: <20MB total request250- **File API**: 2GB per file, 20GB project quota251- **Retention**: 48 hours auto-delete252253## Reference Navigation254255For detailed implementation guidance, see:256257### Audio Processing258- `references/audio-processing.md` - Transcription, analysis, TTS259 - Timestamp handling and segment analysis260 - Multi-speaker identification261 - Non-speech audio analysis262 - Text-to-speech generation263264### Image Understanding265- `references/vision-understanding.md` - Captioning, detection, OCR266 - Object detection and localization267 - Pixel-level segmentation268 - Visual question answering269 - Multi-image comparison270271### Video Analysis272- `references/video-analysis.md` - Scene detection, temporal understanding273 - YouTube URL processing274 - Timestamp-based queries275 - Video clipping and FPS control276 - Long video optimization277278### Document Extraction279- `references/document-extraction.md` - PDF processing, structured output280 - Table and form extraction281 - Chart and diagram analysis282 - JSON schema validation283 - Multi-page handling284285### Image Generation286- `references/image-generation.md` - Text-to-image, editing287 - Prompt engineering strategies288 - Image editing and composition289 - Aspect ratio selection290 - Safety settings291292## Cost Optimization293294### Token Costs295**Input Pricing**:296- Gemini 2.5 Flash: $1.00/1M input, $0.10/1M output297- Gemini 2.5 Pro: $3.00/1M input, $12.00/1M output298- Gemini 1.5 Flash: $0.70/1M input, $0.175/1M output299300**Token Rates**:301- Audio: 32 tokens/second (1 min = 1,920 tokens)302- Video: ~300 tokens/second (default) or ~100 (low-res)303- PDF: 258 tokens/page (fixed)304- Image: 258-1,548 tokens based on size305306**TTS Pricing**:307- Flash TTS: $10/1M tokens308- Pro TTS: $20/1M tokens309310### Best Practices3111. Use `gemini-2.5-flash` for most tasks (best price/performance)3122. Use File API for files >20MB or repeated queries3133. Optimize media before upload (see `media_optimizer.py`)3144. Process specific segments instead of full videos3155. Use lower FPS for static content3166. Implement context caching for repeated queries3177. Batch process multiple files in parallel318319## Rate Limits320321**Free Tier**:322- 10-15 RPM (requests per minute)323- 1M-4M TPM (tokens per minute)324- 1,500 RPD (requests per day)325326**YouTube Limits**:327- Free tier: 8 hours/day328- Paid tier: No length limits329- Public videos only330331**Storage Limits**:332- 20GB per project333- 2GB per file334- 48-hour retention335336## Error Handling337338Common errors and solutions:339- **400**: Invalid format/size - validate before upload340- **401**: Invalid API key - check configuration341- **403**: Permission denied - verify API key restrictions342- **404**: File not found - ensure file uploaded and active343- **429**: Rate limit exceeded - implement exponential backoff344- **500**: Server error - retry with backoff345346## Scripts Overview347348All scripts support unified API key detection and error handling:349350**gemini_batch_process.py**: Batch process multiple media files351- Supports all modalities (audio, image, video, PDF)352- Progress tracking and error recovery353- Output formats: JSON, Markdown, CSV354- Rate limiting and retry logic355- Dry-run mode356357**media_optimizer.py**: Prepare media for Gemini API358- Compress videos/audio for size limits359- Resize images appropriately360- Split long videos into chunks361- Format conversion362- Quality vs size optimization363364**document_converter.py**: Convert documents to PDF365- Convert DOCX, XLSX, PPTX to PDF366- Extract page ranges367- Optimize PDFs for Gemini368- Extract images from PDFs369- Batch conversion support370371Run any script with `--help` for detailed usage.372373## Resources374375- [Audio API Docs](https://ai.google.dev/gemini-api/docs/audio)376- [Image API Docs](https://ai.google.dev/gemini-api/docs/image-understanding)377- [Video API Docs](https://ai.google.dev/gemini-api/docs/video-understanding)378- [Document API Docs](https://ai.google.dev/gemini-api/docs/document-processing)379- [Image Gen Docs](https://ai.google.dev/gemini-api/docs/image-generation)380- [Get API Key](https://aistudio.google.com/apikey)381- [Pricing](https://ai.google.dev/pricing)