{"record":{"id":"f75b378d54f6e373","repo":"Comfy-Org/ComfyUI","slug":"too-much-media-to-send-inline-over-max-inline-by","errorCode":null,"errorMessage":"Too much media to send inline (over {max_inline_bytes // (1024 * 1024)}MB{detail}). Reduce the number or size of attached media.","messagePattern":"Too much media to send inline \\(over (.+?)MB(.+?)\\)\\. Reduce the number or size of attached media\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_gemini.py","lineNumber":401,"sourceCode":"    units: list[tuple[str, Any]] = (\n        [(\"video\", v) for v in videos]\n        + [(\"audio\", a) for a in _flatten_audio(audios)]\n        + [(\"image\", f) for f in _flatten_images(images)]\n    )\n\n    parts: list[GeminiPart] = []\n    url_used = 0\n    inline_bytes = 0\n    for kind, payload in units:\n        if url_used < url_budget:\n            parts.append(await _media_url_part(cls, kind, payload))\n            url_used += 1\n            continue\n        part, nbytes = _media_inline_part(kind, payload)\n        inline_bytes += nbytes\n        if inline_bytes > max_inline_bytes:\n            detail = f\" after the first {url_budget} inputs are uploaded as URLs\" if url_budget else \"\"\n            raise ValueError(\n                f\"Too much media to send inline (over {max_inline_bytes // (1024 * 1024)}MB{detail}). \"\n                \"Reduce the number or size of attached media.\"\n            )\n        parts.append(part)\n    return parts\n\n\ndef to_interaction_media_part(part: GeminiPart) -> GeminiInteractionMediaPart:\n    \"\"\"Convert a fileData/inlineData GeminiPart into an Interactions API media part.\"\"\"\n    if part.fileData:\n        mime = part.fileData.mimeType.value\n        return GeminiInteractionMediaPart(type=mime.split(\"/\")[0], uri=part.fileData.fileUri, mime_type=mime)\n    mime = part.inlineData.mimeType.value\n    return GeminiInteractionMediaPart(type=mime.split(\"/\")[0], data=part.inlineData.data, mime_type=mime)\n\n\nclass GeminiNode(IO.ComfyNode):\n    \"\"\"","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_gemini.py#L383-L419","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reduce the number of attached media inputs (drop videos or images you do not need).","Reduce the size of each media item: downscale images, re-encode video at lower resolution/bitrate or shorter duration.","Split the work into multiple interactions, each with fewer/smaller media files.","For images, rely on the URL upload path by keeping total media count within the url_budget so fewer inputs are inlined."],"exampleFix":"// before\nmedia = [load_video('clip1.mp4'), load_video('clip2.mp4'), load_video('clip3.mp4')]  # >90MiB combined\nawait omni.execute(model={'videos': media, ...}, seed=1)  # raises: Too much media to send inline...\n\n// after\nmedia = [reencode(load_video('clip1.mp4'), bitrate='2M'), load_video('clip2.mp4')]  # under budget\nawait omni.execute(model={'videos': media, ...}, seed=1)","handlingStrategy":"validation","validationCode":"MAX_INLINE = 90 * 1024 * 1024\ndef estimate_inline_bytes(media_list, url_budget):\n    inline = [m for i, m in enumerate(media_list) if i >= url_budget]\n    return sum(len(m.encode()) for m in inline)  # or file size / base64 estimate\nassert estimate_inline_bytes(media, url_budget) <= MAX_INLINE, \"reduce media count/size first\"","typeGuard":null,"tryCatchPattern":"try:\n    parts = await build_gemini_media_parts(cls, images, [], videos, url_budget=0, max_inline_bytes=MAX_INLINE)\nexcept ValueError as e:\n    if \"Too much media\" in str(e):\n        raise UserFacingError(\"Attach fewer or smaller videos (inline budget 90 MiB)\") from e\n    raise","preventionTips":["Re-encode videos to modest resolution/bitrate before attaching.","Count media against the 90 MiB inline budget before building the request.","Prefer fewer, shorter clips; split large jobs into multiple interactions."],"tags":["gemini","interactions-api","payload-limit","media-upload","comfy-api-nodes"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}