Nodes/ComfyUI-NanoBanana2/NanoBanana - Save Embedding (.npy)
ComfyUI Node

NanoBanana - Save Embedding (.npy)

Persist an embedding to disk so you don't re-pay for it

By IxMxAMAR·Created 6 months ago·Updated about a month ago· 4
NanoBanana - Save Embedding (.npy)
    • saved_path
    embedding_json
    filenameembedding.npy
    subdirectoryembeddings

    Every embedding you generate costs an API call. If your pipeline embeds a thousand captions and you don't save them, that's a thousand paid calls to redo next time. This node is the save button for that pipeline: it takes the JSON vector output of the pack's Text Embeddings node and writes it to disk as a standard NumPy .npy file, ready for vector databases, similarity search, or any downstream ML step.

    It's deliberately simple and does one job well. You won't build your search index inside this node - it just persists a vector - but without a persistence step, the whole embed-and-search story falls apart.

    How it works

    Give it an embedding_json string (the embedding_json output of NanoBanana_Embed), a filename, and optionally a subdirectory, and it parses the JSON into a float array and calls numpy.save. The file lands in your ComfyUI output directory - under output/embeddings/ by default, or wherever you point the subdirectory. It returns the absolute saved_path as a STRING.

    Two details show the pack was built by someone who's been burned. The filename gets basename-sanitized and the subdirectory does too, so a ../../-style path can't escape the output dir - useful if you ever feed filenames from an untrusted source. And it appends the .npy extension for you if you forgot it, because everyone forgets it. It's also flagged as an output node, so it shows up properly in the UI as something that writes a file.

    Inputs:

    • embedding_json - the JSON list of floats from the Embed node.
    • filename - embedding.npy by default; with or without the extension.
    • subdirectory - embeddings by default.

    Output: saved_path - the absolute path to the written file.

    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 NumPy (ComfyUI already ships it). Note this node doesn't need an API key itself - it's pure file I/O - so you can save previously-generated vectors without touching Google.

    Gotchas

    The one real trap is feeding it something that isn't a vector. If embedding_json isn't a JSON list of numbers - say you wired the wrong node's output into it - it raises a clear error, so the failure is loud rather than silent. And remember .npy is a binary format, not human-readable JSON; if you need the vector in a portable text format, save the JSON from the Embed node instead. Finally, the path it returns is absolute and machine-specific - don't hardcode it into a workflow you'll share; re-derive it on the target machine.

    CategoryNanoBanana2/Embeddings

    Inputs (3)

    NameTypeDefaultDescription
    embedding_jsonSTRINGJSON list of floats (output of NanoBanana Text Embeddings node).
    filenameSTRINGembedding.npyFilename (with or without .npy extension). Written to ComfyUI output dir.
    subdirectoryoptSTRINGembeddingsSubdirectory under ComfyUI's output dir.

    Outputs (1)

    NameTypeDescription
    saved_pathSTRING