Package Exports
- n8n-nodes-kimi-media-router
- n8n-nodes-kimi-media-router/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (n8n-nodes-kimi-media-router) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
AI Media Gateway Router
A production-ready custom n8n node that automatically detects input media types and routes them to the correct AI provider with a unified output schema.
Features
- Automatic Media Detection: Detects audio, image, video, PDF, documents, and text via MIME types, file extensions, and magic bytes
- Smart Provider Routing: Automatically selects the best AI provider for each task type
- Audio Transcription: Supports OpenAI, Groq, Deepgram, and AssemblyAI (explicitly excludes OpenRouter for audio)
- Image Analysis: Vision-capable models via OpenRouter, OpenAI, Gemini, and Google Vision
- OCR: Google Vision, Azure Document Intelligence, Gemini, and OpenAI vision models
- PDF Processing: Local text extraction with OCR fallback via Azure, Google Vision, or Gemini
- Video Processing: ffmpeg audio extraction + transcription, with optional frame sampling and visual analysis
- Unified Output Schema: Consistent JSON output regardless of provider or media type
- Post-Processing: Optional summarization, translation, and structured JSON extraction
Supported Providers & Capabilities
| Provider | Text | Image | Audio Transcription | Video | OCR | |
|---|---|---|---|---|---|---|
| OpenRouter | Yes | Yes (vision) | No | No | No | No |
| OpenAI | Yes | Yes (vision) | Yes | No | Limited | Vision-based |
| Groq | Yes | Model-dependent | Yes | No | No | No |
| Gemini | Yes | Yes | Model-dependent | Yes | Yes | Vision-based |
| Deepgram | No | No | Yes | No | No | No |
| AssemblyAI | No | No | Yes | No | No | No |
| Google Vision | No | Yes | No | No | Yes | Yes |
| Azure Document Intelligence | No | No | No | No | Yes | Yes |
| Local Parser | No | No | No | No | Yes | No |
| Local ffmpeg | No | No | No | Yes | No | No |
Installation
Method 1: npm (Recommended)
npm install ai-media-gateway-routerAdd to your n8n ~/.n8n/config:
{
"nodes": {
"include": ["ai-media-gateway-router"]
}
}Method 2: Manual Build
- Clone or copy this repository to your n8n custom nodes directory:
cd ~/.n8n/custom/
git clone <repository-url> ai-media-gateway-router
cd ai-media-gateway-router- Install dependencies and build:
npm install
npm run build- Restart n8n. The node will appear as AI Media Gateway Router in the node panel.
Requirements
- n8n >= 1.48.0
- Node.js >= 18
- ffmpeg (optional, required for video processing)
Credential Setup
Configure credentials in n8n for each provider you want to use:
OpenRouter
- API Key: Get from openrouter.ai/keys
- Optional: HTTP Referer, X-Title
OpenAI
- API Key: Get from platform.openai.com
Groq
- API Key: Get from console.groq.com
Gemini
- API Key: Get from aistudio.google.com
Deepgram
- API Key: Get from console.deepgram.com
AssemblyAI
- API Key: Get from assemblyai.com
Google Vision
- API Key: Google Cloud API key with Vision API enabled
Azure Document Intelligence
- Endpoint: Your Azure Document Intelligence endpoint URL
- API Key: Your Azure API key
Usage Examples
Example 1: Audio to Text using OpenAI
- Add a Read Binary Files node to load an audio file (MP3, WAV, etc.)
- Add AI Media Gateway Router node:
- Input Source: Binary Data
- Binary Property Name:
data - Task Mode: Audio Transcription
- Provider: OpenAI
- Model:
gpt-4o-mini-transcribe(orwhisper-1) - Language:
en(orauto) - Output Format:
json(ortext,srt,vtt,verboseJson)
- Connect OpenAI API credential
- Execute - output will be unified JSON with text, segments, and timestamps
Example 2: Audio to Text using Groq (Faster)
- Add a Read Binary Files node
- Add AI Media Gateway Router:
- Input Source: Binary Data
- Binary Property Name:
data - Task Mode: Audio Transcription
- Provider: Groq
- Model:
whisper-large-v3-turbo - Language:
auto
- Connect Groq API credential
Example 3: Image Analysis using OpenRouter Vision Model
- Add a Read Binary Files node to load an image
- Add AI Media Gateway Router:
- Input Source: Binary Data
- Binary Property Name:
data - Task Mode: Image Analysis
- Provider: OpenRouter
- Model:
anthropic/claude-3.5-sonnet - User Instructions: "Describe the objects and scene in this image"
- Connect OpenRouter API credential
Example 4: PDF Extraction then Summary using OpenRouter
- Add a Read Binary Files node to load a PDF
- Add AI Media Gateway Router:
- Input Source: Binary Data
- Binary Property Name:
data - Task Mode: PDF Extraction
- Provider: Auto
- Advanced Options:
- Enable OCR Fallback:
true - Enable Summarization:
true - Enable Structured Extraction:
true
- Enable OCR Fallback:
- The node will:
- Extract text locally
- Fall back to OCR if scanned
- Send extracted text to OpenRouter for summarization
- Return structured data extraction
Example 5: Video Transcription using ffmpeg + Groq Whisper
- Add a Read Binary Files node to load a video (MP4, MOV, etc.)
- Add AI Media Gateway Router:
- Input Source: Binary Data
- Binary Property Name:
data - Task Mode: Video Transcription
- Provider: Groq
- Model:
whisper-large-v3-turbo - Output Format:
srt - Advanced Options:
- Enable Timestamps:
true - Enable Speaker Diarization:
true
- Enable Timestamps:
- The node will:
- Extract audio using ffmpeg
- Transcribe with Groq Whisper
- Return SRT-formatted output with speaker labels
Example 6: Video Analysis with Frame Sampling
- Add a Read Binary Files node to load a video
- Add AI Media Gateway Router:
- Input Source: Binary Data
- Binary Property Name:
data - Task Mode: Video Analysis
- Provider: OpenRouter
- Model:
anthropic/claude-3.5-sonnet - User Instructions: "Analyze this video content for key events and actions"
- Advanced Options:
- Enable Frame Sampling:
true - Number of Video Frames:
8
- Enable Frame Sampling:
- The node will:
- Extract audio and transcribe
- Sample 8 frames from the video
- Send frames to vision model for analysis
- Combine transcript + visual analysis
Output Schema
Success Response
{
"success": true,
"mediaType": "audio | image | video | pdf | document | text | unknown",
"task": "audioTranscription | imageAnalysis | ocr | pdfExtraction | videoAnalysis | textAnalysis",
"provider": "openai | groq | deepgram | assemblyai | openrouter | gemini | googleVision | azureDocumentIntelligence",
"model": "gpt-4o-mini-transcribe | whisper-large-v3-turbo | ...",
"language": "en",
"text": "Main extracted or generated text",
"summary": "Optional summary (if enabled)",
"segments": [
{
"start": 0.0,
"end": 5.2,
"text": "Segment text",
"speaker": "A"
}
],
"visualAnalysis": {
"description": "Scene description",
"objects": ["object1", "object2"],
"scene": "Indoor/Outdoor scene",
"ocrText": "Extracted text from image"
},
"document": {
"pages": [{ "pageNumber": 1, "text": "Page text" }],
"tables": [{ "headers": ["Col1"], "rows": [["Val1"]] }],
"fields": [{ "name": "Field1", "value": "Value1" }]
},
"metadata": {
"fileName": "file.mp3",
"mimeType": "audio/mpeg",
"fileSize": 123456,
"duration": 120.5
},
"warnings": [],
"rawResponse": {}
}Error Response
{
"success": false,
"error": {
"message": "Error description",
"code": "ERROR_CODE",
"provider": "providerName",
"task": "taskName",
"suggestedFix": "How to fix this error",
"recommendedProviders": ["Provider1", "Provider2"],
"recommendedModels": ["model1", "model2"]
}
}Provider-Specific Notes
OpenRouter
- Used for: text analysis, image understanding, summarization, classification, extraction, JSON generation
- NOT used for: audio transcription (
/audio/transcriptionsendpoint is explicitly blocked) - Supports vision-capable models for image and video frame analysis
- Uses OpenAI-compatible chat completions API
OpenAI
- Audio transcription:
gpt-4o-mini-transcribe,gpt-4o-transcribe,whisper-1 - Image analysis:
gpt-4o,gpt-4o-mini(vision) - Text analysis: All GPT models
Groq
- Audio transcription:
whisper-large-v3,whisper-large-v3-turbo(very fast) - Text analysis:
llama-3.3-70b-versatile - Does NOT support image analysis
Gemini
- Unique capability: Direct video input (no ffmpeg needed)
- Supports PDF input directly
- Models:
gemini-2.0-flash,gemini-1.5-pro,gemini-2.5-pro
Deepgram
- Audio transcription only
- Features: Speaker diarization, smart formatting, language detection
- Models:
nova-2,nova,enhanced,whisper
AssemblyAI
- Audio transcription only
- Features: Speaker labels, summarization, sentiment analysis
- Async API with polling
Google Vision
- OCR and image analysis
- Free tier available
- Supports PDF text detection (page by page)
Azure Document Intelligence
- OCR and document analysis
- Supports:
prebuilt-read,prebuilt-layout,prebuilt-document - Enterprise-grade document understanding
Important Rules
- OpenRouter does NOT support
/audio/transcriptions. The node will reject this combination with a clear error message suggesting alternative providers. - Audio transcription preferred order: OpenAI (
gpt-4o-mini-transcribe) > Groq (whisper-large-v3-turbo) > Deepgram > AssemblyAI - Video default strategy: Extract audio with ffmpeg → transcribe with audio provider. Gemini can accept direct video input.
- PDF strategy: Local text extraction first → OCR fallback for scanned PDFs → Text analysis with LLM
Advanced Options
| Option | Description |
|---|---|
| Temperature | Controls randomness (0-2, default 0.2) |
| Max Tokens | Maximum output length |
| Enable Timestamps | Word/segment timestamps in transcription |
| Enable Speaker Diarization | Identify different speakers |
| Enable Frame Sampling | Extract frames from video for visual analysis |
| Number of Video Frames | How many frames to sample (1-30) |
| Enable OCR Fallback | Use OCR when PDF has no selectable text |
| Enable Summarization | Generate summary after extraction |
| Enable Translation | Translate output |
| Enable Structured Extraction | Extract key-value pairs as JSON |
Troubleshooting
ffmpeg not available
Install ffmpeg on your system:
- Ubuntu/Debian:
sudo apt-get install ffmpeg - macOS:
brew install ffmpeg - Windows: Download from ffmpeg.org
Missing binary data
Ensure the previous node outputs binary data with the correct property name (default: data).
Unsupported MIME type
The node supports common formats. Check the full list in the media detection source code.
API key errors
Verify your credentials are correctly configured in n8n's credential manager.
License
MIT