Appearance
Banana2 / Banana Pro 对接
Banana2 与 Banana Pro 使用独立的图片包装服务,不走 api.zmoapi.cn 网关。请向知梦获取 Banana 专用对接 Key。
接入地址
应用、SDK 或 curl 直连时使用:
text
http://180.178.51.134:19073/v1鉴权:
http
Authorization: Bearer 你的 Banana 专用对接 Key如果要把服务添加到自己的 NewAPI,渠道 Base URL 填 http://180.178.51.134:19073,不要带 /v1。详见 NewAPI 渠道对接。
精确模型名
| 模型 | 输出档位 | 文生图 | 图生图 |
|---|---|---|---|
banana-pro-1k | 1K | 支持 | 支持 |
banana-pro-2k | 2K | 支持 | 支持 |
banana-pro-4k | 4K | 支持 | 支持 |
banana2-512 | 512 | 支持 | 支持 |
banana2-1k | 1K | 支持 | 支持 |
banana2-2k | 2K | 支持 | 支持 |
banana2-4k | 4K | 支持 | 支持 |
分辨率由模型名后缀决定。不要依靠请求体中的 resolution 改变档位。
查看模型
bash
curl http://180.178.51.134:19073/v1/models \
-H "Authorization: Bearer 你的 Banana 专用对接 Key"如果这里返回 401,说明 Key 不属于 Banana 服务;如果模型列表正常,再继续测试生图。
文生图
bash
curl http://180.178.51.134:19073/v1/images/generations \
-H "Authorization: Bearer 你的 Banana 专用对接 Key" \
-H "Content-Type: application/json" \
-d '{
"model": "banana-pro-2k",
"prompt": "一张高级商业广告海报,城市夜景,电影级灯光",
"aspectRatio": "16:9",
"n": 1
}'size 也可以接受 16:9,但对 Banana 更推荐使用含义明确的 aspectRatio。
图生图:公网 URL
有参考图时,仍可使用 /v1/images/generations,包装服务会自动切换为图生图:
bash
curl http://180.178.51.134:19073/v1/images/generations \
-H "Authorization: Bearer 你的 Banana 专用对接 Key" \
-H "Content-Type: application/json" \
-d '{
"model": "banana2-2k",
"prompt": "保持主体不变,改成黑白高级摄影风格",
"imageUrls": [
"https://example.com/input.png"
],
"aspectRatio": "1:1",
"n": 1
}'单图也可以写:
json
{
"model": "banana-pro-1k",
"prompt": "改成商业产品海报",
"image_url": "https://example.com/input.png"
}参考图 URL 必须能从服务器公网访问,不得要求登录,不能是本地路径,也不要使用即将过期的临时链接。
图生图:上传文件
上传本地图片时使用 /v1/images/edits 和 multipart/form-data:
bash
curl http://180.178.51.134:19073/v1/images/edits \
-H "Authorization: Bearer 你的 Banana 专用对接 Key" \
-F "model=banana-pro-2k" \
-F "prompt=保持构图不变,改成商业海报质感" \
-F "aspectRatio=16:9" \
-F "n=1" \
-F "image=@input.png"多张参考图可以重复上传:
bash
-F "image[]=@person.png" \
-F "image[]=@product.png"参数说明
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 必须使用上面列出的精确模型名 |
prompt | string | 是 | 生图或改图提示词 |
n | integer | 否 | 默认 1,服务端最大按 8 处理 |
aspectRatio | string | 否 | 推荐:1:1、16:9、9:16、4:3、3:4、3:2、2:3、5:4、4:5、21:9 |
size | string | 否 | 兼容字段,可传比例或像素尺寸;服务会转换为最接近的比例 |
image_url | string | 否 | 单张参考图 URL |
imageUrls | string[] | 否 | 多张参考图 URL |
images | array | 否 | 兼容的多图字段 |
response_format | string | 否 | 传 b64_json 时尝试返回 Base64,否则默认返回 URL |
参考图限制:
| 模型系列 | 最多参考图 | 单图上限 |
|---|---|---|
| Banana Pro | 10 张 | 10 MB |
| Banana2 | 10 张 | 30 MB |
成功与失败
成功响应:
json
{
"created": 1780000000,
"data": [
{
"url": "https://..."
}
]
}失败响应:
json
{
"error": {
"message": "上游失败原因",
"type": "invalid_request_error",
"code": "upstream_failed"
}
}请求会等待任务得到最终结果。客户端读取超时建议设为 600 秒以上;中间出现空白心跳属于正常保活,最终 JSON 仍在响应末尾。
安全说明
当前 Banana 地址使用 HTTP,只建议服务端到服务端调用。不要把专用 Key 写入网页前端、浏览器插件、公开代码或截图中。