calesthio/OpenMontage · error · ValueError
duration_seconds is required for cost estimation
Error message
duration_seconds is required for cost estimation
What it means
Raised by fal_elevenlabs_music.estimate_cost when inputs has no duration_seconds. Because fal bills per output minute ($0.80/min rounded up), cost cannot be computed without a duration; the tool deliberately refuses to guess instead of defaulting silently.
Source
Thrown at tools/audio/fal_elevenlabs_music.py:131
"Listen to the generated music for mood, mix, and duration",
]
_MODEL = "fal-ai/elevenlabs/music"
_QUEUE_URL = f"https://queue.fal.run/{_MODEL}"
_POLL_INTERVAL_SECONDS = 5
_MAX_WAIT_SECONDS = 600
def _get_api_key(self) -> str | None:
return os.environ.get("FAL_KEY") or os.environ.get("FAL_AI_API_KEY")
def get_status(self) -> ToolStatus:
return ToolStatus.AVAILABLE if self._get_api_key() else ToolStatus.UNAVAILABLE
def estimate_cost(self, inputs: dict[str, Any]) -> float:
"""fal bills $0.80 per output minute, rounded up to a full minute."""
duration = inputs.get("duration_seconds")
if duration is None:
raise ValueError("duration_seconds is required for cost estimation")
return round(math.ceil(float(duration) / 60.0) * 0.80, 2)
def execute(self, inputs: dict[str, Any]) -> ToolResult:
api_key = self._get_api_key()
if not api_key:
return ToolResult(
success=False,
error="No fal.ai API key found. " + self.install_instructions,
)
duration = inputs.get("duration_seconds")
if duration is None:
return ToolResult(success=False, error="duration_seconds is required")
duration = float(duration)
if not 3 <= duration <= 600:
return ToolResult(
success=False,
error="duration_seconds must be between 3 and 600",View on GitHub (pinned to 95e1c3d0ab)
Solutions
- Pass duration_seconds (number of seconds) in inputs before any cost estimation
- Derive it from the approved target runtime in the script/proposal rather than a constant
- Add a schema/validation check upstream that rejects inputs without duration_seconds early
Example fix
// before
inputs = {"prompt": "upbeat jingle"}
cost = tool.estimate_cost(inputs) # raises
// after
inputs = {"prompt": "upbeat jingle", "duration_seconds": 30}
cost = tool.estimate_cost(inputs) Defensive patterns
Strategy: validation
Validate before calling
if "duration_seconds" not in inputs or inputs["duration_seconds"] is None:
raise ValueError("duration_seconds required before estimating fal music cost") Prevention
- Assemble complete inputs (including duration) before any estimate_cost call
- Derive duration from the approved runtime, never a hardcoded default
- Centralize input schema checks in the orchestrator
When it happens
Trigger: Calling estimate_cost (directly or via a cost-checking planner) with inputs lacking duration_seconds; execute() later enforces the same requirement.
Common situations: A pipeline/orchestrator calls estimate_cost before assembling full inputs; dict key typo (duration, length) instead of duration_seconds; porting code from a tool that defaulted the duration.
Related errors
- music_gen.estimate_cost: duration_seconds is required. Deriv
- model_id must be one of: {choices}
- ${res.status} ${url}
- fetch failed ${r.status}: ${url}
- path escapes project
AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15).
Data as JSON: /api/errors/ce7ef28ce156ec73.
Report an issue: GitHub.