|
|
|
|
@ -19,7 +19,7 @@ description: Generate images via AI text-to-image API (GPT Image / Grok). Use wh |
|
|
|
|
|------|------------|------------|------| |
|
|
|
|
| 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/{filename}` | — | |
|
|
|
|
| 图片访问 | `agent-image-t2i.py` | `GET /output/{profile_name}/{filename}` | — | |
|
|
|
|
|
|
|
|
|
## GPT 模型说明 |
|
|
|
|
|
|
|
|
|
@ -56,7 +56,8 @@ curl -X POST http://localhost:8765/images/generations \ |
|
|
|
|
"prompt": "a cute cat", |
|
|
|
|
"provider": "grok", |
|
|
|
|
"size": "1024x1024", |
|
|
|
|
"n": 1 |
|
|
|
|
"n": 1, |
|
|
|
|
"profile_name": "your-agent-name" |
|
|
|
|
}' |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
@ -70,11 +71,12 @@ curl -X POST http://localhost:8765/images/generations \ |
|
|
|
|
"provider": "gpt", |
|
|
|
|
"model": "gpt-image-2-1K", |
|
|
|
|
"size": "1536x1024", |
|
|
|
|
"n": 1 |
|
|
|
|
"n": 1, |
|
|
|
|
"profile_name": "your-agent-name" |
|
|
|
|
}' |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
生成结果中的 `url` 为图片访问地址,例如 `http://localhost:8765/output/{filename}`。 |
|
|
|
|
生成结果中的 `url` 为图片访问地址,例如 `http://localhost:8765/output/{profile_name}/{filename}`。 |
|
|
|
|
|
|
|
|
|
## 调用建议 |
|
|
|
|
|
|
|
|
|
@ -88,6 +90,7 @@ curl -X POST http://localhost:8765/images/generations \ |
|
|
|
|
|
|
|
|
|
请求体为 JSON,发送到 `POST /images/generations`: |
|
|
|
|
|
|
|
|
|
- `profile_name`:**必填**,调用方 agent 的标识(建议用 agent 名称),不填会报 422 错误;图片会保存到 `output/<profile_name>/` 目录 |
|
|
|
|
- `prompt`:必填,图片提示词 |
|
|
|
|
- `provider`:可选,`grok` 或 `gpt`,默认 `grok` |
|
|
|
|
- `model`:可选,覆盖 provider 的默认模型 |
|
|
|
|
@ -96,10 +99,10 @@ curl -X POST http://localhost:8765/images/generations \ |
|
|
|
|
|
|
|
|
|
## 输出规范 |
|
|
|
|
|
|
|
|
|
- 图片默认保存在服务端 `output/` 目录 |
|
|
|
|
- 图片保存在服务端 `output/<profile_name>/` 目录,按调用方 agent 区分 |
|
|
|
|
- 响应返回 `filename`、`url` 和文件大小 `bytes` |
|
|
|
|
- 图片通过 `GET /output/{filename}` 访问 |
|
|
|
|
- 服务启动后,响应中的相对路径 `url` 需要拼接服务地址,例如 `http://localhost:8765/output/{filename}` |
|
|
|
|
- 图片通过 `GET /output/{profile_name}/{filename}` 访问 |
|
|
|
|
- 服务启动后,响应中的相对路径 `url` 需要拼接服务地址,例如 `http://localhost:8765/output/{profile_name}/{filename}` |
|
|
|
|
|
|
|
|
|
## Prompt 技巧 |
|
|
|
|
|
|
|
|
|
|