calesthio/OpenMontage · error · ValueError
Ark request body must be smaller than 64 MB
Error message
Ark request body must be smaller than 64 MB
What it means
Raised by SeedanceArkVideo._validate_request_size when the summed size of base64 data: URLs inside payload['content'] reaches MAX_REQUEST_BYTES (64 MB). Ark rejects oversized request bodies at the HTTP layer, so the client pre-computes the dominant cost — the encoded media — and fails fast instead of uploading 64+ MB only to get a 413.
Source
Thrown at tools/video/seedance_ark.py:1236
if safety is not None and len(str(safety)) > 64:
raise ValueError("safety_identifier must be at most 64 characters")
def _validate_request_size(self, payload: dict[str, Any]) -> None:
# Base64 dominates request size; summing encoded media is a conservative
# lower-cost check that avoids building a second complete JSON string.
encoded_bytes = 0
for item in payload["content"]:
media = (
item.get("image_url")
or item.get("audio_url")
or item.get("video_url")
or {}
)
url = str(media.get("url", ""))
if url.startswith("data:"):
encoded_bytes += len(url.encode("ascii"))
if encoded_bytes >= self.MAX_REQUEST_BYTES:
raise ValueError("Ark request body must be smaller than 64 MB")
@staticmethod
def _media_counts(content: list[dict[str, Any]]) -> dict[str, int]:
return {
kind: sum(1 for item in content if item.get("type") == kind)
for kind in ("text", "image_url", "video_url", "audio_url")
}
def _headers(self, api_key: str) -> dict[str, str]:
return {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
}
def _create_task(self, payload: dict[str, Any], api_key: str) -> str:
import requests
response = requests.post(View on GitHub (pinned to 95e1c3d0ab)
Solutions
- Upload media to accessible storage (S3, OSS, any https URL Ark can fetch) and pass URLs instead of data: URLs.
- Reduce media resolution/bitrate or trim audio/video clips before base64-encoding.
- Split the request: generate with fewer references per call instead of one mega-payload.
- If local-only operation is required, ensure combined base64 payload stays well under 64 MB (remember base64 adds ~33% over raw bytes).
Example fix
# before
content.append({"type": "image_url", "image_url": {"url": f"data:image/png;base64,{b64}"}})
# after
content.append({"type": "image_url", "image_url": {"url": uploaded_https_url}}) Defensive patterns
Strategy: validation
Validate before calling
MAX = 64 * 1024 * 1024
total = sum(len(str((it.get("image_url") or it.get("audio_url") or it.get("video_url") or {}).get("url", ""))) for it in content if str((it.get("image_url") or it.get("audio_url") or it.get("video_url") or {}).get("url", "")).startswith("data:"))
if total >= MAX:
content = [replace_data_urls_with_https(it) for it in content] # upload media first Try / catch
try:
result = tool.run(inputs)
except ValueError as e:
if "64 MB" in str(e):
inputs = upload_media_and_swap_to_https(inputs)
result = tool.run(inputs)
else:
raise Prevention
- Prefer hosted https URLs over data: URLs for any media over ~1 MB.
- Remember base64 inflates payloads ~33% over raw file size when budgeting.
When it happens
Trigger: Passing inline base64 images/audio/video (data: URLs) in content items whose combined encoded length reaches 64 MB — e.g. one 50 MB base64 video plus a 20 MB base64 image, or several ~10 MB images in a multi-reference request.
Common situations: Using local files converted to data URLs instead of uploading them to object storage and passing https URLs; high-resolution reference images from phones or stock libraries; batches that worked individually but are combined into one reference-conditioned generation.
Related errors
- Unknown or invalid style_playbook {style_playbook!r}. Availa
- Artifact {artifact_name!r} must be a JSON object matching it
- Artifact {artifact_name!r} failed schema validation: {exc}
- text_to_video does not accept reference media; use image_to_
- image_to_video requires exactly one reference image
AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15).
Data as JSON: /api/errors/20675ade4ea232b2.
Report an issue: GitHub.