Nodes/comfyui-aichat/Gemini 文件上传器 (File API)
ComfyUI Node

Gemini 文件上传器 (File API)

Gemini's File API, without writing a line of Python

By spawner1145·Created about a year ago·Updated 11 days ago· 3
Gemini 文件上传器 (File API)
  • api_instance
  • content_item
  • file_uri
file_selector
use_absolute_pathfalse
absolute_path_override/path/to/your/file.pdf
display_name

When inline isn't enough

Inline images (what GeminiImageEncoder does) are fine for a frame or two. But documents, PDFs, audio, video, big files - those go through the File API, and that's this node's job. GeminiFileUploader takes a file from your ComfyUI input folder (or any absolute path on disk), uploads it to Google's servers, and hands you a fileUri that GeminiChat can reference. No base64 stuffed into the prompt, no giant request body.

How it works

You need an api_instance from GeminiApiLoader first - the upload runs through that same client. The node does a multipart POST to Google's /upload/v1beta/files endpoint with X-Goog-Upload-Protocol: multipart, then polls the file's status until it turns ACTIVE (or FAILED), waiting up to about two minutes. Only once the file is active does it return the URI. That "waiting for ACTIVE" step is why the node can feel slow with big files - it's not stuck, it's letting Google process the upload.

The fields that matter

  • file_selector - a dropdown of everything in your ComfyUI input directory. Pick one and go.
  • use_absolute_path / absolute_path_override - flip the toggle and type a full path instead, for files that live outside the input folder.
  • display_name - optional name shown on Google's side. Leave blank and it uses the filename.
  • api_instance - required, from the loader.

Outputs

content_item - the GEMINI_CONTENT_ITEM (a fileData dict with mimeType and fileUri) to wire into GeminiChat or a connector. file_uri - the raw URI string, if you want it elsewhere.

Where people get burned

  • The 1.9GB cap. The source refuses anything near 2GB. Realistic for a workflow, but don't plan on uploading a movie.
  • Files land on Google's servers and count against your key's storage. Upload a lot of big files and they accumulate; you'll want to clean them up.
  • MIME guessing. The node infers the type from the extension and falls back to application/octet-stream when it can't - and some models reject octet-stream. Give the file a proper extension.
  • Provider/API differences don't apply here (this is Google's own API), but the File API is a separate billing surface from chat tokens.
  • The file must actually exist at the resolved path - the dropdown only shows input-dir files, so absolute paths are on you.

Install

With the whole pack, via ComfyUI Manager (search "comfyui-aichat") or:

cd ComfyUI/custom_nodes
git clone https://github.com/spawner1145/comfyui-aichat

Restart ComfyUI. Dependencies are just httpx, openai, and PyYAML; no models to download. For single images, prefer the inline encoder - it's faster and doesn't leave files parked on Google's side.

CategoryGemini API/Content

Inputs (5)

NameTypeDefaultDescription
api_instanceGEMINI_API_INSTANCE
file_selectorCOMBO1 options: example.png
use_absolute_pathBOOLEANfalse
absolute_path_overrideSTRING/path/to/your/file.pdf
display_nameSTRINGOptional display name

Outputs (2)

NameTypeDescription
content_itemGEMINI_CONTENT_ITEM
file_uriSTRING