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 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:
pip install google-genai python-dotenv pillow
Common Patterns
Transcribe Audio:
python scripts/gemini_batch_process.py \
--files audio.mp3 \
--task transcribe \
--model gemini-2.5-flash
Analyze Image:
python scripts/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:
python scripts/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:
python scripts/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:
python scripts/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
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-multimodal-73description: 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 Processing1415- Transcription with timestamps (up to 9.5 hours)16- Audio summarization and analysis17- Speech understanding and speaker identification18- Music and environmental sound analysis19- Text-to-speech generation with controllable voice2021### Image Understanding2223- Image captioning and description24- Object detection with bounding boxes (2.0+)25- Pixel-level segmentation (2.5+)26- Visual question answering27- Multi-image comparison (up to 3,600 images)28- OCR and text extraction2930### Video Analysis3132- Scene detection and summarization33- Video Q&A with temporal understanding34- Transcription with visual descriptions35- YouTube URL support36- Long video processing (up to 6 hours)37- Frame-level analysis3839### Document Extraction4041- Native PDF vision processing (up to 1,000 pages)42- Table and form extraction43- Chart and diagram analysis44- Multi-page document understanding45- Structured data output (JSON schema)46- Format conversion (PDF to HTML/JSON)4748### Image Generation4950- Text-to-image generation51- Image editing and modification52- Multi-image composition (up to 3 images)53- Iterative refinement54- Multiple aspect ratios (1:1, 16:9, 9:16, 4:3, 3:4)55- Controllable style and quality5657## Capability Matrix5859| Task | Audio | Image | Video | Document | Generation |60| ----------------- | :---: | :---: | :---: | :------: | :--------: |61| Transcription | ✓ | - | ✓ | - | - |62| Summarization | ✓ | ✓ | ✓ | ✓ | - |63| Q&A | ✓ | ✓ | ✓ | ✓ | - |64| Object Detection | - | ✓ | ✓ | - | - |65| Text Extraction | - | ✓ | - | ✓ | - |66| Structured Output | ✓ | ✓ | ✓ | ✓ | - |67| Creation | TTS | - | - | - | ✓ |68| Timestamps | ✓ | - | ✓ | - | - |69| Segmentation | - | ✓ | - | - | - |7071## Model Selection Guide7273### Gemini 2.5 Series (Recommended)7475- **gemini-2.5-pro**: Highest quality, all features, 1M-2M context76- **gemini-2.5-flash**: Best balance, all features, 1M-2M context77- **gemini-2.5-flash-lite**: Lightweight, segmentation support78- **gemini-2.5-flash-image**: Image generation only7980### Gemini 2.0 Series8182- **gemini-2.0-flash**: Fast processing, object detection83- **gemini-2.0-flash-lite**: Lightweight option8485### Feature Requirements8687- **Segmentation**: Requires 2.5+ models88- **Object Detection**: Requires 2.0+ models89- **Multi-video**: Requires 2.5+ models90- **Image Generation**: Requires flash-image model9192### Context Windows9394- **2M tokens**: ~6 hours video (low-res) or ~2 hours (default)95- **1M tokens**: ~3 hours video (low-res) or ~1 hour (default)96- **Audio**: 32 tokens/second (1 min = 1,920 tokens)97- **PDF**: 258 tokens/page (fixed)98- **Image**: 258-1,548 tokens based on size99100## Quick Start101102### Prerequisites103104**API Key Setup**: Supports both Google AI Studio and Vertex AI.105106The skill checks for `GEMINI_API_KEY` in this order:1071081. Process environment: `export GEMINI_API_KEY="your-key"`1092. Project root: `.env`1103. `.claude/.env`1114. `.claude/skills/.env`1125. `.claude/skills/ai-multimodal/.env`113114**Get API key**: https://aistudio.google.com/apikey115116**For Vertex AI**:117118```bash119export GEMINI_USE_VERTEX=true120export VERTEX_PROJECT_ID=your-gcp-project-id121export VERTEX_LOCATION=us-central1 # Optional122```123124**Install SDK**:125126```bash127pip install google-genai python-dotenv pillow128```129130### Common Patterns131132**Transcribe Audio**:133134```bash135python scripts/gemini_batch_process.py \136 --files audio.mp3 \137 --task transcribe \138 --model gemini-2.5-flash139```140141**Analyze Image**:142143```bash144python scripts/gemini_batch_process.py \145 --files image.jpg \146 --task analyze \147 --prompt "Describe this image" \148 --output docs/assets/<output-name>.md \149 --model gemini-2.5-flash150```151152**Process Video**:153154```bash155python scripts/gemini_batch_process.py \156 --files video.mp4 \157 --task analyze \158 --prompt "Summarize key points with timestamps" \159 --output docs/assets/<output-name>.md \160 --model gemini-2.5-flash161```162163**Extract from PDF**:164165```bash166python scripts/gemini_batch_process.py \167 --files document.pdf \168 --task extract \169 --prompt "Extract table data as JSON" \170 --output docs/assets/<output-name>.md \171 --format json172```173174**Generate Image**:175176```bash177python scripts/gemini_batch_process.py \178 --task generate \179 --prompt "A futuristic city at sunset" \180 --output docs/assets/<output-file-name> \181 --model gemini-2.5-flash-image \182 --aspect-ratio 16:9183```184185**Optimize Media**:186187```bash188# Prepare large video for processing189python scripts/media_optimizer.py \190 --input large-video.mp4 \191 --output docs/assets/<output-file-name> \192 --target-size 100MB193194# Batch optimize multiple files195python scripts/media_optimizer.py \196 --input-dir ./videos \197 --output-dir docs/assets/optimized \198 --quality 85199```200201**Convert Documents to Markdown**:202203```bash204# Convert to PDF205python scripts/document_converter.py \206 --input document.docx \207 --output docs/assets/document.md208209# Extract pages210python scripts/document_converter.py \211 --input large.pdf \212 --output docs/assets/chapter1.md \213 --pages 1-20214```215216## Supported Formats217218### Audio219220- WAV, MP3, AAC, FLAC, OGG Vorbis, AIFF221- Max 9.5 hours per request222- Auto-downsampled to 16 Kbps mono223224### Images225226- PNG, JPEG, WEBP, HEIC, HEIF227- Max 3,600 images per request228- Resolution: ≤384px = 258 tokens, larger = tiled229230### Video231232- MP4, MPEG, MOV, AVI, FLV, MPG, WebM, WMV, 3GPP233- Max 6 hours (low-res) or 2 hours (default)234- YouTube URLs supported (public only)235236### Documents237238- PDF only for vision processing239- Max 1,000 pages240- TXT, HTML, Markdown supported (text-only)241242### Size Limits243244- **Inline**: <20MB total request245- **File API**: 2GB per file, 20GB project quota246- **Retention**: 48 hours auto-delete247248## Reference Navigation249250For detailed implementation guidance, see:251252### Audio Processing253254- `references/audio-processing.md` - Transcription, analysis, TTS255 - Timestamp handling and segment analysis256 - Multi-speaker identification257 - Non-speech audio analysis258 - Text-to-speech generation259260### Image Understanding261262- `references/vision-understanding.md` - Captioning, detection, OCR263 - Object detection and localization264 - Pixel-level segmentation265 - Visual question answering266 - Multi-image comparison267268### Video Analysis269270- `references/video-analysis.md` - Scene detection, temporal understanding271 - YouTube URL processing272 - Timestamp-based queries273 - Video clipping and FPS control274 - Long video optimization275276### Document Extraction277278- `references/document-extraction.md` - PDF processing, structured output279 - Table and form extraction280 - Chart and diagram analysis281 - JSON schema validation282 - Multi-page handling283284### Image Generation285286- `references/image-generation.md` - Text-to-image, editing287 - Prompt engineering strategies288 - Image editing and composition289 - Aspect ratio selection290 - Safety settings291292## Cost Optimization293294### Token Costs295296**Input Pricing**:297298- Gemini 2.5 Flash: $1.00/1M input, $0.10/1M output299- Gemini 2.5 Pro: $3.00/1M input, $12.00/1M output300- Gemini 1.5 Flash: $0.70/1M input, $0.175/1M output301302**Token Rates**:303304- Audio: 32 tokens/second (1 min = 1,920 tokens)305- Video: ~300 tokens/second (default) or ~100 (low-res)306- PDF: 258 tokens/page (fixed)307- Image: 258-1,548 tokens based on size308309**TTS Pricing**:310311- Flash TTS: $10/1M tokens312- Pro TTS: $20/1M tokens313314### Best Practices3153161. Use `gemini-2.5-flash` for most tasks (best price/performance)3172. Use File API for files >20MB or repeated queries3183. Optimize media before upload (see `media_optimizer.py`)3194. Process specific segments instead of full videos3205. Use lower FPS for static content3216. Implement context caching for repeated queries3227. Batch process multiple files in parallel323324## Rate Limits325326**Free Tier**:327328- 10-15 RPM (requests per minute)329- 1M-4M TPM (tokens per minute)330- 1,500 RPD (requests per day)331332**YouTube Limits**:333334- Free tier: 8 hours/day335- Paid tier: No length limits336- Public videos only337338**Storage Limits**:339340- 20GB per project341- 2GB per file342- 48-hour retention343344## Error Handling345346Common errors and solutions:347348- **400**: Invalid format/size - validate before upload349- **401**: Invalid API key - check configuration350- **403**: Permission denied - verify API key restrictions351- **404**: File not found - ensure file uploaded and active352- **429**: Rate limit exceeded - implement exponential backoff353- **500**: Server error - retry with backoff354355## Scripts Overview356357All scripts support unified API key detection and error handling:358359**gemini_batch_process.py**: Batch process multiple media files360361- Supports all modalities (audio, image, video, PDF)362- Progress tracking and error recovery363- Output formats: JSON, Markdown, CSV364- Rate limiting and retry logic365- Dry-run mode366367**media_optimizer.py**: Prepare media for Gemini API368369- Compress videos/audio for size limits370- Resize images appropriately371- Split long videos into chunks372- Format conversion373- Quality vs size optimization374375**document_converter.py**: Convert documents to PDF376377- Convert DOCX, XLSX, PPTX to PDF378- Extract page ranges379- Optimize PDFs for Gemini380- Extract images from PDFs381- Batch conversion support382383Run any script with `--help` for detailed usage.384385## Resources386387- [Audio API Docs](https://ai.google.dev/gemini-api/docs/audio)388- [Image API Docs](https://ai.google.dev/gemini-api/docs/image-understanding)389- [Video API Docs](https://ai.google.dev/gemini-api/docs/video-understanding)390- [Document API Docs](https://ai.google.dev/gemini-api/docs/document-processing)391- [Image Gen Docs](https://ai.google.dev/gemini-api/docs/image-generation)392- [Get API Key](https://aistudio.google.com/apikey)393- [Pricing](https://ai.google.dev/pricing)