Composio's Universal CLI just launched on Product Hunt and it's blowing up. The concept is simple: connect your AI agents to 500+ tools from the command line. Developers love it.
But I thought — what if we take this further? What if your CLI could not just orchestrate tools, but generate images, videos, and audio — all from your terminal?
So I built it. In 10 minutes. Using NexaAPI.
What I Built
A Universal AI CLI that does:
# Generate an image
python ai_cli.py image "a futuristic city at sunset"
# ✅ Image saved to output.png — Cost: $0.003
# Convert text to speech
python ai_cli.py audio "Hello, this is your AI assistant" --voice nova
# ✅ Audio saved to output.mp3
# Generate a short video
python ai_cli.py video "a cat playing piano in a jazz club"
# ✅ Video saved to output.mp4
Why NexaAPI?
I tried a few options. Here's what I found:
| API | Image Cost | Models | Single Key? |
|---|---|---|---|
| NexaAPI | $0.003 | 50+ | ✅ |
| OpenAI DALL-E 3 | $0.04 | 2 | ✅ |
| Replicate | $0.003+ | 100+ | ✅ |
| fal.ai | $0.003+ | 50+ | ✅ |
NexaAPI wins on simplicity: one API key for images, video, AND audio. Available on RapidAPI — subscribe in seconds.
The Code (Python)
# pip install nexaapi
import argparse
from nexaapi import NexaAPI
client = NexaAPI(api_key='YOUR_RAPIDAPI_KEY')
def generate_image(prompt, output='output.png', model='flux-schnell'):
result = client.image.generate(model=model, prompt=prompt)
with open(output, 'wb') as f:
f.write(result.image_data)
print(f'✅ Image saved to {output} — Cost: $0.003')
def generate_audio(text, output='output.mp3', voice='alloy'):
result = client.audio.tts(text=text, voice=voice)
with open(output, 'wb') as f:
f.write(result.audio_data)
print(f'✅ Audio saved to {output}')
def generate_video(prompt, output='output.mp4'):
result = client.video.generate(model='kling-v1', prompt=prompt)
with open(output, 'wb') as f:
f.write(result.video_data)
print(f'✅ Video saved to {output}')
def main():
parser = argparse.ArgumentParser(description='Universal AI CLI — https://nexa-api.com')
subparsers = parser.add_subparsers(dest='command')
img = subparsers.add_parser('image')
img.add_argument('prompt')
img.add_argument('--output', default='output.png')
img.add_argument('--model', default='flux-schnell')
audio = subparsers.add_parser('audio')
audio.add_argument('text')
audio.add_argument('--output', default='output.mp3')
audio.add_argument('--voice', default='alloy')
video = subparsers.add_parser('video')
video.add_argument('prompt')
video.add_argument('--output', default='output.mp4')
args = parser.parse_args()
if args.command == 'image':
generate_image(args.prompt, args.output, args.model)
elif args.command == 'audio':
generate_audio(args.text, args.output, args.voice)
elif args.command == 'video':
generate_video(args.prompt, args.output)
if __name__ == '__main__':
main()
The Code (JavaScript/Node.js)
// npm install nexaapi commander
import NexaAPI from 'nexaapi';
import { writeFileSync } from 'fs';
import { program } from 'commander';
const client = new NexaAPI({ apiKey: process.env.NEXAAPI_KEY });
program.command('image <prompt>')
.option('-o, --output <file>', 'Output file', 'output.png')
.option('-m, --model <model>', 'Model', 'flux-schnell')
.action(async (prompt, opts) => {
const result = await client.image.generate({ model: opts.model, prompt });
writeFileSync(opts.output, result.imageData);
console.log(`✅ Image saved to ${opts.output} — Cost: $0.003`);
});
program.command('audio <text>')
.option('-o, --output <file>', 'Output file', 'output.mp3')
.option('-v, --voice <voice>', 'Voice', 'alloy')
.action(async (text, opts) => {
const result = await client.audio.tts({ text, voice: opts.voice });
writeFileSync(opts.output, result.audioData);
console.log(`✅ Audio saved to ${opts.output}`);
});
program.command('video <prompt>')
.option('-o, --output <file>', 'Output file', 'output.mp4')
.action(async (prompt, opts) => {
const result = await client.video.generate({ model: 'kling-v1', prompt });
writeFileSync(opts.output, result.videoData);
console.log(`✅ Video saved to ${opts.output}`);
});
program.parse();
Real-World Use Cases I've Found
1. CI/CD thumbnails — auto-generate blog post thumbnails on every publish
2. Batch product images — generate 100 product variations overnight
3. Podcast production — convert blog posts to audio automatically
4. Game asset generation — generate sprites and backgrounds from prompts
Get Started
- 🔑 Get your API key: rapidapi.com/user/nexaquency
- 📦 Install:
pip install nexaapiornpm install nexaapi - 🚀 Clone the repo and start building
Links:
- Website: nexa-api.com
- Python SDK: pypi.org/project/nexaapi
- Node.js SDK: npmjs.com/package/nexaapi
- Full tutorial: nexa-api.com/blog
The CLI + AI trend is just getting started. Composio showed us developers want AI in their terminals — let's build the tools that make it happen.
What would you build with a Universal AI CLI? Drop a comment below 👇
Top comments (0)