Agent Media
Agent Media is an agent-first media toolkit that provides CLI-accessible commands for image, video, and audio processing. All commands produce deterministic, machine-readable JSON output.
Available Commands
Image Commands
npx agent-media@latest image resize - Resize an image
npx agent-media@latest image convert - Convert image format
npx agent-media@latest image generate - Generate image from text
npx agent-media@latest image edit - Edit one or more images with text prompt
npx agent-media@latest image remove-background - Remove image background
npx agent-media@latest image upscale - Upscale image with AI super-resolution
npx agent-media@latest image extend - Extend image canvas with padding
npx agent-media@latest image crop - Crop image to dimensions around focal point
Audio Commands
npx agent-media@latest audio extract - Extract audio from video
npx agent-media@latest audio transcribe - Transcribe audio to text
Video Commands
npx agent-media@latest video generate - Generate video from text or image
Output Format
All commands return JSON to stdout:
{
"ok": true,
"media_type": "image",
"action": "resize",
"provider": "local",
"output_path": "output_123.webp",
"mime": "image/webp",
"bytes": 12345
}
On error:
{
"ok": false,
"error": {
"code": "INVALID_INPUT",
"message": "input file not found"
}
}
Providers
- local - Default provider using Sharp (resize, convert, extend, crop) and Transformers.js (remove-background, upscale, transcribe)
- fal - fal.ai provider (generate, edit, remove-background, upscale, transcribe, video)
- replicate - Replicate API (generate, edit, remove-background, upscale, transcribe, video)
- runpod - Runpod API (generate, edit, video)
- ai-gateway - Vercel AI Gateway (generate, edit)
Provider Selection
- Explicit:
--provider <name>
- Auto-detect from environment variables
- Fallback to local provider
Environment Variables
AGENT_MEDIA_DIR - Custom output directory
FAL_API_KEY - Enable fal provider
REPLICATE_API_TOKEN - Enable replicate provider
RUNPOD_API_KEY - Enable runpod provider
AI_GATEWAY_API_KEY - Enable ai-gateway provider
1---2name: agent-media3description: Agent-first media toolkit for image, video, and audio processing. Use when you need to resize, convert, generate, edit, upscale images, remove backgrounds, extend or crop canvases, extract audio, transcribe speech, or generate videos. All commands return deterministic JSON output.4---56# Agent Media78Agent Media is an agent-first media toolkit that provides CLI-accessible commands for image, video, and audio processing. All commands produce deterministic, machine-readable JSON output.910## Available Commands1112### Image Commands13- `npx agent-media@latest image resize` - Resize an image14- `npx agent-media@latest image convert` - Convert image format15- `npx agent-media@latest image generate` - Generate image from text16- `npx agent-media@latest image edit` - Edit one or more images with text prompt17- `npx agent-media@latest image remove-background` - Remove image background18- `npx agent-media@latest image upscale` - Upscale image with AI super-resolution19- `npx agent-media@latest image extend` - Extend image canvas with padding20- `npx agent-media@latest image crop` - Crop image to dimensions around focal point2122### Audio Commands23- `npx agent-media@latest audio extract` - Extract audio from video24- `npx agent-media@latest audio transcribe` - Transcribe audio to text2526### Video Commands27- `npx agent-media@latest video generate` - Generate video from text or image2829## Output Format3031All commands return JSON to stdout:3233```json34{35 "ok": true,36 "media_type": "image",37 "action": "resize",38 "provider": "local",39 "output_path": "output_123.webp",40 "mime": "image/webp",41 "bytes": 1234542}43```4445On error:4647```json48{49 "ok": false,50 "error": {51 "code": "INVALID_INPUT",52 "message": "input file not found"53 }54}55```5657## Providers5859- **local** - Default provider using Sharp (resize, convert, extend, crop) and Transformers.js (remove-background, upscale, transcribe)60- **fal** - fal.ai provider (generate, edit, remove-background, upscale, transcribe, video)61- **replicate** - Replicate API (generate, edit, remove-background, upscale, transcribe, video)62- **runpod** - Runpod API (generate, edit, video)63- **ai-gateway** - Vercel AI Gateway (generate, edit)6465## Provider Selection66671. Explicit: `--provider <name>`682. Auto-detect from environment variables693. Fallback to local provider7071## Environment Variables7273- `AGENT_MEDIA_DIR` - Custom output directory74- `FAL_API_KEY` - Enable fal provider75- `REPLICATE_API_TOKEN` - Enable replicate provider76- `RUNPOD_API_KEY` - Enable runpod provider77- `AI_GATEWAY_API_KEY` - Enable ai-gateway provider