Image Generator
独立图像生成工具,支持多种 AI 图像生成 API。
特点
- ✅ 独立可执行 - 无需安装 Python 或依赖
- ✅ 跨平台 - 支持 Windows/Linux/macOS
- ✅ 多 API - 支持智谱AI、OpenAI、自定义API
- ✅ MCP 服务器 - 可集成到 Claude Code/OpenClaw
- ✅ 零依赖 - 仅使用 Python 标准库
安装
方式一:PyPI 安装(推荐)
pip install image-gen-mcp
安装后可直接使用:
# 命令行工具
image-gen -k YOUR_KEY -t "一只可爱的橘猫"
# MCP 服务器配置到 ~/.claude/settings.json
image-gen-mcp
方式二:下载可执行文件
从 Releases 下载对应平台的可执行文件。
方式三:从源码运行
git clone https://github.com/your-username/image-gen.git
cd image_gen
python3 img_gen.py -k YOUR_KEY -t "风景"
快速开始
命令行使用
# 智谱AI(默认)
image-gen -k YOUR_KEY -t "日落风景" -o ~/sunset.png
# OpenAI DALL-E
image-gen -p openai -k YOUR_KEY -m dall-e-3 -t "森林小屋"
# 自定义 API
image-gen -p custom -u https://api.example.com/v1/images -k KEY -t "山水画"
作为 MCP 服务器使用
- 编辑
~/.claude/settings.json:
{
"mcpServers": {
"image-gen": {
"command": "image-gen-mcp",
"env": {
"IMAGE_GEN_API_KEY": "your-api-key",
"IMAGE_GEN_MODEL": "cogview-3-flash"
}
}
}
}
- 重启 Claude Code,然后直接对话:
你: 生成一张赛博朋克城市的图片
命令行参数
| 参数 | 说明 | 必需 |
|---|---|---|
--provider, -p |
API 提供商 (zhipu/openai/custom) | 否 |
--api-key, -k |
API 密钥 | 是 |
--model, -m |
模型名称 | 否 |
--api-url, -u |
自定义 API 地址 | 否 |
--prompt, -t |
图片描述 | 是 |
--size, -s |
图片尺寸 | 否 |
--output, -o |
输出路径 | 否 |
支持的模型
智谱AI (zhipu)
| 模型 | 说明 |
|---|---|
cogview-3-flash |
快速生成(推荐) |
cogview-3 |
高质量生成 |
API 密钥: https://open.bigmodel.cn/usercenter/apikeys
OpenAI (openai)
| 模型 | 说明 |
|---|---|
dall-e-2 |
标准质量 |
dall-e-3 |
高质量 |
API 密钥: https://platform.openai.com/api-keys
开发
打包可执行文件
# Linux/macOS
chmod +x build.sh && ./build.sh
# Windows
build.bat
发布到 PyPI
chmod +x publish.sh && ./publish.sh
文件结构
image_gen/
├── img_gen.py # 独立可执行程序源码
├── mcp_server.py # MCP 服务器
├── build.sh # Linux/macOS 打包脚本
├── build.bat # Windows 打包脚本
├── publish.sh # PyPI 发布脚本
├── pyproject.toml # 项目配置
├── .github/workflows/ # CI/CD 配置
├── README.md # 本文档
└── LICENSE # MIT 许可证
技术实现
- 仅用标准库 -
urllib,json,pathlib,argparse - PyInstaller 打包 - 单文件可执行
- MCP 协议 - 与 LLM 集成
许可证
Metadata
Release files for lyf-image-gen 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| lyf_image_gen-1.0.2.tar.gz | 7.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lyf_image_gen-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.4 kB
Release files / lyf_image_gen-1.0.2.tar.gz
| Download URL | lyf_image_gen-1.0.2.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82504dc2972971b45608c5efe178f955350772249c906c0e94e8844f7fadfb07
|
|
BLAKE2b-256 checksum How to use checksums |
a6b6c2b7506bb2b8f900d653817c2e93f69600e7ff9072ae290d8e678efc30e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / lyf_image_gen-1.0.2-py3-none-any.whl
| Download URL | lyf_image_gen-1.0.2-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8cabfefd28d149767e35d13bde0d02ef9d5114e5768ff680c2bdfb511a7ff4bc
|
|
BLAKE2b-256 checksum How to use checksums |
560804a5f571d63e3a9ccedd1bf0b07bde1583b2d68440d2243ca948a214eca8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for lyf-image-gen 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.