Nano Banana 2.1 API
Nano Banana 2.1 のテキストからの画像生成および画像編集モデルの完全な API リファレンスです。
モデルの種類
この API は 2 種類のモデルに対応しています。
比較一覧
対応するアスペクト比
両モデルとも 14 種類のアスペクト比に対応しています。
16:9, 9:16, 1:1, 3:2, 2:3, 3:4, 4:3, 5:4, 4:5, 21:9, 1:4, 4:1, 1:8, 8:1
比率は数値の width と height を個別に指定します。例えば、width: 16 と height: 9 で 16:9 を選択できます。これらの値は比率を表し、出力画像のピクセル寸法ではありません。
Nano Banana 2.1(テキストからの画像生成)
エンドポイント {#}
POST /api/v1/image/task
認証
Authorization: Bearer YOUR_API_KEY
リクエストパラメータ
必須
注意: width:height の比率は、16:9、9:16、1:1、3:2、2:3、3:4、4:3、5:4、4:5、21:9、1:4、4:1、1:8、8:1 のいずれかである必要があります。
任意
リクエスト例
const response = await fetch('https://api.flaq.ai/api/v1/image/task', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_name: 'nano-banana-2.1',
prompt: 'A serene mountain landscape at sunset',
width: 16,
height: 9,
resolution: '2k',
enable_web_search: true,
enable_image_search: false
})
});
const { data } = await response.json();
const taskId = data.task_id;
Nano Banana 2.1 Edit(画像編集)
エンドポイント
POST /api/v1/image/task
リクエストパラメータ
必須
注意: width:height の比率は、上記の対応する 14 種類の比率のいずれかである必要があります。
任意
単一画像の編集例
{
model_name: 'nano-banana-2.1-edit',
prompt: 'Change the sky to sunset colors',
width: 16,
height: 9,
resolution: '2k',
image_url_list: ['https://example.com/image.jpg'],
enable_web_search: false,
enable_image_search: true
}
複数画像の合成例
{
model_name: 'nano-banana-2.1-edit',
prompt: 'Combine these images into a cohesive landscape',
width: 16,
height: 9,
resolution: '2k',
image_url_list: ['https://example.com/image1.jpg', 'https://example.com/image2.jpg', 'https://example.com/image3.jpg'],
enable_web_search: false,
enable_image_search: false
}
料金に関する注意: 参照画像は 1 枚目から画像ごとに課金されます。有効にした検索オプションごとに、画像数にかかわらず生成 1 回あたりの固定料金が別途加算されます。料金については現在の価格をご確認ください。
レスポンス形式
初期レスポンス
{
"code": 0,
"message": "success",
"data": {
"task_id": "{task_id}",
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}",
"task_status": "submitted"
}
}
ポーリングレスポンス
{
"code": 0,
"message": "success",
"data": {
"task_id": "{task_id}",
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}",
"task_status": "processing",
"task_status_msg": null,
"task_result": null
}
}
成功時のレスポンス
{
"code": 0,
"message": "success",
"data": {
"task_id": "{task_id}",
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}",
"task_status": "succeed",
"task_status_msg": null,
"task_result": {
"credit": 0.074,
"images": [
{
"url": "https://example.com/generated-image.png"
}
]
}
}
}
ステータス値
submitted:タスクが受け付けられました
processing:タスクを実行中です
succeed:タスクが正常に完了しました
failed:タスクが失敗しました
ベストプラクティス
テキストからの画像生成のヒント
- 画像を説明する: プロンプトに被写体、照明、構図を含めます。
- 解像度を選択する: すべてのリクエストで
1k、2k、4k のいずれかを渡します。
- アスペクト比を選択する: 対応する 14 種類の比率のいずれかに合う
width と height の値を渡します。
- 検索オプションを選択する: 各検索フラグを省略するとデフォルトの
false になります。必要に応じて true に設定します。
画像編集のヒント
- 参照画像を指定する:
image_url_list にアクセス可能な画像 URL を 1~14 件指定します。
- 編集内容を説明する: プロンプトで変更する内容や維持する内容を明示します。
- 出力設定を選択する: 必須の
resolution、width、height の値を指定します。
- 検索オプションを選択する: ウェブ検索と画像検索は個別に有効にできます。