Skip to main content

What you will build

You will call the Gemini image generateContent route through RunBridge AI, request an image output from Gemini image models including Nano Banana model families, skip intermediate thought image parts, and save the final inlineData image.

Prerequisites

  • A RunBridge AI API key stored in RUNBRIDGE_API_KEY
  • Python 3.10+ with requests, or Node.js 18+
  • The Nano Banana 2 model ID gemini-3.1-flash-image, used in the text-to-image example below.

API key, base URL, authentication

Use the Gemini image route through RunBridge AI:
Authenticate with x-goog-api-key:

Code examples

Use the tabs below for copyable examples in cURL, Python, and Node.js.

Flow explanation

Gemini image generation is synchronous on this route. The response uses Gemini native candidates[].content.parts[]. Parts can include text, generated images, and intermediate image parts where thought is true. When saving the result, iterate through image parts, ignore thought: true, and save the last remaining inlineData image. Use its mimeType to select .jpg, .png, or .webp; the examples preserve the returned image bytes.

Common parameters

Troubleshooting / FAQ

Do not save parts where thought is true. These are intermediate images, not the final output.
Check that generationConfig.responseModalities includes IMAGE, and that the selected model supports image output.
Use inlineData request parts as shown in the Gemini image guide, and keep the final-image parsing logic the same. The Python SDK exposes the same field as inline_data.

Next steps

Last modified on October 9, 2026