
2025/12/26
2 分钟阅读
Nano Banana 图像生成 API 指南
通过 Ruxa AI 使用 Google Nano Banana(Gemini 2.5 Flash Image)API 生成图像的完整指南。
Nano Banana 概述
Nano Banana 是基于 Google Gemini 2.5 Flash Image 的图像生成模型。它提供快速、高质量的文生图能力,支持多种宽高比和输出格式。
可用模型
| 模型 | 描述 | 特点 |
|---|---|---|
google/nano-banana |
标准文生图 | 快速生成,多种宽高比 |
google/nano-banana-pro |
高级版本 | 更高分辨率(1k/2k/4k),支持图像编辑 |
基础文生图
使用 Nano Banana 生成图像:
curl --request POST \
--url https://api.ruxa.ai/api/v1/tasks/create \
--header 'Authorization: Bearer sk-xxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "google/nano-banana",
"input": {
"prompt": "爱因斯坦刚刚完成相对论后发布的一条超写实风格的推文。",
"output_format": "png",
"image_size": "1:1"
}
}'响应:
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_gemini-2.5-flash-image_xxxxx"
}
}使用回调 URL
生产环境推荐使用回调:
curl --request POST \
--url https://api.ruxa.ai/api/v1/tasks/create \
--header 'Authorization: Bearer sk-xxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "google/nano-banana",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "您的提示词",
"output_format": "png",
"image_size": "16:9"
}
}'Nano Banana Pro - 图像编辑
使用 Pro 版本进行图像编辑:
curl --request POST \
--url https://api.ruxa.ai/api/v1/tasks/create \
--header 'Authorization: Bearer sk-xxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "google/nano-banana-pro",
"input": {
"prompt": "将这张照片变成一个摇头娃娃:头部稍微放大,保持面部准确,身体卡通化。",
"image_input": ["https://example.com/your-image.png"],
"aspect_ratio": "1:1",
"resolution": "1k",
"output_format": "png"
}
}'参数参考
Nano Banana(标准版)
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
prompt |
string | 是 | 图像描述提示词 |
output_format |
string | 否 | 输出格式:png、jpeg(默认:png) |
image_size |
string | 否 | 宽高比(默认:1:1) |
支持的宽高比:
1:1、9:16、16:9、3:4、4:3、3:2、2:3、5:4、4:5、21:9、auto
Nano Banana Pro
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
prompt |
string | 是 | 图像描述/编辑指令(最大 10000 字符) |
image_input |
array | 是 | 输入图像 URL 数组(最多 8 张) |
aspect_ratio |
string | 否 | 宽高比(默认:1:1) |
resolution |
string | 否 | 分辨率:1k、2k、4k(默认:1k) |
output_format |
string | 否 | 输出格式:png、jpg(默认:png) |
Pro 版支持的宽高比:
1:1、2:3、3:2、3:4、4:3、4:5、5:4、9:16、16:9、21:9、auto
查询任务状态
curl --request GET \
--url 'https://api.ruxa.ai/api/v1/tasks/query/{taskId}' \
--header 'Authorization: Bearer sk-xxxxxx'提示词技巧
- 具体描述 - 包含主体、风格、光线、细节
- 使用风格关键词 - "超写实"、"插画风格"、"3D渲染"
- 指定构图 - "特写"、"全景"、"俯视角度"
- 添加质量修饰词 - "高清"、"专业摄影"、"8K分辨率"
示例提示词:
"一只橘猫坐在窗台上看雨,柔和的自然光,温馨的室内场景,专业摄影风格,浅景深"
响应状态码
| 状态码 | 描述 |
|---|---|
| 200 | 成功 |
| 401 | 未授权 - API Key 无效 |
| 402 | 积分不足 |
| 404 | 未找到 |
| 422 | 验证错误 |
| 429 | 速率限制 |
| 500 | 服务器错误 |
了解更多
作者

分类
更多文章
邮件列表
加入我们的社区
订阅邮件列表,及时获取最新消息和更新


