Comfy-Org/ComfyUI · error · ValueError

Too much media to send inline (over {max_inline_bytes // (10

Error message

Too much media to send inline (over {max_inline_bytes // (1024 * 1024)}MB{detail}). Reduce the number or size of attached media.

What it means

Raised by build_gemini_media_parts when the accumulated inline base64 payload for media parts exceeds max_inline_bytes (90 MiB for the Interactions API, which rejects requests over ~100 MiB). Only inputs beyond the url_budget get inlined — the first url_budget inputs are uploaded as URLs and don't count — so the error fires when the remaining media's inline size budget is exhausted. It is a client-side pre-flight guard so the request fails locally instead of being rejected by the API.

Source

Thrown at comfy_api_nodes/nodes_gemini.py:401

    units: list[tuple[str, Any]] = (
        [("video", v) for v in videos]
        + [("audio", a) for a in _flatten_audio(audios)]
        + [("image", f) for f in _flatten_images(images)]
    )

    parts: list[GeminiPart] = []
    url_used = 0
    inline_bytes = 0
    for kind, payload in units:
        if url_used < url_budget:
            parts.append(await _media_url_part(cls, kind, payload))
            url_used += 1
            continue
        part, nbytes = _media_inline_part(kind, payload)
        inline_bytes += nbytes
        if inline_bytes > max_inline_bytes:
            detail = f" after the first {url_budget} inputs are uploaded as URLs" if url_budget else ""
            raise ValueError(
                f"Too much media to send inline (over {max_inline_bytes // (1024 * 1024)}MB{detail}). "
                "Reduce the number or size of attached media."
            )
        parts.append(part)
    return parts


def to_interaction_media_part(part: GeminiPart) -> GeminiInteractionMediaPart:
    """Convert a fileData/inlineData GeminiPart into an Interactions API media part."""
    if part.fileData:
        mime = part.fileData.mimeType.value
        return GeminiInteractionMediaPart(type=mime.split("/")[0], uri=part.fileData.fileUri, mime_type=mime)
    mime = part.inlineData.mimeType.value
    return GeminiInteractionMediaPart(type=mime.split("/")[0], data=part.inlineData.data, mime_type=mime)


class GeminiNode(IO.ComfyNode):
    """

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Reduce the number of attached media inputs (drop videos or images you do not need).
  2. Reduce the size of each media item: downscale images, re-encode video at lower resolution/bitrate or shorter duration.
  3. Split the work into multiple interactions, each with fewer/smaller media files.
  4. For images, rely on the URL upload path by keeping total media count within the url_budget so fewer inputs are inlined.

Example fix

// before
media = [load_video('clip1.mp4'), load_video('clip2.mp4'), load_video('clip3.mp4')]  # >90MiB combined
await omni.execute(model={'videos': media, ...}, seed=1)  # raises: Too much media to send inline...

// after
media = [reencode(load_video('clip1.mp4'), bitrate='2M'), load_video('clip2.mp4')]  # under budget
await omni.execute(model={'videos': media, ...}, seed=1)
Defensive patterns

Strategy: validation

Validate before calling

MAX_INLINE = 90 * 1024 * 1024
def estimate_inline_bytes(media_list, url_budget):
    inline = [m for i, m in enumerate(media_list) if i >= url_budget]
    return sum(len(m.encode()) for m in inline)  # or file size / base64 estimate
assert estimate_inline_bytes(media, url_budget) <= MAX_INLINE, "reduce media count/size first"

Try / catch

try:
    parts = await build_gemini_media_parts(cls, images, [], videos, url_budget=0, max_inline_bytes=MAX_INLINE)
except ValueError as e:
    if "Too much media" in str(e):
        raise UserFacingError("Attach fewer or smaller videos (inline budget 90 MiB)") from e
    raise

Prevention

When it happens

Trigger: Passing more media units than the url_budget (or with url_budget=0, as the Interactions API accepts video only inline or via Files API URI) such that sum of inline bytes exceeds GEMINI_INTERACTIONS_MAX_INLINE_BYTES (90 MiB). Typical with several high-resolution videos or large batched image sets in the omni node.

Common situations: Multiple long/large MP4 videos attached to a Gemini omni interaction (url_budget=0 forces all video inline); large batched image tensors plus videos together exceeding the 90 MiB cap; users assuming the URL upload path covers all inputs when only the first N get URLs.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/f75b378d54f6e373. Report an issue: GitHub.