fix(image): support stream and moderation options
This commit is contained in:
@@ -287,7 +287,48 @@ else:
|
||||
raise RuntimeError(f"unexpected response: {data}")
|
||||
```
|
||||
|
||||
## 15. 图片接口常见问题
|
||||
## 15. `stream`、`partial_images`、`moderation`
|
||||
|
||||
`gpt-image-2` 的图片接口可额外尝试下面几个字段:
|
||||
|
||||
- `stream`:`true` / `false`
|
||||
- `partial_images`:整数,常见值 `1`
|
||||
- `moderation`:`auto` 或 `low`
|
||||
|
||||
示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"model": "gpt-image-2",
|
||||
"prompt": "火影忍者真人版海报",
|
||||
"size": "3840x1280",
|
||||
"quality": "high",
|
||||
"output_format": "png",
|
||||
"moderation": "low",
|
||||
"stream": true,
|
||||
"partial_images": 1
|
||||
}
|
||||
```
|
||||
|
||||
说明:
|
||||
|
||||
- `stream=true` 时,服务端可能返回 `text/event-stream`。
|
||||
- `partial_images=1` 表示在最终图之前,先推 1 张中间图。
|
||||
- `moderation` 当前只观察到 `auto` 和 `low` 两个枚举值。
|
||||
- 不是所有兼容网关都会真的返回 SSE;有些网关即使接受 `stream=true`,仍然返回普通 JSON。
|
||||
|
||||
仓库里的环境变量映射:
|
||||
|
||||
- `IMAGE_STREAM=true`
|
||||
- `IMAGE_PARTIAL_IMAGES=1`
|
||||
- `IMAGE_MODERATION=low`
|
||||
|
||||
脚本处理策略:
|
||||
|
||||
- 收到 `EventStream`:逐条解析事件,保存 `stream-events.jsonl` 和 `partials/`。
|
||||
- 没收到 `EventStream`:自动回退到同步 JSON 或异步任务轮询逻辑。
|
||||
|
||||
## 16. 图片接口常见问题
|
||||
|
||||
- 只传 `size: "16:9"` 不能保证一定是 4K;要 4K,推荐直接传 `4096x2304` 等像素尺寸。
|
||||
- `gpt-image-1` 和 `gpt-image-1.5` 不支持真正 4K,网关会自动降级。
|
||||
@@ -295,7 +336,7 @@ else:
|
||||
- 单张图可能耗时较长,客户端 `timeout` 建议至少 120 秒;4K 建议 240 秒。
|
||||
- 如果返回 `b64_json`,说明当前是同步模式,不需要再轮询 `task_id`。
|
||||
|
||||
## 16. 直连测试命令
|
||||
## 17. 直连测试命令
|
||||
|
||||
- 运行 `scripts/run_figma_direct_test.sh` 会先读取当前 `.env`,再临时清空本地代理并直连 `vip.auto-code.net`。
|
||||
- 它只强制 `IMAGE_REQUEST_STYLE=apicodex`、`IMAGE_SIZE=3840x2160` 和长超时,其余参数继续沿用 `.env` 和 `gpt_image2_generate.py` 的默认值。
|
||||
|
||||
Reference in New Issue
Block a user