Nano Banana 2 API: AI 图像生成
通过 Muapi REST API 使用 Nano Banana 2生成图像。按次生成付费,无需订阅。
交互式模型控制
使用 Nano Banana 2 生成图像——兼具速度与 4K 分辨率,输出快速且高保真,并保持出色的角色一致性。描述任意场景,几秒内即可获得精致图像。免费试用——按次生成付费,无需订阅。
通过 Muapi REST API 使用 Nano Banana 2生成图像。按次生成付费,无需订阅。
使用 Nano Banana 2 生成图像——兼具速度与 4K 分辨率,输出快速且高保真,并保持出色的角色一致性。描述任意场景,几秒内即可获得精致图像。免费试用——按次生成付费,无需订阅。
POST https://api.muapi.ai/api/v1/nano-banana-2使用 Muapi API 密钥在 x-api-key 请求头中提交任务,然后轮询 https://api.muapi.ai/api/v1/predictions/{request_id}/result 直到状态变为 completed。
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| prompt | string | 是 | 描述目标图像内容的文本提示词。 |
| aspect_ratio | string | 否 | The aspect ratio of the 生成的图像.选项: 1:1, 1:4, 1:8, 2:3, 3:2, 3:4, 4:1, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9, Auto默认值: "1:1" |
| google_search | boolean | 否 | 是否使用 Google Search 增强提示词。默认值: false |
| resolution | string | 否 | The resolution of the 生成的图像.选项: 1k, 2k, 4k默认值: "1k" |
| output_format | string | 否 | The format of the 输出图像.选项: jpg, png默认值: "jpg" |
REQUEST_ID=$(curl -s -X POST https://api.muapi.ai/api/v1/nano-banana-2 \
-H "x-api-key: $MUAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"<prompt>"}' | jq -r .request_id)
curl -s https://api.muapi.ai/api/v1/predictions/$REQUEST_ID/result -H "x-api-key: $MUAPI_API_KEY"import os, time, requests
API = "https://api.muapi.ai/api/v1"
headers = {"x-api-key": os.environ["MUAPI_API_KEY"]}
r = requests.post(f"{API}/nano-banana-2", headers=headers, json={"prompt":"<prompt>"})
request_id = r.json()["request_id"]
while True:
res = requests.get(f"{API}/predictions/{request_id}/result", headers=headers).json()
if res["status"] == "completed":
print(res["outputs"]); break
if res["status"] == "failed":
raise RuntimeError(res.get("error"))
time.sleep(3)完整文档及 Agent/MCP 集成: llms.txt. 在此获取 API 密钥: muapi.ai/access-keys.