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

# Gemma 4 ComfyUI workflow example

> Gemma 4 is Google's multimodal LLM family supporting text generation, image understanding, video analysis, and audio transcription with up to 256K context. Available in 2B, 4B, and 31B sizes.

<Tip>
  <Tabs>
    <Tab title="Portable or self deployed users">
      Make sure your ComfyUI is updated.

      * [Download ComfyUI](https://www.comfy.org/download)
      * [Update Guide](/installation/update_comfyui)

      Workflows in this guide can be found in the [Workflow Templates](/interface/features/template).
      If you can't find them in the template, your ComfyUI may be outdated. (Desktop version's update will delay sometime)

      If nodes are missing when loading a workflow, possible reasons:

      1. You are not using the latest ComfyUI version (Nightly version)
      2. Some nodes failed to import at startup
    </Tab>

    <Tab title="Desktop or Cloud users">
      * The Desktop is base on ComfyUI stable release, it will auto-update when there is a new Desktop stable release available.
      * [Cloud](https://cloud.comfy.org) will update after ComfyUI stable release.

      So, if you find any core node missing in this document, it might be because the new core nodes have not yet been released in the latest stable version. Please wait for the next stable release.
    </Tab>
  </Tabs>
</Tip>

**Gemma 4** is the latest generation of lightweight open LLMs from Google DeepMind, built for text generation, image understanding, video analysis, audio transcription, and structured tool use. It is natively supported in ComfyUI as the default **Text Generation** model.

**Model highlights**:

* **Multimodal by design** — accepts text, image, video, and audio inputs simultaneously
* **Three sizes available**:
  * **E2B (2B)** — Fast and lightweight, ideal for consumer GPUs
  * **E4B (4B)** — Balanced performance, recommended default
  * **31B** — Best quality, requires higher VRAM
* **Thinking mode** — Built-in step-by-step reasoning before generating answers
* **Long context** — Up to 128K tokens (E2B/E4B) and 256K tokens (31B)
* **Multilingual** — 35+ languages out of the box, pre-trained on 140+
* **Function calling** — Native support for structured tool use and agentic workflows
* **ComfyUI native** — loaded and run through the built-in `TextGenerate` and `CLIPLoader` nodes

**Related links**:

* [Hugging Face (Comfy-Org/gemma-4)](https://huggingface.co/Comfy-Org/gemma-4)
* [Google AI for Developers](https://ai.google.dev/gemma)
* [ComfyUI Source Code (nodes\_textgen.py)](https://github.com/Comfy-Org/ComfyUI/blob/master/comfy_extras/nodes_textgen.py)

## Available workflow

### Gemma 4: Text Generation

<Card title="Download Workflow" icon="download" href="https://github.com/Comfy-Org/workflow_templates/blob/main/templates/llm_gemma4_text_gen.json">
  Download JSON or search "Gemma 4 Text Generation" in Template Library
</Card>

<Card title="Run on Comfy Cloud" icon="cloud" href="https://cloud.comfy.org/?template=llm_gemma4_text_gen&utm_source=docs&utm_medium=referral&utm_campaign=gemma4">
  Open in Comfy Cloud
</Card>

![Gemma 4 Text Generation Workflow](https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/templates/llm_gemma4_text_gen-1.webp)

This workflow demonstrates the core **text generation** capabilities of Gemma 4. It accepts an optional image, audio file, or video as additional context alongside your text prompt, and generates natural language output — with support for reasoning, coding, and multilingual prompts.

**Inputs**:

* **Text prompt** — your question or instruction
* **Image** (optional) — for visual understanding tasks (OCR, object detection, chart reading, etc.)
* **Audio** (optional) — for speech recognition or transcription
* **Video** (optional) — for video understanding across frames (subsampled to 1 FPS internally)

**Key controls**:

* **Max length** — maximum number of tokens to generate (default 256)
* **Sampling mode** — toggle sampling on/off and adjust temperature, top-k, top-p, repetition penalty, and seed
* **Thinking mode** — enable step-by-step reasoning before the final answer
* **Use default template** — apply the built-in system prompt for the model

**Output**:

* **Generated text** — the model's response as a plain text string

<Card title="Learn about Subgraph" icon="book-open" href="/interface/features/subgraph">
  This workflow uses Subgraph nodes for modular processing. Check out the Subgraph documentation to learn how to customize and extend the workflow.
</Card>

## Model Download

Gemma 4 models are loaded as text encoders in ComfyUI. Download the relevant model file and place it in the correct directory:

<Card title="Gemma 4 2B (E2B IT FP8)" icon="download" href="https://huggingface.co/Comfy-Org/gemma-4/resolve/main/text_encoders/gemma4_e2b_it_fp8_scaled.safetensors">
  Fast, lightweight. Recommended for consumer GPUs.
</Card>

<Card title="Gemma 4 4B (E4B IT FP8)" icon="download" href="https://huggingface.co/Comfy-Org/gemma-4/resolve/main/text_encoders/gemma4_e4b_it_fp8_scaled.safetensors">
  Balanced performance. The default model in the workflow.
</Card>

<Card title="View All Variants" icon="external-link" href="https://huggingface.co/Comfy-Org/gemma-4/tree/main/text_encoders">
  Browse all Gemma 4 model weights.
</Card>

Place the downloaded `.safetensors` file in:

```
📂 ComfyUI/
├── 📂 models/
│   └── 📂 text_encoders/
│       └── gemma4_e4b_it_fp8_scaled.safetensors
```
