Skip to main content

Nano Banana image generation

Use nano-banana-2 or nano-banana-pro with the OpenAI-compatible Images API.

Configuration items​

  • Base URL: After logging in to the official website, view and copy it on the User Center - [API Key] page
  • API Key:MuskAI API Key
  • Model: nano-banana-2 or nano-banana-pro
  • Endpoint: POST /v1/images/generations

Minimal request​

curl "$BASE_URL/v1/images/generations" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana-pro",
"prompt": "A premium perfume poster with soft side lighting",
"aspect_ratio": "1:1",
"resolution": "2k",
"response_format": "b64_json"
}'

Use aspect_ratio and resolution=1k/2k/4k; do not copy GPT Image pixel size or quality. Read the image from data[0].b64_json or data[0].url.

Usage suggestions​

Image tasks often take a long time. If the client has a timeout configuration, it is recommended to set it to 120 seconds or higher, and avoid submitting a large number of concurrent tasks in a short period of time.