Tutorial•CLI•Python•March 2026
I Built a Universal AI CLI Tool in 10 Minutes (Inspired by Composio's Product Hunt Launch)
Composio Universal CLIis blowing up on Product Hunt — developers want AI in their terminals. Here's how to build your own AI CLI tool that generates images, videos & audio from your terminal using NexaAPI at $0.003/image.
March 27, 2026•NexaAPI Team•10 min read
⚡ TL;DR
- • Composio Universal CLI is trending on Product Hunt — AI in the terminal is hot
- • Build your own AI CLI in 10 minutes with
pip install nexaapi click - • Generate images ($0.003), audio, and video from your terminal
- • Full Python source code included
- • Free tier: rapidapi.com/user/nexaquency
Why CLI + AI Is the New Hotness
The trend is clear: developers want to control AI from the command line. Whether it's:
- 🔄 Running AI generation in CI/CD pipelines
- 📦 Batch processing images in scripts
- 🛠️ Building AI-powered developer tools
- ⚡ Integrating AI into existing terminal workflows
The command line is where developers live. And with NexaAPI, you can add AI generation to any CLI tool in minutes.
Setup
pip install nexaapi click requests export NEXAAPI_KEY="your_api_key_here" # Get free key: https://rapidapi.com/user/nexaquency
Build the Universal AI CLI
ai_cli.py
#!/usr/bin/env python3
"""
Universal AI CLI — Generate images, audio, and video from your terminal
Powered by NexaAPI ($0.003/image)
"""
import click
import os
import sys
from nexaapi import NexaAPI
client = NexaAPI(api_key=os.environ.get('NEXAAPI_KEY', 'YOUR_API_KEY'))
@click.group()
def cli():
"""🤖 Universal AI CLI — AI generation from your terminal"""
pass
@cli.command()
@click.argument('prompt')
@click.option('--model', default='flux-schnell', help='Image model')
@click.option('--width', default=1024, help='Image width')
@click.option('--height', default=1024, help='Image height')
@click.option('--output', default='output.png', help='Output file')
def image(prompt, model, width, height, output):
"""Generate an image from a text prompt"""
click.echo(f"🖼️ Generating image: {prompt[:50]}...")
result = client.image.generate(
model=model,
prompt=prompt,
width=width,
height=height
)
# Download and save
import requests
response = requests.get(result.image_url)
with open(output, 'wb') as f:
f.write(response.content)
click.echo(f"✅ Saved to {output}")
click.echo(f"💰 Cost: $0.003")
click.echo(f"🔗 URL: {result.image_url}")
@cli.command()
@click.argument('text')
@click.option('--voice', default='alloy', help='TTS voice')
@click.option('--output', default='output.mp3', help='Output file')
def tts(text, voice, output):
"""Convert text to speech"""
click.echo(f"🔊 Generating audio: {text[:50]}...")
result = client.audio.tts(text=text, voice=voice)
with open(output, 'wb') as f:
f.write(result.audio_data)
click.echo(f"✅ Saved to {output}")
@cli.command()
@click.argument('prompt')
@click.option('--count', default=1, help='Number of images')
@click.option('--output-dir', default='.', help='Output directory')
def batch(prompt, count, output_dir):
"""Batch generate multiple images"""
import os
os.makedirs(output_dir, exist_ok=True)
click.echo(f"🚀 Generating {count} images...")
total_cost = count * 0.003
for i in range(count):
result = client.image.generate(model='flux-schnell', prompt=prompt)
output_path = f"{output_dir}/image_{i+1:03d}.png"
import requests
response = requests.get(result.image_url)
with open(output_path, 'wb') as f:
f.write(response.content)
click.echo(f" [{i+1}/{count}] ✅ {output_path}")
click.echo(f"\n💰 Total cost: ${total_cost:.3f}")
if __name__ == '__main__':
cli()Usage Examples
# Generate an image python ai_cli.py image "a futuristic city at sunset" --output city.png # Generate audio python ai_cli.py tts "Hello, this is your AI assistant" --output hello.mp3 # Batch generate 10 images python ai_cli.py batch "professional product photo" --count 10 --output-dir ./products/ # Use a different model python ai_cli.py image "portrait photo" --model flux-pro --width 512 --height 512
Why NexaAPI for CLI Tools
💰
$0.003/image
13x cheaper than DALL-E 3. Batch 1000 images for $3.
⚡
50+ Models
FLUX, Stable Diffusion, Whisper, TTS — all in one API.
🔧
OpenAI Compatible
Drop-in replacement. Works with existing OpenAI code.
Build Your AI CLI Today
$0.003/image. 50+ models. Free tier available. No credit card required.