BerriAI/litellm · error · ValueError
prefetched_source_data is required for Vertex AI video edit.
Error message
prefetched_source_data is required for Vertex AI video edit. Ensure get_video_edit_prefetch_params is called by the handler.
What it means
Raised by the Vertex edit request transform when prefetched_source_data is None. In normal operation the LiteLLM handler (litellm/llms/custom_httpx/llm_http_handler.py:7680) calls get_video_edit_prefetch_params, performs the fetchPredictOperation call, and passes the operation JSON back in. This ValueError therefore means the transform was invoked directly or via a code path that skipped the prefetch step.
Source
Thrown at litellm/llms/vertex_ai/videos/transformation.py:690
def transform_video_edit_request(
self,
prompt: str,
video_id: str,
api_base: str,
litellm_params: GenericLiteLLMParams,
headers: dict,
extra_body: dict[str, object] | None = None,
prefetched_source_data: dict[str, Any] | None = None,
) -> tuple[str, dict]:
"""
Build a predictLongRunning edit request from the pre-fetched source video.
The actual fetchPredictOperation HTTP call is hoisted into the handler so
it can use the shared async/sync httpx client instead of blocking the loop.
"""
if prefetched_source_data is None:
raise ValueError(
"prefetched_source_data is required for Vertex AI video edit. "
"Ensure get_video_edit_prefetch_params is called by the handler."
)
if not prefetched_source_data.get("done", False):
raise ValueError("Source video generation is not complete yet. Check the video status before editing.")
source_response: Final[_VeoOperationResponse] = prefetched_source_data.get("response", {})
videos: Final = source_response.get("videos", [])
if not videos:
raise ValueError("No videos found in the completed operation. Cannot edit.")
source_video: Final = videos[0]
video_input: Final[dict[str, str]] = {}
if "gcsUri" in source_video:
video_input["gcsUri"] = source_video["gcsUri"]
elif "bytesBase64Encoded" in source_video:
video_input["bytesBase64Encoded"] = source_video["bytesBase64Encoded"]View on GitHub (pinned to 77b7c6c40c)
Solutions
- Use the standard litellm.video_edit(...) entry point so the handler performs the prefetch for you
- If calling the transform directly, first call get_video_edit_prefetch_params, HTTP GET that URL, and pass response.json() as prefetched_source_data
Example fix
# before
url, body = config.transform_video_edit_request(video_id, prompt, api_base, litellm_params, headers)
# ValueError: prefetched_source_data is required
# after
p_url, p_body = config.get_video_edit_prefetch_params(video_id, api_base, litellm_params, headers)
resp = httpx.get(p_url, headers=headers) # fetchPredictOperation
url, body = config.transform_video_edit_request(
video_id, prompt, api_base, litellm_params, headers,
prefetched_source_data=resp.json(),
) Defensive patterns
Strategy: validation
Validate before calling
def build_edit_request(config, video_id, prompt, api_base, litellm_params, headers, http_get):
p_url, _ = config.get_video_edit_prefetch_params(video_id, api_base, litellm_params, headers)
prefetched = http_get(p_url, headers).json() # fetchPredictOperation
return config.transform_video_edit_request(
video_id, prompt, api_base, litellm_params, headers,
prefetched_source_data=prefetched,
) Type guard
from typing import Any
def has_prefetched_source_data(kwargs: dict[str, Any]) -> bool:
return isinstance(kwargs.get("prefetched_source_data"), dict) Try / catch
try:
url, body = config.transform_video_edit_request(video_id, prompt, api_base, lp, headers, prefetched_source_data=prefetched)
except ValueError as e:
if "prefetched_source_data is required" in str(e):
raise RuntimeError("handler bug: prefetch step was skipped") from e
raise Prevention
- Prefer the public litellm.video_edit entry point over calling transformations directly
- If invoking transforms manually, always pair get_video_edit_prefetch_params + HTTP fetch + pass the JSON back in
- Assert prefetched_source_data is not None before calling the transform in custom handlers
When it happens
Trigger: Calling config.transform_video_edit_request(...) manually in custom code; a forked/modified handler that builds the edit request without first fetching the source operation; provider interface changes where a handler forgets the prefetch contract.
Common situations: Writing a custom video handler that mimics litellm's; upgrading litellm versions where the handler/prefetch contract shifted; unit tests invoking the transformation in isolation.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- No videos found in the completed operation. Cannot edit.
- Failed to extract video data: {e}
- Source video generation is not complete yet. Check the video
- Source video has neither gcsUri nor bytesBase64Encoded. Cann
- No operation name in Veo edit response: {response_data}
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/7fc38543c32f4cbf.
Report an issue: GitHub.