ai-img
AI image generation CLI built with Bun + Bunli + AI SDK.
Install
bun add -g ai-img
Or local development:
git clone https://github.com/aryasaatvik/ai-img
cd ai-img
bun install
bun run build
Install as Agent Skill
Add to your AI agent:
npx skills add aryasaatvik/ai-img -a claude-code
npx skills add aryasaatvik/ai-img -a opencode
npx skills add aryasaatvik/ai-img
Or install locally:
npx skills add ./skills/ai-image-gen
See skills/ai-image-gen for full skill documentation.
Commands
ai-img generate -p "a cat wearing sunglasses" -o cat.png
ai-img edit -p "make it blue" -i input.png -o output.png
ai-img batch -i jobs.jsonl -o ./output
ai-img status
ai-img generate -p "a cat wearing sunglasses" --image-mode on
ai-img edit -p "make it blue" -i input.png --image-mode on
ai-img status --image-mode on
ai-img config init
ai-img config init --target project
ai-img config show
ai-img config set aiImg.defaults.provider openai
ai-img config set aiImg.preview.mode auto
ai-img config unset aiImg.defaults.provider
ai-img completions bash
ai-img completions zsh
ai-img completions fish
Shell Completions
The completions plugin adds a completions command for Bash/Zsh/Fish.
Quick install patterns:
source <(ai-img completions bash)
mkdir -p ~/.zsh/completions
ai-img completions zsh > ~/.zsh/completions/_ai-img
ai-img completions fish > ~/.config/fish/completions/ai-img.fish
Providers
Supported providers: openai, google, fal.
Credential resolution order is:
- Environment variables
- Config secrets (
aiImg.secrets.<provider>)
Environment variable names:
- OpenAI:
OPENAI_API_KEY
- Google:
GOOGLE_API_KEY, GEMINI_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY
- Fal:
FAL_API_KEY
Runtime Config
Config is loaded from these sources (deep merged, later overrides earlier):
~/.config/ai-img/config.json
.ai-imgrc
.ai-imgrc.json
.ai-imgrc.local.json
Runtime precedence is:
- CLI flags
- Project config
- User config
- Built-in defaults
config init/set/unset defaults to --target user. Use --target project to write local project config.
For preview mode specifically, precedence is:
--image-mode flag
aiImg.preview.mode config
- default
auto
Config Schema
{
"aiImg": {
"schemaVersion": 1,
"defaults": {
"provider": "openai",
"model": "gpt-image-1.5",
"size": "1024x1024",
"output": "output.png",
"outDir": "./output"
},
"generate": {
"quality": "auto",
"count": 1
},
"edit": {
"count": 1
},
"batch": {
"concurrency": 5,
"maxAttempts": 3
},
"preview": {
"mode": "auto",
"protocol": "auto",
"width": 32
},
"secrets": {
"openai": "...",
"google": "...",
"fal": "..."
}
}
}
Terminal Preview Notes
- Preview mode values:
off, auto, on
auto is best-effort and non-fatal when rendering is unavailable
on is strict and fails fast before provider API calls when preview is unsupported
- Default thumbnail width is
32 columns; only width is set so aspect ratio is preserved
- Current protocol support is Kitty-compatible terminals (for example Kitty, Ghostty)
aiImg.schemaVersion defaults to 1 during config load when omitted
IDE Autocomplete via JSON Schema
The config schema is generated from Zod and published as ai-img.schema.json.
Generate/update it:
bun run generate:schema
Check for drift:
bun run generate:schema:check
Use it in your config file:
{
"$schema": "./ai-img.schema.json",
"aiImg": {
"schemaVersion": 1
}
}
Scripts
bun run dev
bun run build
bun run typecheck
bun run generate:schema
bun run generate:schema:check