> ## 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 Google Gemini with Comfy Router

> Python, TypeScript and cURL snippets for calling Google Gemini text models over HTTP through Comfy Router, plus the request fields and the result shape

API Reference for Google Gemini. Google Gemini is Google's family of multimodal text models, covering fast drafting through deep reasoning across the Flash and Pro tiers.

<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.

Pick the model you want to call. The models share one request and response shape, documented once below.

<Tabs>
  <Tab title="Gemini 3.1 Pro">
    **Model ID:** `vertexai/gemini-3.1-pro-preview`

    **Endpoint:** `POST https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview`

    <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-pro-preview",
              {
                  "contents": [
                      {
                          "role": "user",
                          "parts": [
                              {
                                  "text": "Describe a single red maple leaf on a white background in one sentence.",
                              },
                          ],
                      },
                  ],
                  "generationConfig": {
                      "temperature": 0.7,
                      "maxOutputTokens": 256,
                  },
              },
          )

      print("text:", result["candidates"][0]["content"]["parts"][0]["text"])
      ```

      ```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: { text: string }[] } }[] };
      const { data } = await comfy.models.run<Result>("vertexai/gemini-3.1-pro-preview", {
        contents: [
          {
            role: "user",
            parts: [
              {
                text: "Describe a single red maple leaf on a white background in one sentence.",
              },
            ],
          },
        ],
        generationConfig: {
          temperature: 0.7,
          maxOutputTokens: 256,
        },
      });

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

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Gemini 3.5 Flash">
    **Model ID:** `vertexai/gemini-3.5-flash`

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

    <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.5-flash",
              {
                  "contents": [
                      {
                          "role": "user",
                          "parts": [
                              {
                                  "text": "Describe a single red maple leaf on a white background in one sentence.",
                              },
                          ],
                      },
                  ],
                  "generationConfig": {
                      "temperature": 0.7,
                      "maxOutputTokens": 256,
                  },
              },
          )

      print("text:", result["candidates"][0]["content"]["parts"][0]["text"])
      ```

      ```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: { text: string }[] } }[] };
      const { data } = await comfy.models.run<Result>("vertexai/gemini-3.5-flash", {
        contents: [
          {
            role: "user",
            parts: [
              {
                text: "Describe a single red maple leaf on a white background in one sentence.",
              },
            ],
          },
        ],
        generationConfig: {
          temperature: 0.7,
          maxOutputTokens: 256,
        },
      });

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

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/vertexai/gemini-3.5-flash \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Gemini 2.5 Pro">
    **Model ID:** `vertexai/gemini-2.5-pro`

    **Endpoint:** `POST https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro`

    <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-2.5-pro",
              {
                  "contents": [
                      {
                          "role": "user",
                          "parts": [
                              {
                                  "text": "Describe a single red maple leaf on a white background in one sentence.",
                              },
                          ],
                      },
                  ],
                  "generationConfig": {
                      "temperature": 0.7,
                      "maxOutputTokens": 256,
                  },
              },
          )

      print("text:", result["candidates"][0]["content"]["parts"][0]["text"])
      ```

      ```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: { text: string }[] } }[] };
      const { data } = await comfy.models.run<Result>("vertexai/gemini-2.5-pro", {
        contents: [
          {
            role: "user",
            parts: [
              {
                text: "Describe a single red maple leaf on a white background in one sentence.",
              },
            ],
          },
        ],
        generationConfig: {
          temperature: 0.7,
          maxOutputTokens: 256,
        },
      });

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

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Gemini 2.5 Flash">
    **Model ID:** `vertexai/gemini-2.5-flash`

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

    <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-2.5-flash",
              {
                  "contents": [
                      {
                          "role": "user",
                          "parts": [
                              {
                                  "text": "Describe a single red maple leaf on a white background in one sentence.",
                              },
                          ],
                      },
                  ],
                  "generationConfig": {
                      "temperature": 0.7,
                      "maxOutputTokens": 256,
                  },
              },
          )

      print("text:", result["candidates"][0]["content"]["parts"][0]["text"])
      ```

      ```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: { text: string }[] } }[] };
      const { data } = await comfy.models.run<Result>("vertexai/gemini-2.5-flash", {
        contents: [
          {
            role: "user",
            parts: [
              {
                text: "Describe a single red maple leaf on a white background in one sentence.",
              },
            ],
          },
        ],
        generationConfig: {
          temperature: 0.7,
          maxOutputTokens: 256,
        },
      });

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

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-flash \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## 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, oldest first. A part is `text`, or `inlineData` to send an image, audio or video alongside the prompt.
</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="systemInstruction" type="object">
  System prompt applied to the whole conversation.
</ParamField>

<ParamField body="systemInstruction.parts" type="object[]" />

<ParamField body="systemInstruction.parts[].text" type="string" />

<ParamField body="generationConfig" type="object">
  Sampling and length settings.
</ParamField>

<ParamField body="generationConfig.temperature" type="number">
  Randomness of sampling. Defaults are model specific.

  Range: `0` to `2`
</ParamField>

<ParamField body="generationConfig.topP" type="number">
  Nucleus sampling threshold. Defaults are model specific.
</ParamField>

<ParamField body="generationConfig.topK" type="integer">
  Top-k sampling cutoff. Defaults are model specific.
</ParamField>

<ParamField body="generationConfig.maxOutputTokens" type="integer">
  Upper bound on generated tokens.
</ParamField>

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

<ParamField body="generationConfig.stopSequences" type="string[]">
  Strings that end generation when produced.
</ParamField>

<ParamField body="generationConfig.thinkingConfig" type="object">
  Reasoning effort controls on models that support it.
</ParamField>

<ParamField body="generationConfig.thinkingConfig.thinkingLevel" type="string">
  Possible values: `MINIMAL`, `LOW`, `MEDIUM`, `HIGH`
</ParamField>

<ParamField body="generationConfig.thinkingConfig.includeThoughts" type="boolean">
  Return the model's reasoning alongside the answer.
</ParamField>

<ParamField body="tools" type="object[]">
  Function declarations the model may call.
</ParamField>

<ParamField body="tools[].functionDeclarations" type="object[]" />

<ParamField body="tools[].functionDeclarations[].name" type="string" />

<ParamField body="tools[].functionDeclarations[].description" type="string" />

<ParamField body="tools[].functionDeclarations[].parameters" type="object">
  JSON Schema for the function's arguments.
</ParamField>

### Output

Router returns Google's native response unchanged. The text is at `candidates[0].content.parts[0].text`.

<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[].text" type="string">
  The generated text.
</ResponseField>

<ResponseField name="candidates[].content.parts[].functionCall" type="object">
  Present when the model chose to call one of your `tools`.
</ResponseField>

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

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

<ResponseField name="candidates[].finishReason" type="string">
  Why generation stopped: `STOP`, `MAX_TOKENS`, `SAFETY`, ...
</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": "Describe a single red maple leaf on a white background in one sentence."
        }
      ]
    }
  ],
  "generationConfig": {
    "temperature": 0.7,
    "maxOutputTokens": 256
  }
}
```

### Output

```json theme={null}
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "A single red maple leaf rests on a plain white background, its edges sharp and its color deep."
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 18,
    "candidatesTokenCount": 24
  }
}
```

## 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>
