Files
image-generator/README.md
2026-03-28 21:08:17 +08:00

114 lines
2.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 图片生成器
MiniMax 文生图工具,基于 `image-01` 模型。
**访问:** `http://域名或IP:8195`
---
## 部署
### 环境要求
- Node.js >= 18
- npm
### 一键部署
```bash
# 克隆 + 安装依赖 + 启动
git clone https://gitea.zwbcc.cn/zwbpc/image-generator.git /home/zwbpc/image-generator \
&& cd /home/zwbpc/image-generator \
&& npm i -g express node-fetch \
&& chmod +x start.sh \
&& ./start.sh
```
### 配置开机自启(可选)
```bash
# 创建 service 文件
mkdir -p ~/.config/systemd/user
cat > ~/.config/systemd/user/image-generator.service << 'EOF'
[Unit]
Description=MiniMax Image Generator
After=network.target
[Service]
Type=simple
WorkingDirectory=/home/zwbpc/image-generator
ExecStart=/home/zwbpc/image-generator/start.sh
Restart=on-failure
[Install]
WantedBy=default.target
EOF
# 启用并启动
systemctl --user daemon-reload
systemctl --user enable --now image-generator.service
```
**重启服务:** `systemctl --user restart image-generator.service`
---
## 配置
首次使用需填写 API Key
1. 访问页面右上角 **⚙️ 设置**
2. 填入 MiniMax API Key格式`eyJhbGciOiJIUzI1NiIsInR...`
3. API 地址默认 `https://api.minimaxi.com`,无需修改
4. 保存
> 获取地址https://platform.minimaxi.com/user-center/payment/token-plan
---
## 项目结构
```
image-generator/
├── index.html # HTML 页面
├── style.css # 样式(深色主题)
├── ui.js # 前端交互逻辑
├── app.js # 服务端Express
├── start.sh # 启动脚本
├── config.json # API Key 存储(不提交,自动生成)
└── CHANGELOG.md
```
---
## API 接口
| 方法 | 路径 | 说明 |
|------|------|------|
| `POST` | `/api/generate` | 生成图片 |
| `GET` | `/api/config` | 获取配置(不含 Key |
| `POST` | `/api/config` | 保存配置 |
### 生成参数
| 参数 | 默认 | 说明 |
|------|------|------|
| `model` | `image-01` | 模型,目前仅支持 `image-01` |
| `prompt` | 必填 | 图片描述,最多 1500 字符 |
| `aspect_ratio` | `16:9` | `1:1` `16:9` `4:3` `3:2` `2:3` `3:4` `9:16` `21:9` |
| `response_format` | `url` | `url`24h有效`base64` |
| `n` | `1` | 数量 1-9 |
| `seed` | 随机 | 整数,用于复现 |
| `width` / `height` | — | 自定义分辨率 512-20488的倍数 |
### 常见错误
| 错误码 | 说明 |
|--------|------|
| 1002 | 限流,稍后重试 |
| 1004 | API Key 错误 |
| 1008 | 余额不足 |
| 1026 | 内容含敏感词,修改 Prompt |
| 2049 | 无效的 API Key |