MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / _make_video_api_request

Method _make_video_api_request

src/services/flow_client.py:984–1016  ·  view source on GitHub ↗

视频 API 加硬截止,避免 curl_cffi 底层偶发卡住导致整条请求悬挂。

(
        self,
        url: str,
        json_data: Dict[str, Any],
        at: str,
        timeout: int,
        project_id: Optional[str] = None,
        token_id: Optional[int] = None,
        action: str = "VIDEO_GENERATION",
    )

Source from the content-addressed store, hash-verified

982 return fallback
983
984 async def _make_video_api_request(
985 self,
986 url: str,
987 json_data: Dict[str, Any],
988 at: str,
989 timeout: int,
990 project_id: Optional[str] = None,
991 token_id: Optional[int] = None,
992 action: str = "VIDEO_GENERATION",
993 ) -> Dict[str, Any]:
994 """视频 API 加硬截止,避免 curl_cffi 底层偶发卡住导致整条请求悬挂。"""
995 raw_body = json.dumps(json_data, ensure_ascii=False, separators=(",", ":"))
996 headers = self._build_realistic_video_submit_headers()
997 headers.update(self._build_labs_request_context_headers(project_id))
998 try:
999 return await asyncio.wait_for(
1000 self._make_request(
1001 method="POST",
1002 url=url,
1003 headers=headers,
1004 json_data=json_data,
1005 raw_body=raw_body,
1006 use_at=True,
1007 at_token=at,
1008 timeout=timeout,
1009 allow_urllib_fallback=False,
1010 apply_default_client_headers=False,
1011 impersonate=self._resolve_runtime_impersonate(),
1012 ),
1013 timeout=timeout + 5
1014 )
1015 except asyncio.TimeoutError as exc:
1016 raise Exception(f"Flow video API request timed out after {timeout}s") from exc
1017
1018 async def _acquire_image_launch_gate(
1019 self,

Callers 7

generate_video_textMethod · 0.95
generate_video_extendMethod · 0.95
upsample_videoMethod · 0.95
check_video_statusMethod · 0.95

Tested by

no test coverage detected