> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ovalbee.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ovalbee.com/_mcp/server.

# Prelabel with Gemini

> Pre-label a dataset's images with object detection boxes from a Gemini model, prompted with the class names or with visual examples, into a new dataset. Runs on the instance's Google Gemini key.

## Overview

Draws object detection boxes on a dataset's images with a Gemini model, so labelers start from prelabels instead of empty images. The model looks for the dataset's own classes, told either their names or shown a few labeled examples of each, and the boxes land in a new dataset next to the original images.

Run it beside [Prelabel with Claude](/node-library/nodes/models-llm-prelabel-with-claude) and [Prelabel with GPT](/node-library/nodes/models-llm-prelabel-with-gpt) on the same images, score each run with [Compare prelabels with ground truth](/node-library/nodes/evaluate-evaluate-prelabeling-efficiency), and rank them with [Compare prelabeling models](/node-library/nodes/evaluate-compare-prelabeling-models). The badge shows how many images got boxes and how many failed.

```mermaid
flowchart LR
  n1["Dataset"] --> n2["Prelabel with Gemini"] --> n3["Compare prelabels with ground truth"] --> n4["Compare prelabeling models"]
```

## Prerequisites

| Requirement                     | What you need                                                                                                                         |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| **Google Gemini API key**       | A key for Google Gemini on the instance, added by an instance administrator under **Admin → Configuration → Integrations**.           |
| **Classes**                     | The dataset's classes, from its ontology or from images already labeled in it. The model never invents a class of its own.            |
| **Reference images** (optional) | A labeled [Dataset](/node-library/nodes/dataset-ops-dataset) with clear examples of every class. Needed only for **Visual examples**. |

## How it works

Reads the dataset's classes and copies its images into the node's prelabel dataset.

For **Visual examples**, cuts the largest labeled objects of each class out of **Reference images**, each with its box drawn in red, at most seven in all.

Cuts every image into **Tiles** overlapping tiles and sends each tile, shrunk to 1536 px on its longest side, to the chosen model with the class names and the examples, several requests at a time.

Turns the tiles' answers into boxes on the whole image, keeping one box for an object two overlapping tiles both found, and saves them as the image's annotation, along with the model, the prompt, the time and the tokens all its tiles took.

## FAQ

#### Should I use class names or visual examples?

Class names work when the class is something the model already knows by name. Visual examples help with an unusual class, or a common word that means something specific in your data. Run the node once with each and compare both runs to decide.

#### What should go in Reference images?

A few hand-checked images where every class appears clearly. Keep them out of the dataset you prelabel: an image the model was shown as an example would score better than it should.

#### How many tiles should I use?

A model lists only so many objects in one answer and then stops, however many more the image holds. On crowded images, such as stacks of pipes or shelves of products, 3 x 3 tiles find several times more objects than the whole image does. On images with a handful of large objects, **None** finds the same boxes for a fraction of the tokens, and an object larger than a tile is cut between tiles.

#### Why are some images counted as failed?

The model returned an error, refused, or answered with something that wasn't a list of boxes. A failed image gets no annotation and the run carries on with the rest. A missing or rejected API key, an unknown model, or running out of credits stops the whole run instead.

#### Why do the boxes carry no confidence?

A language model answers with boxes only, with no score for each one. Every box it returns is kept, so there is no threshold to tune and no precision-recall curve to read.

#### What happens when I run the node again?

The new boxes go into a new version of the same prelabel dataset, so earlier runs stay in its history.

#### What does a run cost?

Each tile is one request to Google Gemini, billed by the tokens it takes, so 3 x 3 tiles cost several times what one request per image does. On OvalBee Cloud each request is charged to the workspace's credits. The tokens of every image are saved on its annotation, and Compare prelabeling models adds them up per model.

## Inputs

**`Dataset`** `dataset` — required

Images to pre-label. Its classes are what the model looks for. The images are left untouched here and copied, with the predicted boxes, into the node's pre-label dataset. Key: `DATASET`.

---

**`Model`** `select` — required, default: gemini-3.1-pro-preview

Gemini model that draws the boxes. It runs on the instance's Google Gemini API key, which an instance administrator adds under Admin, Configuration, Integrations. Key: `LLM_MODEL`.

Options:

* Gemini 3.1 Pro (`gemini-3.1-pro-preview`)
* Gemini 3.8 Flash (`gemini-3.8-flash`)
* Gemini 3.6 Flash (`gemini-3.6-flash`)
* Gemini 3.5 Flash-Lite (`gemini-3.5-flash-lite`)

---

**`Prompt`** `select` — required, default: visual

How the model is told what to look for. Visual examples also shows it labeled objects of each class, cut from Reference images, with every image. Key: `PROMPT_MODE`.

Options:

* Visual examples (`visual`)
* Class names (`text`)

---

**`Reference images`** `dataset`

Labeled images the visual examples are cut from, the largest objects of each class first. Needed only for Visual examples. Key: `REFERENCE_DATASET`.

---

**`Tiles`** `select` — required, default: 1

Cut each image into overlapping tiles and ask the model about each tile on its own. A model lists only so many objects in one answer, so tiles find far more on crowded images, at one request per tile. Key: `TILE_GRID`.

Options:

* None (`1`)
* 2 x 2 (`2`)
* 3 x 3 (`3`)

---

**`Examples per class`** `integer` — required, default: 2

Labeled objects of each class shown with every image. A request carries at most seven examples, shared out between the classes. Minimum: `1`. Maximum: `7`. Step: `1`. Key: `EXAMPLES_PER_CLASS`.

---

## Outputs

**`Prelabeled dataset`** `dataset`

The node's pre-label dataset, holding the input images with the model's boxes as their annotations. Each annotation records the model, the prompt, the time and the tokens it took, which Compare prelabeling models reads. Key: `OUTPUT_DATASET`.

---

**`Prelabeled images`** `string`

How many images got boxes, and how many failed. Shown on the node as a badge. Key: `PRED_COUNT`.

---

## Models and configuration

**Model** picks the Google model that draws the boxes; every option runs on the same instance key. **Prompt** decides what the model is told: **Class names** sends only the names of the dataset's classes, and **Visual examples** also sends labeled objects of each class cut from **Reference images**. **Examples per class** sets how many objects of each class are sent, at most seven in all.

#### Models

* Gemini 3.1 Pro (default)
* Gemini 3.8 Flash
* Gemini 3.6 Flash
* Gemini 3.5 Flash-Lite

## Runtime

Runs on a CPU worker. The model itself runs at Google Gemini, reached through the instance's LLM route, so the worker needs no GPU.

## JSON config

Machine-readable node interface for automation and advanced usage.

#### Show JSON

```json
{
  "name": "Prelabel with Gemini",
  "description": "Pre-label a dataset's images with object detection boxes from a Gemini model, prompted with the class names or with visual examples, into a new dataset. Runs on the instance's Google Gemini key.",
  "category": "Predict",
  "namespace": null,
  "templateKey": "models/llm/prelabel_with_gemini",
  "version": "v1",
  "inputs": [
    {
      "key": "DATASET",
      "label": "Dataset",
      "type": "dataset",
      "description": "Images to pre-label. Its classes are what the model looks for. The images are left untouched here and copied, with the predicted boxes, into the node's pre-label dataset.",
      "required": true,
      "default": null,
      "visibleWhen": null,
      "options": {
        "creatable": false
      }
    },
    {
      "key": "LLM_MODEL",
      "label": "Model",
      "type": "select",
      "description": "Gemini model that draws the boxes. It runs on the instance's Google Gemini API key, which an instance administrator adds under Admin, Configuration, Integrations.",
      "required": true,
      "default": "gemini-3.1-pro-preview",
      "visibleWhen": null,
      "options": {
        "options": [
          {
            "label": "Gemini 3.1 Pro",
            "value": "gemini-3.1-pro-preview"
          },
          {
            "label": "Gemini 3.8 Flash",
            "value": "gemini-3.8-flash"
          },
          {
            "label": "Gemini 3.6 Flash",
            "value": "gemini-3.6-flash"
          },
          {
            "label": "Gemini 3.5 Flash-Lite",
            "value": "gemini-3.5-flash-lite"
          }
        ]
      }
    },
    {
      "key": "PROMPT_MODE",
      "label": "Prompt",
      "type": "select",
      "description": "How the model is told what to look for. Visual examples also shows it labeled objects of each class, cut from Reference images, with every image.",
      "required": true,
      "default": "visual",
      "visibleWhen": null,
      "options": {
        "options": [
          {
            "label": "Visual examples",
            "value": "visual"
          },
          {
            "label": "Class names",
            "value": "text"
          }
        ]
      }
    },
    {
      "key": "REFERENCE_DATASET",
      "label": "Reference images",
      "type": "dataset",
      "description": "Labeled images the visual examples are cut from, the largest objects of each class first. Needed only for Visual examples.",
      "required": false,
      "default": null,
      "visibleWhen": null,
      "options": {
        "creatable": false
      }
    },
    {
      "key": "TILE_GRID",
      "label": "Tiles",
      "type": "select",
      "description": "Cut each image into overlapping tiles and ask the model about each tile on its own. A model lists only so many objects in one answer, so tiles find far more on crowded images, at one request per tile.",
      "required": true,
      "default": "1",
      "visibleWhen": null,
      "options": {
        "options": [
          {
            "label": "None",
            "value": "1"
          },
          {
            "label": "2 x 2",
            "value": "2"
          },
          {
            "label": "3 x 3",
            "value": "3"
          }
        ]
      }
    },
    {
      "key": "EXAMPLES_PER_CLASS",
      "label": "Examples per class",
      "type": "number",
      "description": "Labeled objects of each class shown with every image. A request carries at most seven examples, shared out between the classes.",
      "required": true,
      "default": 2,
      "visibleWhen": null,
      "options": {
        "type": "integer",
        "min": 1,
        "max": 7,
        "step": 1
      }
    }
  ],
  "outputs": [
    {
      "key": "OUTPUT_DATASET",
      "label": "Prelabeled dataset",
      "type": "dataset",
      "description": "The node's pre-label dataset, holding the input images with the model's boxes as their annotations. Each annotation records the model, the prompt, the time and the tokens it took, which Compare prelabeling models reads.",
      "artifact": false,
      "badge": false,
      "badgeOpens": null,
      "hidden": false
    },
    {
      "key": "PRED_COUNT",
      "label": "Prelabeled images",
      "type": "string",
      "description": "How many images got boxes, and how many failed.",
      "artifact": false,
      "badge": true,
      "badgeOpens": null,
      "hidden": false
    }
  ],
  "automation": {
    "requires_configuration": true
  },
  "widgets": {
    "widget": {
      "id": "asset-preview",
      "settings": {
        "datasetId": {
          "type": "variable",
          "value": "self.outputs.OUTPUT_DATASET"
        }
      }
    }
  }
}
```

## References

#### Sources and related pages

* [Gemini models](https://ai.google.dev/gemini-api/docs/models) from Google, with what each model costs and how large an image it reads.
* [Compare prelabels with ground truth](/node-library/nodes/evaluate-evaluate-prelabeling-efficiency) scores one prelabel run against ground truth.
* [Compare prelabeling models](/node-library/nodes/evaluate-compare-prelabeling-models) ranks several prelabel runs on the same images.