Content

[](https://github.com/martianzhang/apimart-cli/actions/workflows/ci.yml)
[](https://go.dev/)
[](LICENSE)
[](https://github.com/martianzhang/apimart-cli/releases)
**A CLI that supports OpenAI, OpenRouter, and any OpenAI-compatible relay services.**
Not just API forwarding - intelligently adapts to each platform's proprietary API, fully covering image/video/Midjourney/AI conversation/prompt inspiration, with built-in MCP Server and Agentic Chat.
---
## Why Choose aigc-cli?
| | | |
|---|---|---|
| 🤖 | **MCP Server** | Access Claude Desktop, Cursor and other AI clients, directly generate images and videos in conversations, no need to switch tools or copy and paste. |
| 🔬 | **AIGC Detection Engine** | Offline multi-signal fusion: C2PA Content Credentials, TC260 (national standard GB 45438-2025), SynthID invisible watermark, ONNX model inference, FFT spectrum analysis, SRM noise residual, JPEG quantization detection. All run locally, no API Key required. |
| 🔌 | **Unified Entry for Multiple Providers** | Change one `base_url` to switch between OpenAI / OpenRouter / any relay, commands remain unchanged, Provider automatically adapts. |
---
## Quick Start
### Installation
Download the binary file for your platform from the [Releases page](https://github.com/martianzhang/aigc-cli/releases).
### Using OpenAI
```bash
export OPENAI_API_KEY="sk-xxx"
aigc-cli image --prompt "a cat in the starry sky"
aigc-cli chat --message "who are you?"
```
### Using OpenRouter (change environment variables, no need to change commands)
```bash
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" # Automatically use the dedicated video API
aigc-cli models --type image # Model discovery without authentication
```
### Using Any OpenAI-Compatible Relay
```bash
export OPENAI_API_KEY="sk-xxx"
export OPENAI_BASE_URL="https://your-relay.com/v1"
aigc-cli chat --message "Hello"
```
### MCP Integration (Recommended)
Add the following configuration to MCP settings in Claude Desktop / Cursor / Windsurf:
```json
{
"mcpServers": {
"aigc-cli": {
"command": "aigc-cli",
"args": ["mcp"]
}
}
}
```
AI agents can directly generate images, create videos, query models, and detect AIGC in conversations. See [docs/mcp.md](docs/mcp.md) for details.
---
## Feature List
| | Capability | Description |
|---|---|---|
| 🤖 | **MCP Server** | Built-in MCP protocol support, Claude Desktop / Cursor / Windsurf / VS Code out of the box |
| 🔬 | **AIGC Detection Engine** | C2PA / TC260 / SynthID / ONNX / FFT / SRM noise / JPEG quantization, offline running, emoji output |
| 🔌 | **Unified Entry for Multiple Providers** | Change one `base_url` to switch providers, commands remain unchanged |
| 🧠 | **Provider Automatic Adaptation** | OpenRouter automatically uses dedicated image/video API, zero configuration |
| 🎨 | **Midjourney Complete Pipeline** | 17 subcommands covering imagine → blend → describe → upscale → zoom → inpaint → video → remix, no Discord required |
| 💬 | **Agentic Chat** | Interactive REPL with built-in `generate_image` / `generate_video` / `midjourney_*` / `ideas` tools |
| 🔍 | **Prompt Inspiration Library** | Offline BM25 search engine (CJK aware + n-gram + RRF), tens of thousands of prompt datasets |
| 🔄 | **Video Task Persistence** | OpenRouter submission → polling → download full process, timeout recovery with `--job-id` |
| 🧪 | **Dry-Run & Curl** | `--dry-run` outputs equivalent curl command, zero-threshold learning and debugging API |
| ⚡ | **Go Single Binary** | `go install` one-click installation, no runtime dependencies, cross-platform |
---
## Provider Automatic Adaptation
The same `image` / `video` / `models` commands, with API paths automatically switched based on the Provider:
| Provider | Image | Video | Models |
|---|---|---|---|
| **OpenAI** | `POST /v1/images/generations` (synchronous) | — | `GET /v1/models` |
| **OpenRouter** | `POST /v1/images` (dedicated image API) or `POST /v1/responses` (Responses API) | `POST /v1/videos` asynchronous → polling → download + `--job-id` recovery | `GET /v1/images/models` / `GET /v1/videos/models` (no authentication) |
| **APIMart** | Asynchronous task submission → polling → download | Asynchronous task + VEO3 Remix (extended video) | Market API + model pricing query |
| **Cloud Mist AI** | — | `POST /v1/video/create` + `GET /v1/video/query` | — |
| **Generic Relay** | `POST /v1/images/generations` (synchronous) | — | `GET /v1/models` |
Detection logic: automatically identified based on `base_url`, or manually specified with `--mode sync` / `--mode async`.
---
## Commands
```
aigc-cli
├── image Image generation (synchronous/asynchronous/OpenRouter dedicated API/Grok Edit) → docs/guide-image.md
├── video Video generation (OpenRouter/Cloud Mist + VEO3 Remix) → docs/guide-video.md
├── midjourney Midjourney complete pipeline (17 subcommands) → docs/guide-midjourney.md
│ └── mj Alias, same as above
├── chat AI conversation / interactive REPL / Agent Loop (tool invocation) → docs/guide-chat.md
├── ideas Prompt inspiration search (keywords/random/image, supports BM25 + n-gram) → docs/guide-ideas.md
├── models Model list (OpenRouter discovery/OpenAI compatible)
│ └── --price View model pricing
├── task Query asynchronous task status (compatible with APIMart asynchronous tasks)
├── balance Query balance (compatible with APIMart balance query)
├── preview Preview generated images/videos with system default program
├── detect Detect watermark, metadata, and AIGC (multi-signal fusion + emoji) → docs/guide-detect.md
├── mcp Start MCP Server (AI agent integration) → docs/mcp.md
│
│ # Global flags
│ --dry-run Print request parameters and equivalent curl, do not call API
│ --print-config Print current effective configuration (with source annotation)
│ -v/--verbose Display detailed output: complete JSON, token usage, time consumption, cost
│ --json Pass request in JSON format (file, string, or stdin)
│ --preview Automatically open system preview after generation
│ --save-prompt Save prompt as .md file
│ --http-proxy Specify HTTP proxy
```
### Midjourney Subcommands
```
aigc-cli midjourney (or mj)
├── imagine Text-to-image / image-to-image (default entry)
├── blend Multi-image fusion (2-4 images)
├── describe Image-to-text (reverse prompt)
├── edits Image editing (rewrite entire image)
├── upscale Enlarge single image (U1-U4)
├── variation Micro-variation (V1-V4)
├── high-variation Strong variation
├── low-variation Weak variation
├── reroll Regenerate grid
├── zoom Zoom out / outpaint
├── pan Pan (left/right/up/down)
├── inpaint Local inpainting entry (→ modal)
├── modal Submit mask + prompt to complete inpainting
├── video Image-to-video
├── remix-strong Strong remix (v8/v8.1)
├── remix-subtle Subtle remix (v8/v8.1)
└── query Query task status
```
---
## Documentation
| Document | Content |
|---|---|
| [Installation and Configuration](docs/installation.md) | Installation, API Key, configuration file, proxy |
| [Image Generation](docs/guide-image.md) | All parameters, synchronous/asynchronous mode, image-to-image, inpainting |
| [Video Generation](docs/guide-video.md) | All parameters, first and last frames, reference video (APIMart) |
| [Midjourney Generation](docs/guide-midjourney.md) | 17 subcommand complete instructions: imagine, blend, upscale, etc. |
| [AI Conversation](docs/guide-chat.md) | Interactive multi-turn REPL, streaming output, verbose statistics |
| [AIGC Detection](docs/guide-detect.md) | Multi-signal fusion, ONNX model, FFT spectrum, emoji output |
| [Prompt Inspiration](docs/guide-ideas.md) | Search AI image prompts from Image2Studio |
| [Other Commands](docs/guide-commands.md) | models, task, balance, dry-run, API reference |
| [API Reference](docs/api-reference.md) | Provider interface specifications, detection mechanism, strategy routing |
| [FAQ](docs/faq.md) | Installation, usage, MCP, cost, and other frequently asked questions |
| [MCP Integration](docs/mcp.md) | AI agent (Claude/Cursor) integration guide |
---
## Priority Rules
**CLI parameters > JSON input > YAML configuration > code defaults**
Proxy priority:
**`--http-proxy` parameter > `OPENAI_HTTP_PROXY` / `APIMART_HTTP_PROXY` environment variable > `HTTP_PROXY` standard environment variable**
---
## Contribution
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
---
## License
[MIT](LICENSE)
<div align="center">
<img src="wechat.jpg" width="400" alt="No extra text" />
**Welcome to follow the WeChat official account "No extra text", sharing more useful tools**
</div>