++
This commit is contained in:
@@ -13,9 +13,10 @@ description: Generate images via AI text-to-image API (GPT Image / Grok). Use wh
|
||||
|
||||
| 能力 | 服务端文件 | HTTP 端点 | 模型 |
|
||||
|------|------------|------------|------|
|
||||
| GPT / Grok 绘图 | `agent-image-t2i.py` | `POST /images/generations` | `gpt-image-2-1K` / `gpt-image-2-2K` / `gpt-image-2-4K` / `grok-imagine-image-lite` |
|
||||
| 健康检查 | `agent-image-t2i.py` | `GET /health` | — |
|
||||
| 图片访问 | `agent-image-t2i.py` | `GET /output/{profile_name}/{filename}` | — |
|
||||
| GPT / Grok 绘图 | `main.py` | `POST /images/generations` | `gpt-image-2-1K` / `gpt-image-2-2K` / `gpt-image-2-4K` / `grok-imagine-image-lite` |
|
||||
| Agnes 绘图(文生图 / 图生图 / 多图合成) | `main.py` | `POST /agnes/images/generations` | `agnes-image-2.1-flash` |
|
||||
| 健康检查 | `main.py` | `GET /health` | — |
|
||||
| 图片访问 | `main.py` | `GET /output/{profile_name}/{filename}` | — |
|
||||
|
||||
## GPT 模型说明
|
||||
|
||||
@@ -68,6 +69,102 @@ curl -X POST http://localhost:8765/images/generations \
|
||||
|
||||
生成结果中的 `url` 为图片访问地址,例如 `http://localhost:8765/output/{profile_name}/{filename}`。
|
||||
|
||||
## Agnes Image 2.1 Flash
|
||||
|
||||
升级版图像生成模型,针对高信息密度图像和复杂构图做了优化。同时支持**文生图、图生图、多图合成**。
|
||||
|
||||
### 调用示例
|
||||
|
||||
文生图(2K, 16:9):
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:8765/agnes/images/generations \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"prompt": "a luminous floating city above a misty canyon at sunrise, cinematic realism",
|
||||
"size": "2K",
|
||||
"ratio": "16:9",
|
||||
"profile_name": "profile_name"
|
||||
}'
|
||||
```
|
||||
|
||||
图生图(传入参考图 URL 或 Data URI Base64):
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:8765/agnes/images/generations \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"prompt": "turn the scene into a rainy cyberpunk night while preserving the original composition",
|
||||
"size": "1K",
|
||||
"ratio": "16:9",
|
||||
"images": ["https://example.com/input.png"],
|
||||
"profile_name": "profile_name"
|
||||
}'
|
||||
```
|
||||
|
||||
多图合成(`images` 传多张):
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:8765/agnes/images/generations \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"prompt": "combine the two characters into an intense fantasy battle scene, dynamic lighting",
|
||||
"size": "1K",
|
||||
"ratio": "16:9",
|
||||
"images": [
|
||||
"https://example.com/character-1.png",
|
||||
"https://example.com/character-2.png"
|
||||
],
|
||||
"profile_name": "profile_name"
|
||||
}'
|
||||
```
|
||||
|
||||
响应示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"model": "agnes-image-2.1-flash",
|
||||
"size": "2624x1472",
|
||||
"ratio": "16:9",
|
||||
"images": [
|
||||
{"filename": "agnes-image-2.1-flash-xxxx.png", "url": "/output/profile_name/agnes-image-2.1-flash-xxxx.png", "bytes": 1234567}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
返回的 `size` 是根据 `size` 档位 + `ratio` 解析出的实际像素尺寸,便于拼接访问地址。
|
||||
|
||||
### 请求参数
|
||||
|
||||
请求体为 JSON,发送到 `POST /agnes/images/generations`:
|
||||
|
||||
- `profile_name`:**必填**,调用方 agent 的标识,图片会保存到 `output/<profile_name>/`
|
||||
- `prompt`:必填,文本提示词
|
||||
- `size`:可选,尺寸档位 `1K` / `2K` / `3K` / `4K`,或精确尺寸如 `1024x1024`;默认 `1K`
|
||||
- `ratio`:可选,宽高比,与 `size` 档位配合使用;支持 `1:1` / `3:4` / `4:3` / `16:9` / `9:16` / `2:3` / `3:2` / `21:9`;默认 `1:1`
|
||||
- `images`:可选,图生图或多图合成的输入图像 URL 或 Data URI Base64 列表
|
||||
|
||||
### 输出尺寸参考
|
||||
|
||||
| Ratio | 1K | 2K | 3K | 4K |
|
||||
|--------|-------------|-------------|-------------|-------------|
|
||||
| `1:1` | `1024x1024` | `2048x2048` | `3072x3072` | `4096x4096` |
|
||||
| `3:4` | `864x1152` | `1728x2304` | `2592x3456` | `3456x4608` |
|
||||
| `4:3` | `1152x864` | `2304x1728` | `3456x2592` | `4608x3456` |
|
||||
| `16:9` | `1312x736` | `2624x1472` | `3936x2208` | `5248x2944` |
|
||||
| `9:16` | `736x1312` | `1472x2624` | `2208x3936` | `2944x5248` |
|
||||
| `2:3` | `832x1248` | `1664x2496` | `2496x3744` | `3328x4992` |
|
||||
| `3:2` | `1248x832` | `2496x1664` | `3744x2496` | `4992x3328` |
|
||||
| `21:9` | `1568x672` | `3136x1344` | `4704x2016` | `6272x2688` |
|
||||
|
||||
### 使用注意
|
||||
|
||||
- 需要服务端配置 `AGNES_API_KEY`(默认走 `https://apihub.agnes-ai.com/v1`,可用 `AGNES_API_BASE_URL` 覆盖)
|
||||
- 单次上游请求超时为 360 秒,建议客户端超时 ≥ 60s
|
||||
- 上游请求遇到网络错误或 408/429/500/502/503/504 时,最多自动重试 3 次,并使用指数退避
|
||||
- 图生图 / 多图合成的参考图必须是可公开访问的 HTTPS URL,否则请用 Data URI Base64
|
||||
- 当前定价:免费(`$0 / 张`)
|
||||
|
||||
## 调用建议
|
||||
|
||||
- **优先用 Grok**:稳定出图,适合日常使用
|
||||
|
||||
Reference in New Issue
Block a user