YM2API Developer docs
Skip to content
Docs / Nano Banana #125 / #139

Nano Banana #125 / #139 response formats

Both groups take the same requests, models and prices; switching is just a different key. They differ only when the request body has no response_format: for Gemini native, Images and Messages, #125 returns Base64 and #139 returns a hosted image link. Chat and Responses return links in both groups. With response_format set, both groups return the same thing.

Key points about response formats
  • Without response_format, Gemini native, Images (generate and edit) and Messages return Base64 on #125 and a link on #139. A client that only reads Base64 gets no image from #139.
  • Chat and Responses return a Markdown image link in both groups, #125 included; Base64 needs "response_format": "b64_json".
  • Image links expire after 1 hour (then 404). Download or copy them right away.
  • Image streaming is paused: stream requests return HTTP 400 at once, with no generation and no charge.

1 The two groups

GroupNameNative / Images / Messages defaultTo switch
#125【AI Studio 生图】Nanobana · 默认 Base64(原生)Base64For links add a top-level "response_format": "url"
#139【AI Studio 生图】Nanobana 主渠道 · 默认 URLLink (valid 1 hour)For Base64 add a top-level "response_format": "b64_json"
ModelModel name#125#139
Nano Banana 2.0gemini-3.1-flash-image-preview$0.04 / image$0.04 / image
Nano Banana 2.1gemini-nano-banana-2.1$0.05 / image$0.05 / image
Nano Banana 2 Progemini-3-pro-image-preview$0.055 / image$0.055 / image

2 Test results

Tested 2026-10-22 00:10 (UTC+8) with gemini-3.1-flash-image-preview at 1K, one key per group, 6 request formats × 3 ways of writing response_format. One call per case; all 36 returned HTTP 200.

Request formatPathNo format · #125No format · #139b64_json (both)url (both)
Gemini native ◀ differsPOST /v1beta/models/{model}:generateContentBase64LinkBase64Link
Images generation ◀ differsPOST /v1/images/generationsBase64LinkBase64Link
Images edit ◀ differsPOST /v1/images/edits (multipart)Base64LinkBase64Link
Messages ◀ differsPOST /v1/messagesBase64LinkBase64Link
Chat CompletionsPOST /v1/chat/completionsLinkLinkBase64Link
ResponsesPOST /v1/responsesLinkLinkBase64Link

3 Where the image is in the response

The response structure is the same in both groups; only the value at that position is Base64 or a link. Walk every part instead of assuming the first one is the image.

Request formatBase64 locationLink location
Gemini nativecandidates[].content.parts[].inlineData.datacandidates[].content.parts[].fileData.fileUri, plus a ![image](link) text part
Images generationdata[].b64_jsondata[].url
Images editdata[].b64_jsondata[].url
Messagescontent[].text contains ![image](data:image/…;base64,…)content[].text contains ![image](https://…)
Chat Completionschoices[].message.content contains ![image](data:image/…;base64,…)choices[].message.content contains ![image](https://…)
Responsesoutput[].content[].text contains ![image](data:image/…;base64,…)output[].content[].text contains ![image](https://…)

4 Which to use

5 Streaming

Image streaming is paused in both groups: streamGenerateContent and Chat with "stream": true return HTTP 400 at once, with no generation and no charge. Use non-streaming requests.