generateContent wire format. You can keep using Google’s official google-genai SDK — or any Gemini-compatible client — and just point it at BananaHub.
Base URL
Pass this as the SDK’s The SDK appends
base_url:/v1beta/models/... itself, so keep the /api/gemini suffix.How it differs from the native API
The Gemini-compatible endpoint is synchronous: a single request returns the image inline, in Gemini JSON. There are no jobs to poll and no webhooks.Authentication
Send your BananaHub API key asx-goog-api-key. When you set api_key on the SDK client, it adds this header for you. A ?key= query parameter is also accepted.
The key must be scoped for the model you request — see Authentication. A key without permission for the model returns 403 PERMISSION_DENIED.
Models
Use any of the supported Gemini model IDs:
Set the aspect ratio and size through
imageConfig (aspectRatio, imageSize). imageSize is passed through to and validated by the model: supported values are 1K (default), 2K, 4K, plus 512px on NanoBanana 2. An unsupported value returns 400 INVALID_ARGUMENT. See Aspect ratios.
Billing is per the requested size, with
1K as the floor: 512px is billed at the 1K rate. 2K and 4K are billed at their own rates.Supported methods
Both directions are a full passthrough: any
generationConfig, safetySettings, systemInstruction, or tools fields you send reach the model unchanged, and the complete Gemini response — including usageMetadata, finishReason, and safetyRatings — is returned verbatim. The only request-shaping is the imageSize validation described above (and NanoBanana being fixed at 1K).
Billing
You’re billed per generated image, at the same price as the native API. A prompt blocked for safety returns200 with finishReason: IMAGE_SAFETY and no image, and is not charged.
Limits
The request body — prompt plus any base64 input images underinlineData — must not exceed 200 MB. A larger request returns 400 INVALID_ARGUMENT.
Next steps
SDK quickstart
Generate, edit, and stream images with the
google-genai SDK.Errors
The Gemini error envelope and status codes.