Nano Banana API
curl --request POST \
--url https://apistable.ai/api/v1/tasks/create_task \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "nano-banana",
"input": {
"prompt": "Product photograph of a cobalt blue teapot on a wooden table, lit by a window.",
"aspect_ratio": "16:9"
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'nano-banana',
input: {
prompt: 'Product photograph of a cobalt blue teapot on a wooden table, lit by a window.',
aspect_ratio: '16:9'
}
})
};
fetch('https://apistable.ai/api/v1/tasks/create_task', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://apistable.ai/api/v1/tasks/create_task"
payload = {
"model": "nano-banana",
"input": {
"prompt": "Product photograph of a cobalt blue teapot on a wooden table, lit by a window.",
"aspect_ratio": "16:9"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"code": 200,
"msg": "success",
"data": {
"task_id": "00000000-0000-4000-8000-000000000001"
}
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}Google
Nano Banana API
支持 1K 文生图和参考图编辑。
POST
/
api
/
v1
/
tasks
/
create_task
Nano Banana API
curl --request POST \
--url https://apistable.ai/api/v1/tasks/create_task \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "nano-banana",
"input": {
"prompt": "Product photograph of a cobalt blue teapot on a wooden table, lit by a window.",
"aspect_ratio": "16:9"
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'nano-banana',
input: {
prompt: 'Product photograph of a cobalt blue teapot on a wooden table, lit by a window.',
aspect_ratio: '16:9'
}
})
};
fetch('https://apistable.ai/api/v1/tasks/create_task', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://apistable.ai/api/v1/tasks/create_task"
payload = {
"model": "nano-banana",
"input": {
"prompt": "Product photograph of a cobalt blue teapot on a wooden table, lit by a window.",
"aspect_ratio": "16:9"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"code": 200,
"msg": "success",
"data": {
"task_id": "00000000-0000-4000-8000-000000000001"
}
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}参数与输入模式
model 和 input 始终必填。通过 URL 传参考图时,请使用公网图片直链,并确保任务结束前始终可访问。
| 请求场景 | input 必填字段 |
|---|---|
| 文生图 | prompt |
| 参考图编辑 | prompt 和非空的 image_urls 数组。 |
使用场景
{
"model": "nano-banana",
"input": {
"prompt": "Product photograph of a cobalt blue teapot on a wooden table, lit by a window.",
"aspect_ratio": "16:9"
}
}
{
"model": "nano-banana",
"input": {
"prompt": "Replace the background with a plain ivory studio backdrop.",
"image_urls": [
"https://cdn.example.com/reference.png"
],
"aspect_ratio": "auto"
}
}
授权
登录 APIstable 后,在 API Key 管理 创建并复制密钥。
每次调用都要在 HTTP 请求头传入:
Authorization: Bearer YOUR_API_KEY
将 YOUR_API_KEY 替换为你创建的 API Key。
请求体
application/json
回调
POST{$request.body#/callback_url}Webhook
请求体
application/json
任务成功或失败后,APIstable 向创建任务时传入的 callback_url 发送 JSON POST。验签后返回 HTTP 2xx 确认接收。
用 data.status 判断生成结果。部分成功也返回 succeeded。data.result.urls 列出成功图片,图片保留 14 天。全部失败时为 failed,data.result 为 null,data.message 提供失败原因。
签名和去重使用 X-APIstable-Signature、X-APIstable-Timestamp 和 X-APIstable-Event-Id。详见 Webhook 安全与验签。
Webhook 请求体示例
{
"code": 200,
"msg": "success",
"data": {
"task_id": "00000000-0000-4000-8000-000000000001",
"model": "nano-banana",
"status": "succeeded",
"created_at": "2026-11-13T08:30:00.000Z",
"completed_at": "2026-11-13T08:30:08.000Z",
"duration": 8000,
"charged_credits": 2,
"message": "",
"input": "{\"prompt\":\"Studio photograph of a cobalt blue teapot.\",\"resolution\":\"1K\"}",
"result": {
"urls": [
"https://cdn.example.com/generated/image.png"
],
"items": [
{
"id": "00000000-0000-4000-8000-000000000002",
"status": "succeeded",
"charged_credits": 2,
"urls": [
"https://cdn.example.com/generated/image.png"
]
}
]
}
}
}
响应
2XX
已接收 Webhook。
响应
已受理。使用 task_id 查询任务,或通过 callback_url 接收结果。