Files
image-generator/README.md

103 lines
2.5 KiB
Markdown
Raw 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 文生图工具,访问 `http://域名或IP:8195`
---
## 一键部署
```bash
# SSH 登录目标机器后,一键运行:
bash <(curl -fsSL https://gitea.zwbcc.cn/zwbpc/image-generator/raw/branch/master/start.sh)
```
或手动部署:
```bash
# 1. 安装依赖
npm i -g express node-fetch
# 2. 下载项目(到 /home/zwbpc/image-generator 或其他目录)
git clone https://gitea.zwbcc.cn/zwbpc/image-generator.git
cd image-generator
# 3. 启动
chmod +x start.sh
./start.sh
# 4. 配置开机自启(可选)
# 创建 service~/.config/systemd/user/image-generator.service
# 内容见下方「Systemd」小节
systemctl --user daemon-reload
systemctl --user enable --now image-generator.service
```
**访问:** `http://域名或IP:8195`
**配置 API Key** 页面右上角 ⚙️ → 填入 MiniMax Key → 保存
---
## Systemd Service可选
```ini
# ~/.config/systemd/user/image-generator.service
[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
```
```bash
systemctl --user daemon-reload
systemctl --user enable --now image-generator.service
```
---
## 项目结构
```
image-generator/
├── index.html # 前端
├── style.css # 样式
├── app.js # 服务端Express
├── start.sh # 启动脚本
├── config.json # API Key 存储(自动生成)
└── CHANGELOG.md
```
---
## API 端点
| 方法 | 路径 | 说明 |
|------|------|------|
| `POST` | `/api/generate` | 生成图片 |
| `GET` | `/api/config` | 获取配置 |
| `POST` | `/api/config` | 保存配置 |
**生成参数:**
| 参数 | 默认值 | 说明 |
|------|--------|------|
| `model` | `image-01` | `image-01``image-01-live` |
| `prompt` | — | 图片描述(必填) |
| `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的倍数 |
| `style.style_type` | — | 画风:`漫画` `元气` `中世纪` `水彩`(仅 live |
| `style.style_weight` | 0.8 | 画风权重 0.1-1.0(仅 live |
**常见错误码:** `1002`限流 `1004`鉴权失败 `1008`余额不足 `1026`敏感词 `2049`无效Key