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

Method generate_video_text

src/services/flow_client.py:2122–2266  ·  view source on GitHub ↗

文生视频,返回task_id Args: at: Access Token project_id: 项目ID prompt: 提示词 model_key: veo_3_1_t2v_fast 等 aspect_ratio: 视频宽高比 user_paygate_tier: 用户等级 Returns: { "operations": [{

(
        self,
        at: str,
        project_id: str,
        prompt: str,
        model_key: str,
        aspect_ratio: str,
        use_v2_model_config: bool = False,
        user_paygate_tier: str = "PAYGATE_TIER_ONE",
        token_id: Optional[int] = None,
        token_video_concurrency: Optional[int] = None,
    )

Source from the content-addressed store, hash-verified

2120 return media_refs
2121
2122 async def generate_video_text(
2123 self,
2124 at: str,
2125 project_id: str,
2126 prompt: str,
2127 model_key: str,
2128 aspect_ratio: str,
2129 use_v2_model_config: bool = False,
2130 user_paygate_tier: str = "PAYGATE_TIER_ONE",
2131 token_id: Optional[int] = None,
2132 token_video_concurrency: Optional[int] = None,
2133 ) -> dict:
2134 """文生视频,返回task_id
2135
2136 Args:
2137 at: Access Token
2138 project_id: 项目ID
2139 prompt: 提示词
2140 model_key: veo_3_1_t2v_fast 等
2141 aspect_ratio: 视频宽高比
2142 user_paygate_tier: 用户等级
2143
2144 Returns:
2145 {
2146 "operations": [{
2147 "operation": {"name": "task_id"},
2148 "sceneId": "uuid",
2149 "status": "MEDIA_GENERATION_STATUS_PENDING"
2150 }],
2151 "remainingCredits": 900
2152 }
2153 """
2154 url = f"{self.api_base_url}/video:batchAsyncGenerateVideoText"
2155
2156 # 403/reCAPTCHA 重试逻辑 - reCAPTCHA evaluation failed 时允许更高重试上限
2157 max_retries = self._resolve_generation_retry_budget(config.flow_max_retries)
2158 last_error = None
2159 retry_attempt = 0
2160 session_id = self._generate_session_id()
2161 batch_id = str(uuid.uuid4())
2162 video_context_warmed = False
2163 while retry_attempt < max_retries:
2164 # 每次重试都重新获取 reCAPTCHA token - 视频使用 VIDEO_GENERATION action
2165 launch_gate_acquired = False
2166 launch_ok, _, _ = await self._acquire_video_launch_gate(
2167 token_id=token_id,
2168 token_video_concurrency=token_video_concurrency,
2169 )
2170 if not launch_ok:
2171 last_error = Exception("Video launch queue wait timeout")
2172 raise last_error
2173
2174 launch_gate_acquired = True
2175 try:
2176 recaptcha_token, browser_id = await self._get_recaptcha_token(
2177 project_id,
2178 action="VIDEO_GENERATION",
2179 token_id=token_id