Nano Banana
Gemini image editing API
Edit images with Nano Banana through BetterToken’s Gemini API. Send reference images and editing instructions, try requests online, and read the image response.
POST
Gemini image editing API
Send a reference image and an editing instruction to Nano Banana Pro, 2, or 2.1.
All three offer
POST /v1beta/models/{model}:generateContent
Text-to-image and image editing use the same endpoint. Image editing adds a reference image to the request.
Reference images
Use a separate part for each text instruction and image.inlineData.data contains raw base64 without a Data URL prefix. Use PNG or JPEG reference images; this endpoint accepts JSON, not multipart uploads or image URLs.
Before sending, replace REPLACE_WITH_IMAGE_BASE64 with your image’s base64 and set inlineData.mimeType to match the file. The sample instruction describes a mug; change it too if you use a different subject.
Try a request
Prepare your reference image first. Enter your BetterToken API Key in x-goog-api-key and select model. In contents, provide the editing instruction and image data. Check thatinlineData.data has been replaced and inlineData.mimeType matches the file, then click Send.
Clicking Send makes a real generation request and may incur charges. Wait for the synchronous response. After a timeout or disconnection, check usage records and the request result before sending it again.
1K, 2K, and 4K. Nano Banana 2 and 2.1 support 14 aspect ratios; Pro supports 10. X-BetterToken-Max-Images is a delivery and billing cap, not a guaranteed image count. Aspect ratios
Use non-streaming generateContent. Files / fileData, Batch, Interactions, and streaming are not supported by this integration.
Read the response
Images are returned incandidates[].content.parts[].inlineData. Iterate over the parts, skip thought: true, decode data, and choose the file extension from mimeType. Do not assume the image is always the first part or always PNG.
Related guides
Authorizations
BetterToken API Key.
Headers
Maximum number of returned and billable images, not a guaranteed count. Defaults to 1.
Required range:
1 <= x <= 4Path Parameters
BetterToken Model ID. Choose one of the three Nano Banana models.
Available options:
nano-banana-pro, nano-banana-2, nano-banana-2.1 Body
application/json

