Skip to main content
Call the standard Gemini-native method when your client can keep one connection open until generation finishes:
The model ID is part of the path. The body contains contents and optional generationConfig; there is no top-level YingTu envelope. Choose the model and supported size before deciding that synchronous execution fits. A Pro 4K response can be much larger and slower than a Lite 1K response; the HTTP method does not remove those differences.

When synchronous fits

Use this method for interactive tools, server actions, and simple integrations where the request timeout comfortably exceeds image-generation time. The HTTP response contains the final Gemini candidates array.
A short client or proxy timeout can terminate the connection before the image arrives. Use the asynchronous task method when the caller cannot safely hold the connection.

Read the result safely

content.parts may contain text and image parts in different positions. Find every part with inlineData; do not index the array by a fixed position. Use inlineData.mimeType to decide how to save the Base64 bytes.

Open the synchronous Playground

Inspect model, body, authentication, and response schemas.

Choose a Nano Banana model

Match resolution and price to the job before sending the request.