Image generation

Nano Banana

Google's Gemini image models, called with Google's own SDK.

Parsec serves the Gemini API’s own generateContent endpoint, so Google’s google-genai SDK works unchanged: point its base URL at Parsec and use your Parsec key as the API key.

Model id
nano-banana-2Gemini 3.1 Flash Image
nano-banana-2.1Gemini Nano Banana 2.1

Python

pip install google-genai
import os
from google import genai

client = genai.Client(
    api_key=os.environ["PARSEC_API_KEY"],
    http_options={"base_url": "https://platform.parseclab.ai"},
)
resp = client.models.generate_content(
    model="nano-banana-2",
    contents="A watercolor lighthouse at dusk",
)
for part in resp.candidates[0].content.parts:
    if part.inline_data and not part.thought:
        open("out.png", "wb").write(part.inline_data.data)

The base URL has no /v1beta: the SDK adds it.

Editing an image

Pass the source image alongside the instruction:

from google.genai import types

source = open("room.jpg", "rb").read()
resp = client.models.generate_content(
    model="nano-banana-2",
    contents=[
        types.Part.from_bytes(data=source, mime_type="image/jpeg"),
        "Repaint the walls a pale sage green",
    ],
)

HTTP

curl https://platform.parseclab.ai/v1beta/models/nano-banana-2:generateContent \
  -H "x-goog-api-key: $PARSEC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents": [{"parts": [{"text": "A watercolor lighthouse at dusk"}]}]}'

The request body and the response are the Gemini API’s, relayed as sent, and errors are Google-shaped. Images come back base64-encoded in candidates[0].content.parts[].inlineData.

Usage and limits

  • Billing follows Google’s token counts: input, text output (thinking included) and image output tokens, at the prices on the models page.
  • Streaming (streamGenerateContent) is not supported yet.