Comfy-Org/ComfyUI · error · ValueError
Invalid size for sora-2 model, only 720x1280 and 1280x720 ar
Error message
Invalid size for sora-2 model, only 720x1280 and 1280x720 are supported.
What it means
Raised by the Sora-2 node when model is "sora-2" and the size parameter is not one of the two supported resolutions (720x1280 portrait or 1280x720 landscape). Other models in the node skip this check. It fires before any request is sent to the OpenAI proxy endpoint.
Source
Thrown at comfy_api_nodes/nodes_sora.py:127
($isProSize ? 0.5 : 0.1);
{"type":"usd","usd": $round($perSec * $dur, 2)}
)
""",
),
)
@classmethod
async def execute(
cls,
model: str,
prompt: str,
size: str = "1280x720",
duration: int = 8,
seed: int = 0,
image: Optional[torch.Tensor] = None,
):
if model == "sora-2" and size not in ("720x1280", "1280x720"):
raise ValueError("Invalid size for sora-2 model, only 720x1280 and 1280x720 are supported.")
files_input = None
if image is not None:
if get_number_of_images(image) != 1:
raise ValueError("Currently only one input image is supported.")
files_input = {"input_reference": ("image.png", tensor_to_bytesio(image), "image/png")}
initial_response = await sync_op(
cls,
endpoint=ApiEndpoint(path="/proxy/openai/v1/videos", method="POST"),
data=Sora2GenerationRequest(
model=model,
prompt=prompt,
seconds=str(duration),
size=size,
),
files=files_input,
response_model=Sora2GenerationResponse,
content_type="multipart/form-data",
)View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Set size to exactly "720x1280" or "1280x720"
- Pick the orientation matching your content: 720x1280 for vertical, 1280x720 for horizontal
Example fix
# before generate(model="sora-2", size="1920x1080", ...) # after generate(model="sora-2", size="1280x720", ...)
Defensive patterns
Strategy: validation
Validate before calling
SORA2_SIZES = {"720x1280", "1280x720"}
if model == "sora-2":
assert size in SORA2_SIZES, f"sora-2 size must be one of {SORA2_SIZES}, got {size!r}" Type guard
def is_valid_sora2_size(model: str, size: str) -> bool:
return model != "sora-2" or size in ("720x1280", "1280x720") Try / catch
try:
await sora_execute(model="sora-2", size=size, ...)
except ValueError as e:
if "Invalid size" in str(e):
await sora_execute(model="sora-2", size="1280x720", ...)
else:
raise Prevention
- Hard-code the two allowed sora-2 sizes in workflow templates
- Choose orientation from your input image's aspect ratio before calling
When it happens
Trigger: Calling the Sora node with model="sora-2" and size set to anything else (e.g. "1920x1080", "1024x1024", or a typo like "1280x720 ").
Common situations: Copying size settings from other video nodes that accept arbitrary resolutions; assuming sora-2 supports square or 1080p output; string formatting mistakes (extra spaces, uppercase X).
Related errors
- Custom resolution is only supported by GPT Image 2 model
- Custom width and height must be multiples of 16, got {custom
- Custom resolution max edge must be <= 3840, got {custom_widt
- Custom resolution aspect ratio must not exceed 3:1, got {cus
- Custom resolution total pixels must be between 655,360 and 8
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/c6de88df4be19d21.
Report an issue: GitHub.