Nodes/ComfyUI-NanoBanana2/NanoBanana - Text Embeddings
ComfyUI Node

NanoBanana - Text Embeddings

Turn text into a vector, for the RAG-ish workflows in your graph

By IxMxAMAR·Created 6 months ago·Updated about a month ago· 4
NanoBanana - Text Embeddings
  • network
  • embedding_json
  • dim
api_key
modelgemini-embedding-001
text
custom_model
task_typeSEMANTIC_SIMILARITY
output_dim768

Embeddings are the quiet workhorse behind every "semantic search" and RAG pipeline you've ever used: instead of matching keywords, you convert text into a vector of numbers and measure similarity by distance. This node does that conversion for you, calling Google's Gemini embedding models from inside ComfyUI. Text in, a JSON list of floats out, plus the vector dimension.

Why in ComfyUI? Because ComfyUI is increasingly where people assemble the whole pipeline - caption a batch of images with a vision node, embed the captions, store the vectors, then later embed a query and find the nearest neighbors. The pack even pairs this with the Save Embedding (.npy) node so you can persist vectors to disk for reuse. If your workflow has no use for a vector, this node is not for you - it produces math, not prose.

How it works

It calls embed_content with two knobs that actually matter:

  • task_type - tells the model what the vector is for. SEMANTIC_SIMILARITY (default), CLASSIFICATION, CLUSTERING, RETRIEVAL_QUERY, RETRIEVAL_DOCUMENT, QUESTION_ANSWERING, FACT_VERIFICATION, CODE_RETRIEVAL_QUERY. This is not cosmetic - a retrieval-document embedding and a retrieval-query embedding are trained to be comparable with each other, so pick the task and use it consistently.
  • output_dim - dimensionality, 128 to 3072 (default 768). Bigger isn't always better; 768 is the sweet spot, and lower dims are cheaper to store and search.

Models: gemini-embedding-001 (default) and the newer gemini-embedding-2-preview, both listed in the dropdown.

Outputs: embedding_json (the vector as a JSON list of floats - wire it into EmbedSave or any JSON-consuming node) and dim (the dimensionality as an INT, handy for logging or validation).

Installation

Part of the NanoBanana2 pack:

cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-NanoBanana2
pip install google-genai

ComfyUI Manager: search NanoBanana2. Needs a Gemini API key from aistudio.google.com.

Gotchas

The classic mistake is mixing task types - embedding your documents with RETRIEVAL_DOCUMENT and your queries with SEMANTIC_SIMILARITY and wondering why similarity scores are garbage. Pick one scheme and stay consistent. And note this node embeds a single text blob; if you want to embed a whole batch of captions, you'll loop it or call it per item - there's no batch input here. It's also a paid API call per embed, though embedding tokens are cheap. Finally, keep output_dim fixed across a project; two vectors of different dims can't be compared, and you'll find out at the worst time.

CategoryNanoBanana2/Embeddings

Inputs (7)

NameTypeDefaultDescription
api_keySTRING
modelCOMBOgemini-embedding-0013 options: gemini-embedding-2, gemini-embedding-2-preview, gemini-embedding-001
textSTRING
custom_modeloptSTRING
task_typeoptCOMBOSEMANTIC_SIMILARITYOptimize the embedding for this downstream task.
output_dimoptINT768128–3072Output dimensionality. 768 is default. Larger = more expressive.
networkoptNB_NETWORKOptional. Wire a NanoBanana - Network Route node here to route this request through that proxy (e.g. US egress).

Outputs (2)

NameTypeDescription
embedding_jsonSTRING
dimINT