aigc-cli:终端原生的多厂商 AIGC 工具包,内置 MCP Server
martianzhang/aigc-cli
martianzhang/aigc-cli 是一款终端原生的 AIGC 工具包,支持 OpenAI、OpenRouter、Anthropic、Ollama 等兼容接口,可生成图像、视频、音频并运行 Midjourney 全流程。
Terminal-native AIGC toolkit: multi-provider image/video/audio generation, Midjourney, chat, AIGC forensics, knowledge base, MCP Server.
Generate, detect, and manage AI content from the terminal. Supports OpenAI, OpenRouter, Anthropic, Ollama and any compatible relay — with local offline models for AIGC detection, OCR, background removal, and knowledge base.
Why aigc-cli?
| 🤖 | MCP Server | Built-in MCP Server for Claude Desktop, Cursor, Windsurf: 30 tools, 4 workflow prompts, 4 read-only resources, full MCP annotations. AI agents can generate images/videos/music, run Midjourney, OCR, search KB, detect AIGC, query pricing — all in conversation. The provider argument only accepts names from your config.yaml whitelist; no base_url/api_key can ever be passed remotely. |
| 🔬 | AIGC Forensics | Offline multi-signal fusion: C2PA, TC260 (GB 45438-2025), SynthID, ONNX classifier, FFT spectrum, SRM noise, JPEG quantization. Zero API key needed. |
| 🔌 | Multi-Protocol | Not just OpenAI — supports Anthropic Messages API, Ollama, local ONNX models alongside OpenAI-compatible endpoints. |
| 🧠 | Provider Auto-Adapt | Each provider gets the correct API routing automatically (OpenRouter dedicated image/video API, APIMart async tasks, etc.) |
| 🎨 | Midjourney Pipeline | 17 subcommands: imagine → blend → describe → upscale → zoom → inpaint → video → remix. No Discord required. |
| 💬 | Agentic Chat | Interactive REPL with built-in tools: generate_image, generate_video, midjourney_*, ideas, kb_*, detect_image, recognize_text. |
| 🔍 | Prompt Ideas | Offline BM25 search (CJK-aware + n-gram + RRF) plus 4 keyless online prompt libraries, fused with RRF; 10K+ prompt dataset. |
| 🔊 | Local TTS / ASR | sherpa-onnx offline speech (kokoro 53 voices, EN/ZH/JA/KR/FR) and recognition (SenseVoice). No internet. |
| 🔄 | Video Job Persistence | OpenRouter submit → poll → download pipeline. --job-id resume after timeout. |
| 🧪 | Dry-Run & Curl | --dry-run prints the equivalent curl command for any API call. Learn and debug without cost. |
| ⚡ | Go Binary | go install one command. No runtime deps. Cross-platform. |
| 📚 | Knowledge Base | FTS5 + pluggable semantic search (ONNX / Ollama / OpenAI-compatible embeddings), age-encrypted vault, web search auto-import, MCP/Chat tools. |
| 👁️ | OCR & Vision | Offline DBNet+CRNN text recognition. Image captioning via local EXIF or online vision LLM. |
| 🖼️ | Background Removal | RMBG 2.0 semantic segmentation. Pure local ONNX, no API key. |
| 📏 | Depth Map | depth: local Depth Anything V2 ONNX → grayscale depth map (image or video) for depth-guided image-to-video. |
| 🔎 | Image Upscale | upscale: local Real-ESRGAN / Real-CUGAN / Swin2SR ONNX super-resolution (2x/4x), offline, tiled. |
Quick Start
Installation
Download the binary for your platform from the Releases page.
Using OpenAI
export OPENAI_API_KEY="sk-xxx" aigc-cli image --prompt "a cat under the stars" aigc-cli chat --message "Hello, who are you?"
Using OpenRouter (change env vars, commands stay the same)
export OPENAI_API_KEY="sk-or-xxx" export OPENAI_BASE_URL="https://openrouter.ai/api/v1" aigc-cli image --model "openai/gpt-image-2" --prompt "a cat" aigc-cli video --model "google/veo-3.1" --prompt "a dog running" # auto-routes to dedicated video API aigc-cli models --type image # authentication-free model discovery
Using any OpenAI-Compatible Relay
export OPENAI_API_KEY="sk-xxx" export OPENAI_BASE_URL="https://your-relay.com/v1" aigc-cli chat --message "Hello"
MCP Integration (Recommended)
Add to your MCP config in Claude Desktop / Cursor / Windsurf:
{
"mcpServers": {
"aigc-cli": {
"command": "aigc-cli",
"args": ["mcp"]
}
}
}AI agents can generate images/videos/music, run Midjourney, OCR, search the idea library or knowledge base, query model pricing, and detect AIGC directly in conversation — via 30 tools, 4 workflow prompts, and 4 read-only resources (all tools carry MCP annotations). The per-call provider argument is restricted to a whitelist of names from config.providers; no tool accepts base_url or api_key. See docs/en/guide-mcp.md.
Feature Overview
| Capability | Description | |
|---|---|---|
| 🤖 | MCP Server | Built-in MCP protocol support with 30 tools, 4 workflow prompts, 4 read-only resources and MCP annotations; works out of the box with Claude Desktop / Cursor / Windsurf / VS Code |
| 🔬 | AIGC Detection Engine | C2PA / TC260 / SynthID / ONNX / FFT / SRM noise / JPEG quantization, offline, emoji output |
| 🔌 | Multi-Provider Unified Entry | Change one base_url to switch providers, commands unchanged |
| 🧠 | Provider Auto-Adapt | OpenRouter automatically routes to dedicated image/video APIs, zero config |
| 🎨 | Complete Midjourney Pipeline | 17 subcommands covering imagine → blend → describe → upscale → zoom → inpaint → video → remix, no Discord needed |
| 🎵 | AI Music Generation | Natural-language music: APIMart (suno / flowmusic, async submit → poll → download), OpenRouter (Lyria-3, sync streaming), Alibaba Cloud Bailian (Fun-Music, sync) |
| 💬 | Agentic Chat | Interactive REPL with built-in generate_image / generate_video / midjourney_* / ideas / kb_* tools |
| 🔍 | Prompt Idea Library | Offline BM25 search engine (CJK-aware + n-gram + RRF), 10K+ prompt dataset, plus aipromptslibrary / prompts.chat / openart / civitai via --source |
| 🔊 | Local TTS / ASR | sherpa-onnx offline speech synthesis (kokoro, 53 voices, EN/ZH/JA/KR/FR) and speech recognition (SenseVoice, best for Chinese), no internet needed |
| 📏 | Depth Map | depth: local Depth Anything V2 ONNX → grayscale depth map (image or video) for depth-guided image-to-video |
| 🔎 | Image Upscale | upscale: local Real-ESRGAN / Real-CUGAN / Swin2SR ONNX super-resolution (2x/4x), offline, feathered tiles |
| 🔄 | Video Job Persistence | OpenRouter submit → poll → download full pipeline, --job-id one-key resume after timeout |
| 🧪 | Dry-Run & Curl | --dry-run prints equivalent curl commands, zero-friction API learning and debugging |
| ⚡ | Go Single Binary | go install one-command install, no runtime dependencies, cross-platform |
| 📚 | Local Knowledge Base | FTS5 + pluggable semantic search (ONNX / Ollama / OpenAI-compatible embeddings), age-encrypted vault, web search auto-import, MCP/Chat tool integration |
| 🧮 | Decision Models | Run typed decisions (choice / yes-no / rating) locally with Ollama (tev1/nimble) or remotely via OpenRouter Jev — question banks, calibrated probabilities, multimodal image decisions (Clef / Clef-Flash, auto-resized), zero cost offline |
Provider Auto-Adaptation
The same image / video / audio / music / models command automatically uses the correct API path based on the provider:
| Provider | Image | Video | Audio | Music | Models |
|---|---|---|---|---|---|
| OpenAI | POST /v1/images/generations (sync) |
— | POST /v1/audio/speech + POST /v1/audio/transcriptions |
— | GET /v1/models |
| OpenRouter | POST /api/v1/images (dedicated image API) |
POST /api/v1/videos async → poll → download + --job-id resume |
POST /api/v1/audio/speech + POST /api/v1/audio/transcriptions (10+ TTS model aggregation) |
POST /api/v1/chat/completions (modalities: text+audio) sync streaming — Lyria-3 |
GET /api/v1/images/models / GET /api/v1/videos/models (auth-free) |
| APIMart | Async task submit → poll → download | Async task + VEO3 Remix (extend video) | POST /v1/audio/speech + POST /v1/audio/transcriptions |
POST /v1/music/generations async → poll (GET /v1/music/tasks/{id}) — suno / flowmusic |
Marketplace API + model pricing query |
| Alibaba Cloud Bailian | — | — | — | POST /api/v1/services/audio/music/generation sync (DashScope native) — fun-music-v1 / fun-music-preview |
— |
| Agnes AI | POST /v1/images/generations (sync, pixel size) |
POST /v1/videos async → poll → download (text/keyframe/reference, 720P) |
❌ Not yet available | — | GET /v1/models |
| ZeekAI | POST /v1/images/generations for text-to-image, POST /v1/images/edits for image-to-image (auto-detected) |
— | — | — | GET /v1/models |
| OpenLux | POST /v1/images/generations (sync) |
POST /v1/video/create + GET /v1/video/query |
❌ Not yet available | — | GET /v1/models |
| Pollinations | POST /v1/images/generations (sync; pass --quality) |
GET /video/{prompt} at the root (sync MP4) |
POST /v1/audio/speech + POST /v1/audio/transcriptions (per-model pricing; paidOnly needs paid Pollen) |
— | GET /v1/models (auth-free) |
| Ollama / Local | POST /v1/images/generations (experimental, no API Key) |
❌ | Via LocalAI/openedai-speech etc. | — | GET /v1/models |
| Anthropic | — | — | POST /v1/messages (via Anthropic-compatible relay) |
— | — |
| Generic Relay | POST /v1/images/generations (sync) |
— | POST /v1/audio/speech (passthrough) |
— | GET /v1/models |
Bailian (阿里云百炼) currently has a dedicated route for
musiconly — Fun-Music uses the DashScope native services endpoint, which differs from thecompatible-modepath used for chat. Image / video / audio fall through to the generic OpenAI-compatible path.
Local models/services don't need an API Key. aigc-cli auto-exempts API Key checks and skips the Authorization header. See docs/en/installation.md#local-generation.
Detection logic: auto-identifies by base_url, or manually specify with --mode sync / --mode async.
Each command can use a different provider via the providers config, see docs/en/examples/config.yaml.
Commands
aigc-cli
├── image / img Image generation (sync/async/OpenRouter dedicated API/Grok Edit) → docs/en/guide-image.md
├── video / vid Video generation (Agnes / OpenRouter / OpenLux + VEO3 Remix) → docs/en/guide-video.md
├── depth Image/video → grayscale depth map (offline ONNX, V2 models) → docs/en/guide-depth.md
├── upscale / sr Image super-resolution 2x/4x (offline ONNX: Real-ESRGAN/Real-CUGAN/Swin2SR) → docs/en/guide-upscale.md
├── audio / voice Audio: TTS and STT → docs/en/guide-audio.md
│ ├── tts / speak Text-to-speech (cloud API or local sherpa-onnx offline)
│ ├── asr / stt Speech-to-text (cloud API or local sherpa-onnx offline)
│ └── init Download local models (kokoro, sense-voice, etc.)
├── music AI music generation (APIMart suno/flowmusic async, OpenRouter Lyria sync, Bailian Fun-Music) → docs/en/guide-music.md
│ ├── generate / gen Submit a music generation task
│ └── query Query music task status and result
├── ocr Offline text recognition (DBNet + CRNN, ONNX local inference) → docs/en/guide-ocr.md
│ ├── init Download OCR models
│ └── scan Recognize text in images
│ --engine auto|pdf|ocr PDF processing mode (default: auto)
│ --preview Preview recognized text
├── background / bg AI background removal (RMBG 2.0 semantic segmentation, offline ONNX) → docs/en/guide-background.md
├── midjourney / mj → docs/en/guide-midjourney.md
│ └── mj Alias for midjourney
├── chat AI chat / Interactive REPL / Agent Loop (tool calling) → docs/en/guide-chat.md
├── ideas / idea Prompt idea search (local dataset + online libraries) → docs/en/guide-ideas.md
├── knowledgebase / kb Local knowledge base (FTS5 + semantic search, pluggable embeddings) → docs/en/guide-knowledgebase.md
├── models / model → docs/en/guide-commands.md
│ └── --price View model pricing
├── task Query async task status (APIMart compatible)
├── balance Query balance (APIMart compatible)
├── config Read/edit config.yaml (get/set/list; secrets masked & auto-encrypted) → docs/en/guide-commands.md
├── preview / pr View images / --detail metadata / --describe caption → docs/en/guide-preview.md
├── detect Detect AIGC, metadata and tampering (multi-signal fusion + emoji) → docs/en/guide-detect.md
├── decision / decide Typed decision models (System One / Jev): state + question bank → answers → docs/en/guide-decision.md
├── completion Generate shell completion scripts (bash/zsh/fish/powershell)
├── mcp Start MCP Server (AI agent integration) → docs/en/guide-mcp.md
│
│ # Global flags
│ --dry-run Print request params and equivalent curl, no API call
│ --print-config Print effective config with source annotations (secrets masked)
│ -v/--verbose Show detailed output: full JSON, token usage, timing, cost
│ --json Pass request as JSON (file, string, or stdin)
│ --preview Open system preview after generation
│ --save-prompt Save prompt as .md file
│ --http-proxy Specify HTTP proxy
│ --zdr Request zero data retention where supported (OpenRouter chat/music)
Enable Tab Completion
After installation, add one of the following lines to your shell rc file:
# Bash echo 'source <(aigc-cli completion bash)' >> ~/.bashrc # Zsh echo 'source <(aigc-cli completion zsh)' >> ~/.zshrc # Fish aigc-cli completion fish > ~/.config/fish/completions/aigc-cli.fish
After reloading your shell, typing aigc-cli im+Tab will auto-complete to aigc-cli image.
Midjourney Subcommands
aigc-cli midjourney (or mj)
├── imagine Text-to-image / Image-to-image (default entry)
├── blend Multi-image blend (2-4 images)
├── describe Image-to-text (reverse prompt)
├── edits Image editing (rewrite entire image)
├── upscale Upscale single image (U1-U4)
├── variation Mild variation (V1-V4)
├── high-variation Strong variation
├── low-variation Weak variation
├── reroll Regenerate grid
├── zoom Zoom out / out-paint
├── pan Pan (left/right/up/down)
├── inpaint Local repaint entry (→ modal)
├── modal Submit mask + prompt to complete repaint
├── video Image-to-video
├── remix-strong Strong remix (v8/v8.1)
├── remix-subtle Weak remix (v8/v8.1)
└── query Query task status
Documentation
| Document | Content |
|---|---|
| Installation & Configuration | Install, API Key, config file, proxy |
| Image Generation | All parameters, sync/async modes, image-to-image, Inpainting |
| Video Generation | All parameters, first/last frame, reference video (APIMart) |
| Music Generation | Prompt-to-music: APIMart async (suno/flowmusic), OpenRouter Lyria sync streaming, Alibaba Cloud Bailian Fun-Music sync |
| Depth Conversion | Image/video → depth map, Depth Anything V2 models, parameters |
| Image Upscaling | Local 2x/4x super-resolution, Real-ESRGAN/Real-CUGAN/Swin2SR models, parameters |
| Midjourney | 17 subcommands complete guide: imagine, blend, upscale etc. |
| AI Chat | Interactive multi-turn REPL, streaming, verbose stats |
| AIGC Detection | Multi-signal fusion, ONNX models, FFT spectrum, emoji output |
| Prompt Ideas | Local BM25 search + online libraries (aipromptslibrary, prompts.chat, openart, civitai) |
| Knowledge Base | Local KB: FTS5 + semantic search, vault, web search |
| Other Commands | models, task, balance, config, dry-run, API reference |
| API Reference | Provider API specification sources, detection, strategy routing |
| FAQ | Install, usage, MCP, pricing FAQs |
| MCP Integration | AI agent (Claude/Cursor) integration guide |
| Configuration Example | Full config file reference |
Priority Rules
CLI flags > JSON input > YAML config > Code defaults
For --json this precedence holds per key: when flags accompany --json, each flag you explicitly set overrides the matching key in the JSON body, while every key you did not touch is kept exactly as written. With --json and no flags, the body is sent verbatim.
--json also accepts JSONC: // and /* */ comments, trailing commas, and a leading UTF-8 BOM are stripped before parsing (string-literal aware, so the // in a URL is kept). Strict JSON with no comments passes through unchanged.
# JSON holds the stable params (model, loras, seed, steps, size); the prompt varies per run aigc-cli image --provider modelscope --json downloads/prompt.json --prompt "a low-angle legwear ad"
Proxy priority:
--http-proxy flag > HTTP_PROXY / HTTPS_PROXY standard env vars
Contributing
Contributions welcome! See CONTRIBUTING.md.
Legal Notice
Users must ensure their usage complies with applicable laws and regulations. The software authors assume no legal liability for any user actions.
License
来源:GitHub · github.com