> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-docs-router-model-page-pilot.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Nano Banana 2 Lite with Comfy Router

> Python, TypeScript and cURL snippets for generating images with Nano Banana 2 Lite (Gemini 3.1 Flash-Lite Image) over HTTP through Comfy Router, plus the request fields and the result shape

API Reference for Nano Banana 2 Lite. Nano Banana 2 Lite (Gemini 3.1 Flash-Lite Image) is the Flash-Lite tier of Google's Nano Banana image generation family, tuned for lower latency and cost.

<Note>
  **Comfy Router is not generally available yet.** `POST /v2/models/{provider}/{model}` and its catalog and schema siblings are not serving requests yet: an authenticated call answers `404` today. The snippets on this page document the contract those routes will serve, published ahead of the rollout so your integration is ready to write against.
</Note>

## Quick start

Create a key at [platform.comfy.org/profile/api-keys](https://platform.comfy.org/profile/api-keys) and export it as `COMFY_API_KEY`. The Python and TypeScript snippets use the Comfy SDKs (`pip install comfy-sdk`, `npm install @comfyorg/sdk`); the cURL snippet is the same call over raw HTTP.

**Model ID:** `vertexai/gemini-3.1-flash-lite-image`

**Endpoint:** `POST https://api.comfy.org/v2/models/vertexai/gemini-3.1-flash-lite-image`

<CodeGroup>
  ```python Python theme={null}
  from comfy_sdk import Comfy

  # Reads COMFY_API_KEY from the environment. Each call sends a fresh
  # Idempotency-Key and waits up to 10 minutes for the finished result.
  with Comfy() as client:
      result = client.models.run(
          "vertexai/gemini-3.1-flash-lite-image",
          {
              "contents": [
                  {
                      "role": "user",
                      "parts": [
                          {
                              "text": "a single red maple leaf on a plain white background, studio lighting",
                          },
                      ],
                  },
              ],
              "generationConfig": {
                  "responseModalities": ["IMAGE"],
                  "imageConfig": {
                      "aspectRatio": "1:1",
                  },
              },
          },
      )

  print("image (base64):", result["candidates"][0]["content"]["parts"][0]["inlineData"]["data"])
  ```

  ```typescript TypeScript theme={null}
  import { comfy } from "@comfyorg/sdk";

  // Reads COMFY_API_KEY from the environment. Each call sends a fresh
  // Idempotency-Key and waits up to 10 minutes for the finished result.
  type Result = { candidates: { content: { parts: { inlineData: { data: string } }[] } }[] };
  const { data } = await comfy.models.run<Result>("vertexai/gemini-3.1-flash-lite-image", {
    contents: [
      {
        role: "user",
        parts: [
          {
            text: "a single red maple leaf on a plain white background, studio lighting",
          },
        ],
      },
    ],
    generationConfig: {
      responseModalities: ["IMAGE"],
      imageConfig: {
        aspectRatio: "1:1",
      },
    },
  });

  console.log("image (base64):", data.candidates[0].content.parts[0].inlineData.data);
  ```

  ```bash cURL theme={null}
  curl https://api.comfy.org/v2/models/vertexai/gemini-3.1-flash-lite-image \
    -H "X-API-Key: $COMFY_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"a single red maple leaf on a plain white background, studio lighting\"}]}], \"generationConfig\": {\"responseModalities\":[\"IMAGE\"],\"imageConfig\":{\"aspectRatio\":\"1:1\"}}}"
  ```
</CodeGroup>

## Schema

### Input

*Fields follow Google's published API specification and are checked against it in CI. Router's own schema for this model is not published yet, so requests are forwarded to the provider unvalidated.*

<ParamField body="contents" type="object[]" required>
  The conversation so far. For a single image, one `user` turn with a text part; add an `inlineData` image part to edit an existing image.
</ParamField>

<ParamField body="contents[].role" type="string" required>
  Who authored the turn.

  Possible values: `user`, `model`
</ParamField>

<ParamField body="contents[].parts" type="object[]" required>
  The turn's content parts.
</ParamField>

<ParamField body="contents[].parts[].text" type="string">
  A text part.
</ParamField>

<ParamField body="contents[].parts[].inlineData" type="object">
  An inline media part.
</ParamField>

<ParamField body="contents[].parts[].inlineData.mimeType" type="string">
  Media type, for example `image/png`.
</ParamField>

<ParamField body="contents[].parts[].inlineData.data" type="string">
  Base64-encoded media bytes.
</ParamField>

<ParamField body="generationConfig" type="object">
  Generation settings.
</ParamField>

<ParamField body="generationConfig.responseModalities" type="`TEXT`, `IMAGE`[]">
  Ask for an image with `["IMAGE"]`, or `["TEXT", "IMAGE"]` to also get a caption.
</ParamField>

<ParamField body="generationConfig.imageConfig" type="object">
  Image output settings.
</ParamField>

<ParamField body="generationConfig.imageConfig.aspectRatio" type="string">
  Output aspect ratio, for example `1:1`, `16:9`, `9:16`.
</ParamField>

<ParamField body="generationConfig.seed" type="integer">
  Seed for reproducible results.
</ParamField>

<ParamField body="safetySettings" type="object[]">
  Per-category harm thresholds.
</ParamField>

<ParamField body="safetySettings[].category" type="string">
  Possible values: `HARM_CATEGORY_SEXUALLY_EXPLICIT`, `HARM_CATEGORY_HATE_SPEECH`, `HARM_CATEGORY_HARASSMENT`, `HARM_CATEGORY_DANGEROUS_CONTENT`
</ParamField>

<ParamField body="safetySettings[].threshold" type="string">
  Possible values: `BLOCK_NONE`, `BLOCK_LOW_AND_ABOVE`, `BLOCK_MEDIUM_AND_ABOVE`, `BLOCK_ONLY_HIGH`
</ParamField>

### Output

Router returns Google's native response unchanged. The image (base64) is at `candidates[0].content.parts[0].inlineData.data`.

<ResponseField name="candidates" type="object[]">
  Generated candidates; one unless you asked for more.
</ResponseField>

<ResponseField name="candidates[].content" type="object" />

<ResponseField name="candidates[].content.role" type="string">
  Possible values: `model`
</ResponseField>

<ResponseField name="candidates[].content.parts" type="object[]" />

<ResponseField name="candidates[].content.parts[].inlineData" type="object">
  The generated image, inline.
</ResponseField>

<ResponseField name="candidates[].content.parts[].inlineData.mimeType" type="string">
  Media type of the image, typically `image/png`.
</ResponseField>

<ResponseField name="candidates[].content.parts[].inlineData.data" type="string">
  Base64-encoded image bytes. Decode and write to a file; there is no URL.
</ResponseField>

<ResponseField name="candidates[].content.parts[].text" type="string">
  Present when `TEXT` was among the requested modalities.
</ResponseField>

<ResponseField name="candidates[].finishReason" type="string">
  Why generation stopped, for example `STOP`.
</ResponseField>

<ResponseField name="usageMetadata" type="object">
  Token accounting for the call.
</ResponseField>

<ResponseField name="usageMetadata.promptTokenCount" type="integer">
  Tokens in the prompt.
</ResponseField>

<ResponseField name="usageMetadata.candidatesTokenCount" type="integer">
  Tokens in the generated candidates.
</ResponseField>

<ResponseField name="promptFeedback" type="object">
  Present when the prompt itself was blocked. It is the only field returned in that case, so check for it before reading the result.
</ResponseField>

<ResponseField name="promptFeedback.blockReason" type="string">
  Why the prompt was blocked. No candidates are returned; rephrase the prompt and retry.

  Possible values: `SAFETY`, `OTHER`, `BLOCKLIST`, `PROHIBITED_CONTENT`, `IMAGE_SAFETY`
</ResponseField>

## Examples

### Input

```json theme={null}
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "a single red maple leaf on a plain white background, studio lighting"
        }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": [
      "IMAGE"
    ],
    "imageConfig": {
      "aspectRatio": "1:1"
    }
  }
}
```

### Output

```json theme={null}
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "inlineData": {
              "mimeType": "image/png",
              "data": "iVBORw0KGgoAAAANSUhEUgAA..."
            }
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 12,
    "candidatesTokenCount": 1290
  }
}
```

The image comes back inline as base64 in `inlineData.data`, with its `mimeType` beside it. Decode it and write it to a file; there is no URL to download.

## Before you ship

The snippets above are the shortest working call. Three things are the same for every model and are documented once on the [Comfy Router headers](/development/comfy-router/headers) page: send an `Idempotency-Key` on every paid call and reuse it when you retry, expect the connection to be held up to Router's 10 minute deadline, and keep `X-Comfy-Request-Id` from every response. The SDKs do all three for you; the cURL tab does none of them. On failure, `X-Comfy-Error-Type` names the bucket, and a `422` means the body failed the model's schema and was never billed.

<CardGroup cols={3}>
  <Card title="Headers" icon="list" href="/development/comfy-router/headers">
    Authentication, idempotency, request IDs, error buckets, retry pacing, spend limits.
  </Card>

  <Card title="Quickstart" icon="rocket" href="/development/comfy-router/quickstart">
    Typed error handling in Python and TypeScript, reading the 422, walking the catalog.
  </Card>

  <Card title="Limitations" icon="triangle-exclamation" href="/development/comfy-router/limitations">
    What Router does not do today, and what to use instead.
  </Card>
</CardGroup>
