media-gen-cli 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example ADDED
@@ -0,0 +1,63 @@
1
+ # Media Gen CLI - Environment Variables
2
+ # Copy this file to .env and fill in the API keys for your providers.
3
+
4
+ # OpenAI
5
+ OPENAI_API_KEY=
6
+
7
+ # Google (Gemini / Imagen / Veo)
8
+ GOOGLE_GENERATIVE_AI_API_KEY=
9
+
10
+ # Azure AI Services (OpenAI-compatible endpoint)
11
+ AZURE_OPENAI_API_KEY=
12
+ AZURE_OPENAI_ENDPOINT=https://{resource}.services.ai.azure.com/openai/v1
13
+
14
+ # ElevenLabs
15
+ ELEVENLABS_API_KEY=
16
+
17
+ # Deepgram (transcription, translation, TTS)
18
+ DEEPGRAM_API_KEY=
19
+
20
+ # Fal.ai
21
+ FAL_KEY=
22
+
23
+ # Luma AI
24
+ LUMA_API_KEY=
25
+
26
+ # Replicate
27
+ REPLICATE_API_TOKEN=
28
+
29
+ # Stability AI
30
+ STABILITY_API_KEY=
31
+
32
+ # Runway
33
+ RUNWAY_API_KEY=
34
+
35
+ # Minimax
36
+ MINIMAX_API_KEY=
37
+
38
+ # OpenRouter
39
+ OPENROUTER_API_KEY=
40
+
41
+ # Default provider and model (used when --provider/--model not supplied)
42
+ MEDIA_GEN_DEFAULT_PROVIDER=
43
+ MEDIA_GEN_DEFAULT_MODEL=
44
+
45
+ # Per-type overrides (take priority over global defaults)
46
+ MEDIA_GEN_IMAGE_PROVIDER=
47
+ MEDIA_GEN_IMAGE_MODEL=
48
+ MEDIA_GEN_VIDEO_PROVIDER=
49
+ MEDIA_GEN_VIDEO_MODEL=
50
+ MEDIA_GEN_VOICE_PROVIDER=
51
+ MEDIA_GEN_VOICE_MODEL=
52
+ # Default voice ID for TTS (so --voice-id is optional)
53
+ # Edge TTS examples: en-US-EmmaMultilingualNeural, en-US-AndrewMultilingualNeural
54
+ # ElevenLabs example: JBFqnCBsd6RMkjVDRZzb
55
+ # OpenAI examples: alloy, echo, fable, onyx, nova, shimmer
56
+ MEDIA_GEN_VOICE_ID=
57
+ MEDIA_GEN_AUDIO_PROVIDER=
58
+ MEDIA_GEN_AUDIO_MODEL=
59
+
60
+ # Log level: silent, error, warn, info, debug, trace (default: error)
61
+ # Controls what gets written to ~/.media-gen/logs/
62
+ # The --debug flag always overrides this to 'debug'
63
+ MEDIA_GEN_LOG_LEVEL=error
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Francis Hor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,296 @@
1
+ # media-gen
2
+
3
+ [![skills.sh](https://skills.sh/b/onimusya/media-gen)](https://skills.sh/onimusya/media-gen)
4
+
5
+ A production-ready CLI for multi-provider media generation. Generate images, videos, voice, and transcriptions through OpenAI, Google, Azure, ElevenLabs, Deepgram, Fal.ai, Luma AI, Replicate, Stability AI, Runway, OpenRouter, MiniMax, and Microsoft Edge TTS — all from a single interface.
6
+
7
+ Designed for both direct human use and AI agent integration.
8
+
9
+ ## Prerequisites
10
+
11
+ - **Node.js 18+** — [Download](https://nodejs.org/)
12
+ - **npm** — comes with Node.js
13
+ - At least one provider API key (or use Edge TTS which is free, no key needed)
14
+
15
+ ## Installation
16
+
17
+ ### As an Agent Skill (recommended)
18
+
19
+ Install the skill into any AI agent (Claude Code, Cursor, Codex, Copilot, Windsurf, Gemini, Cline, Kiro):
20
+
21
+ ```bash
22
+ npx skills add onimusya/media-gen
23
+ ```
24
+
25
+ This downloads the `SKILL.md` and the pre-built CLI into your project's skills directory. Your agent will auto-discover it.
26
+
27
+ ### As a global CLI
28
+
29
+ ```bash
30
+ npm install -g media-gen-cli
31
+ ```
32
+
33
+ ### As a local project dependency
34
+
35
+ ```bash
36
+ npm install media-gen-cli
37
+ npx media-gen --help
38
+ ```
39
+
40
+ ## Configuration
41
+
42
+ ### Config Hierarchy
43
+
44
+ media-gen-cli loads configuration from multiple levels (highest priority first):
45
+
46
+ 1. **Project `.env`** — `<project>/.env` (overrides everything)
47
+ 2. **System environment variables** — already in your shell
48
+ 3. **User-level `~/.media-gen/.env`** — shared across all projects (fills gaps)
49
+
50
+ Config files (`.media-gen/config.json`) merge similarly:
51
+ 1. `~/.media-gen/config.json` — user-level defaults
52
+ 2. `<project>/.media-gen/config.json` — project-level overrides
53
+
54
+ ### Setup
55
+
56
+ ```bash
57
+ # Initialize user-level config (once, shared across all projects)
58
+ media-gen config init --global
59
+ # Creates ~/.media-gen/.env and ~/.media-gen/config.json
60
+
61
+ # Initialize project-level config
62
+ media-gen config init
63
+ # Creates .media-gen/config.json in current project
64
+
65
+ # Check what's configured
66
+ media-gen config validate
67
+ ```
68
+
69
+ ### Environment Variables
70
+
71
+ Set API keys for the providers you want to use in `~/.media-gen/.env` (global) or `<project>/.env` (per-project):
72
+
73
+ ```bash
74
+ # OpenAI (images, TTS, transcription)
75
+ OPENAI_API_KEY=sk-...
76
+
77
+ # Google (Imagen, Veo)
78
+ GOOGLE_GENERATIVE_AI_API_KEY=AIza...
79
+
80
+ # Azure OpenAI
81
+ AZURE_OPENAI_API_KEY=
82
+ AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
83
+
84
+ # ElevenLabs (TTS, voice clone, isolation)
85
+ ELEVENLABS_API_KEY=
86
+
87
+ # Deepgram (transcription, translation, TTS)
88
+ DEEPGRAM_API_KEY=
89
+
90
+ # Fal.ai (images, video)
91
+ FAL_KEY=
92
+
93
+ # Luma AI (video)
94
+ LUMA_API_KEY=
95
+
96
+ # Replicate (images, video)
97
+ REPLICATE_API_TOKEN=
98
+
99
+ # Stability AI (images)
100
+ STABILITY_API_KEY=
101
+
102
+ # Runway (video)
103
+ RUNWAY_API_KEY=
104
+
105
+ # OpenRouter (images, multi-provider gateway)
106
+ OPENROUTER_API_KEY=
107
+
108
+ # Edge TTS requires NO API key (free)
109
+ ```
110
+
111
+ ### Default Provider & Model
112
+
113
+ Set defaults so `--provider`, `--model`, and `--voice-id` are optional:
114
+
115
+ ```bash
116
+ # Global defaults
117
+ MEDIA_GEN_DEFAULT_PROVIDER=openrouter
118
+ MEDIA_GEN_DEFAULT_MODEL=openai/gpt-image-2
119
+
120
+ # Per-type overrides (take priority over global)
121
+ MEDIA_GEN_IMAGE_PROVIDER=openrouter
122
+ MEDIA_GEN_IMAGE_MODEL=openai/gpt-image-2
123
+ MEDIA_GEN_VIDEO_PROVIDER=google
124
+ MEDIA_GEN_VIDEO_MODEL=veo-3.1-generate-preview
125
+ MEDIA_GEN_VOICE_PROVIDER=edge-tts
126
+ MEDIA_GEN_VOICE_ID=en-US-EmmaMultilingualNeural
127
+ MEDIA_GEN_AUDIO_PROVIDER=deepgram
128
+ MEDIA_GEN_AUDIO_MODEL=nova-3
129
+
130
+ # Log level (silent, error, warn, info, debug, trace)
131
+ MEDIA_GEN_LOG_LEVEL=error
132
+ ```
133
+
134
+ ## Quick Start
135
+
136
+ ```bash
137
+ # With defaults configured, just provide a prompt:
138
+ media-gen image generate --prompt "A serene mountain lake at dawn" --output ./outputs/lake.png
139
+
140
+ # Or specify provider/model explicitly:
141
+ media-gen image generate \
142
+ --provider openai --model gpt-image-2 \
143
+ --prompt "A pixel art dragon" --output ./outputs/dragon.png
144
+
145
+ # Free text-to-speech (no API key needed):
146
+ media-gen voice tts \
147
+ --provider edge-tts \
148
+ --voice-id en-US-EmmaMultilingualNeural \
149
+ --text "Hello from media-gen!" \
150
+ --output ./outputs/hello.mp3
151
+
152
+ # Google Gemini TTS (30 voices, controllable style):
153
+ media-gen voice tts \
154
+ --provider google \
155
+ --model gemini-3.1-flash-tts-preview \
156
+ --voice-id Kore \
157
+ --text "Say cheerfully: Have a wonderful day!" \
158
+ --output ./outputs/gemini.wav
159
+
160
+ # Transcribe audio:
161
+ media-gen audio transcribe \
162
+ --provider deepgram --input ./audio/meeting.mp3 \
163
+ --output ./outputs/transcript.json
164
+
165
+ # List all providers with their models and voices:
166
+ media-gen providers list
167
+
168
+ # List voices for a specific TTS provider:
169
+ media-gen providers models --provider elevenlabs
170
+ media-gen providers models --provider edge-tts
171
+ media-gen providers models --provider google
172
+ ```
173
+
174
+ ## CLI Commands
175
+
176
+ | Command | Description |
177
+ |---------|-------------|
178
+ | `image generate` | Generate an image from text |
179
+ | `image edit` | Edit an existing image |
180
+ | `video generate` | Generate a video from text |
181
+ | `video image-to-video` | Animate an image into video |
182
+ | `video extend` | Extend an existing video |
183
+ | `voice tts` | Text to speech synthesis |
184
+ | `voice clone` | Clone a voice from samples |
185
+ | `voice isolate` | Isolate voice from background |
186
+ | `audio transcribe` | Transcribe audio to text |
187
+ | `audio translate` | Translate audio to another language |
188
+ | `providers list` | List all providers with models and voices |
189
+ | `providers models` | List models/voices (filter by provider/capability) |
190
+ | `config init` | Initialize configuration (`--global` for user-level) |
191
+ | `config validate` | Validate provider configuration |
192
+ | `skill generate` | Generate AI agent SKILL.md file |
193
+ | `job status` | Check async job status |
194
+ | `job download` | Download async job result |
195
+
196
+ ### Global Options
197
+
198
+ - `--debug` — Enable debug logging
199
+ - `--json` — Machine-readable JSON output
200
+ - `--dry-run` — Validate without calling providers
201
+ - `--overwrite` — Allow overwriting existing files
202
+ - `--metadata` — Save metadata JSON alongside output
203
+ - `--allow-external-output` — Allow writing outside project directory
204
+
205
+ ## Provider Support Matrix
206
+
207
+ | Provider | Image | Video | TTS | Transcribe | Translate | Voice Clone | Voice Isolate |
208
+ |----------|-------|-------|-----|------------|-----------|-------------|---------------|
209
+ | OpenAI | ✓ | | ✓ | ✓ | ✓ | | |
210
+ | Google | ✓ | ✓ | ✓ | | | | |
211
+ | Azure | ✓ | | ✓ | ✓ | ✓ | | |
212
+ | ElevenLabs | | | ✓ | | | ✓ | ✓ |
213
+ | Deepgram | | | ✓ | ✓ | ✓ | | |
214
+ | Fal.ai | ✓ | ✓ | | | | | |
215
+ | Luma AI | | ✓ | | | | | |
216
+ | Replicate | ✓ | ✓ | | | | | |
217
+ | Stability AI | ✓ | | | | | | |
218
+ | Runway | | ✓ | | | | | |
219
+ | OpenRouter | ✓ | ✓ | | | | | |
220
+ | MiniMax | | ✓ | ✓ | | | | |
221
+ | Edge TTS | | | ✓ (free) | | | | |
222
+
223
+ ## Agent Integration
224
+
225
+ The CLI includes a SKILL.md file at `skills/media-generation/SKILL.md` following the [Agent Skills](https://agentskills.io/) open standard. AI agents can:
226
+
227
+ 1. Discover the skill file and learn available capabilities
228
+ 2. Run the pre-built CLI at `skills/media-generation/scripts/media-gen.mjs`
229
+ 3. Parse structured JSON responses
230
+ 4. Handle errors programmatically via error codes
231
+
232
+ ```bash
233
+ # Agent invocation pattern:
234
+ node ./skills/media-generation/scripts/media-gen.mjs image generate \
235
+ --prompt "..." --output ./out.png --json
236
+ ```
237
+
238
+ See `docs/agents.md` for the full agent integration guide.
239
+
240
+ ## Examples
241
+
242
+ See the `examples/` directory:
243
+
244
+ - `image-generate.sh` — Image generation with multiple providers
245
+ - `video-generate.sh` — Video generation with async polling
246
+ - `voice-tts.sh` — Text-to-speech with OpenAI and ElevenLabs
247
+ - `edge-tts.sh` — Free TTS with Microsoft Edge (multiple languages)
248
+ - `deepgram-transcribe.sh` — Transcription and translation
249
+ - `transcribe.sh` — Audio transcription examples
250
+
251
+ ## Development
252
+
253
+ ```bash
254
+ npm install # Install dependencies
255
+ npm run dev -- --help # Run in dev mode
256
+ npm run typecheck # Type check
257
+ npm test # Run tests
258
+ npm run build # Bundle to dist/media-gen.mjs
259
+ ```
260
+
261
+ ## Build
262
+
263
+ ```bash
264
+ npm run build
265
+ ```
266
+
267
+ Produces `dist/media-gen.mjs` and copies it to `skills/media-generation/scripts/media-gen.mjs` for agent access.
268
+
269
+ ## Async Video Jobs
270
+
271
+ ```bash
272
+ # Wait for completion
273
+ media-gen video generate \
274
+ --provider google --model veo-3.1-generate-preview \
275
+ --prompt "..." --wait --timeout 300000 --json
276
+
277
+ # Or get job ID and check later
278
+ media-gen video generate --provider google --model veo-3.1-generate-preview --prompt "..." --json
279
+ media-gen job status --provider google --job-id "operations/abc" --json
280
+ media-gen job download --provider google --job-id "operations/abc" --output ./video.mp4
281
+ ```
282
+
283
+ ## Troubleshooting
284
+
285
+ | Error | Fix |
286
+ |-------|-----|
287
+ | `PROVIDER_NOT_CONFIGURED` | Set the API key in `~/.media-gen/.env` or project `.env` |
288
+ | `CAPABILITY_NOT_SUPPORTED` | Use a different provider. Run `providers list --capability <cap>` |
289
+ | `FILE_ALREADY_EXISTS` | Add `--overwrite` or use a different output path |
290
+ | `EXTERNAL_OUTPUT_BLOCKED` | Add `--allow-external-output` for paths outside project |
291
+
292
+ Add `--debug` to any command for verbose logging.
293
+
294
+ ## License
295
+
296
+ MIT - Francis Hor