ATH-MaaS/Pixelle-Video · error · KeyError
Invalid response format: missing 'video_prompts'
Error message
Invalid response format: missing 'video_prompts'
What it means
generate_video_prompts expects the LLM to answer each batch with JSON containing a 'video_prompts' key. If the parsed JSON lacks that key, a KeyError('Invalid response format: missing 'video_prompts'') is raised. Unlike the image variant it is raised immediately per attempt (no graceful count-retry messaging), so the exception surfaces whenever the model ignores the required schema.
Source
Thrown at pixelle_video/utils/content_generators.py:432
prompt = build_video_prompt_prompt(
narrations=batch_narrations,
min_words=min_words,
max_words=max_words
)
response = await llm_service(
prompt=prompt,
temperature=0.7,
max_tokens=8192
)
logger.debug(f"Batch {batch_idx} attempt {attempt}: LLM response length: {len(response)} chars")
# Parse JSON
result = _parse_json(response)
if "video_prompts" not in result:
raise KeyError("Invalid response format: missing 'video_prompts'")
batch_prompts = result["video_prompts"]
# Validate batch result
if len(batch_prompts) != len(batch_narrations):
raise ValueError(
f"Prompt count mismatch: expected {len(batch_narrations)}, got {len(batch_prompts)}"
)
# Success - add to all_prompts
all_prompts.extend(batch_prompts)
logger.info(f"✓ Batch {batch_idx} completed: {len(batch_prompts)} video prompts")
# Report progress
if progress_callback:
completed = len(all_prompts)
total = len(narrations)
progress_callback(completed, total, f"Batch {batch_idx}/{len(batches)} completed")View on GitHub (pinned to 848b054e4f)
Solutions
- Retry the batch generation — model nondeterminism often produces valid JSON on a later attempt.
- Log/inspect the raw response and tighten the prompt to require the exact key "video_prompts".
- Enable provider JSON mode or a response schema forcing the key.
- Accept a top-level array as fallback before raising.
- Use a stronger model for video prompt generation.
Example fix
// before
result = _parse_json(response)
if "video_prompts" not in result:
raise KeyError("Invalid response format: missing 'video_prompts'")
// after
result = _parse_json(response)
if "video_prompts" not in result:
if isinstance(result, list):
result = {"video_prompts": result}
else:
raise KeyError("Invalid response format: missing 'video_prompts'") Defensive patterns
Strategy: validation
Validate before calling
def looks_like_video_prompt_response(payload) -> bool:
return isinstance(payload, dict) and isinstance(payload.get("video_prompts"), list) and len(payload["video_prompts"]) > 0 Type guard
def has_video_prompts(obj: object) -> bool:
return isinstance(obj, dict) and isinstance(obj.get("video_prompts"), list) and all(isinstance(p, str) for p in obj["video_prompts"]) Try / catch
try:
prompts = generator.generate_video_prompts(narrations)
except KeyError as e:
if "video_prompts" in str(e):
logger.warning("LLM returned unexpected shape; retrying")
prompts = generator.generate_video_prompts(narrations)
else:
raise Prevention
- Enable JSON/structured output mode on the LLM client
- Include a literal output example with the "video_prompts" key in the prompt
- Retry failed batches automatically
- Pin to a model version that reliably follows JSON instructions
When it happens
Trigger: Calling generate_video_prompts where _parse_json(response) yields a dict without 'video_prompts' — model returns prompts under another key, returns prose, or returns a top-level array.
Common situations: Model producing motion-caption-style text instead of JSON; schema instructions lost when customizing the prompt; provider switching to a model that resists JSON formatting; responses truncated so JSON parsed to an empty/partial object.
Related errors
- Invalid response format: missing 'narrations' key
- Invalid response format: missing 'image_prompts'
- Failed to parse LLM response as {response_type.__name__}: {c
- str(e)
- str(e)
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/52c650353eb5588e.
Report an issue: GitHub.