440440 },
441441
442442 # ========== 多图生成 (R2V - Reference Images to Video) ==========
443- # 支持多张图片,不限制数量
443+ # 当前上游协议最多支持 3 张参考图
444444
445445 # veo_3_1_r2v_fast (横竖屏)
446446 "veo_3_1_r2v_fast_portrait" : {
450450 "aspect_ratio" : "VIDEO_ASPECT_RATIO_PORTRAIT" ,
451451 "supports_images" : True ,
452452 "min_images" : 0 ,
453- "max_images" : None # 不限制
453+ "max_images" : 3
454454 },
455455 "veo_3_1_r2v_fast" : {
456456 "type" : "video" ,
457457 "video_type" : "r2v" ,
458- "model_key" : "veo_3_1_r2v_fast " ,
458+ "model_key" : "veo_3_1_r2v_fast_landscape " ,
459459 "aspect_ratio" : "VIDEO_ASPECT_RATIO_LANDSCAPE" ,
460460 "supports_images" : True ,
461461 "min_images" : 0 ,
462- "max_images" : None # 不限制
462+ "max_images" : 3
463463 },
464464
465465 # veo_3_1_r2v_fast_ultra (横竖屏)
470470 "aspect_ratio" : "VIDEO_ASPECT_RATIO_PORTRAIT" ,
471471 "supports_images" : True ,
472472 "min_images" : 0 ,
473- "max_images" : None # 不限制
473+ "max_images" : 3
474474 },
475475 "veo_3_1_r2v_fast_ultra" : {
476476 "type" : "video" ,
477477 "video_type" : "r2v" ,
478- "model_key" : "veo_3_1_r2v_fast_ultra " ,
478+ "model_key" : "veo_3_1_r2v_fast_landscape_ultra " ,
479479 "aspect_ratio" : "VIDEO_ASPECT_RATIO_LANDSCAPE" ,
480480 "supports_images" : True ,
481481 "min_images" : 0 ,
482- "max_images" : None # 不限制
482+ "max_images" : 3
483483 },
484484
485485 # veo_3_1_r2v_fast_ultra_relaxed (横竖屏)
490490 "aspect_ratio" : "VIDEO_ASPECT_RATIO_PORTRAIT" ,
491491 "supports_images" : True ,
492492 "min_images" : 0 ,
493- "max_images" : None # 不限制
493+ "max_images" : 3
494494 },
495495 "veo_3_1_r2v_fast_ultra_relaxed" : {
496496 "type" : "video" ,
497497 "video_type" : "r2v" ,
498- "model_key" : "veo_3_1_r2v_fast_ultra_relaxed " ,
498+ "model_key" : "veo_3_1_r2v_fast_landscape_ultra_relaxed " ,
499499 "aspect_ratio" : "VIDEO_ASPECT_RATIO_LANDSCAPE" ,
500500 "supports_images" : True ,
501501 "min_images" : 0 ,
502- "max_images" : None # 不限制
502+ "max_images" : 3
503503 },
504504
505505 # ========== 视频放大 (Video Upsampler) ==========
625625 "aspect_ratio" : "VIDEO_ASPECT_RATIO_PORTRAIT" ,
626626 "supports_images" : True ,
627627 "min_images" : 0 ,
628- "max_images" : None ,
628+ "max_images" : 3 ,
629629 "upsample" : {"resolution" : "VIDEO_RESOLUTION_4K" , "model_key" : "veo_3_1_upsampler_4k" }
630630 },
631631 "veo_3_1_r2v_fast_ultra_4k" : {
632632 "type" : "video" ,
633633 "video_type" : "r2v" ,
634- "model_key" : "veo_3_1_r2v_fast_ultra " ,
634+ "model_key" : "veo_3_1_r2v_fast_landscape_ultra " ,
635635 "aspect_ratio" : "VIDEO_ASPECT_RATIO_LANDSCAPE" ,
636636 "supports_images" : True ,
637637 "min_images" : 0 ,
638- "max_images" : None ,
638+ "max_images" : 3 ,
639639 "upsample" : {"resolution" : "VIDEO_RESOLUTION_4K" , "model_key" : "veo_3_1_upsampler_4k" }
640640 },
641641
647647 "aspect_ratio" : "VIDEO_ASPECT_RATIO_PORTRAIT" ,
648648 "supports_images" : True ,
649649 "min_images" : 0 ,
650- "max_images" : None ,
650+ "max_images" : 3 ,
651651 "upsample" : {"resolution" : "VIDEO_RESOLUTION_1080P" , "model_key" : "veo_3_1_upsampler_1080p" }
652652 },
653653 "veo_3_1_r2v_fast_ultra_1080p" : {
654654 "type" : "video" ,
655655 "video_type" : "r2v" ,
656- "model_key" : "veo_3_1_r2v_fast_ultra " ,
656+ "model_key" : "veo_3_1_r2v_fast_landscape_ultra " ,
657657 "aspect_ratio" : "VIDEO_ASPECT_RATIO_LANDSCAPE" ,
658658 "supports_images" : True ,
659659 "min_images" : 0 ,
660- "max_images" : None ,
660+ "max_images" : 3 ,
661661 "upsample" : {"resolution" : "VIDEO_RESOLUTION_1080P" , "model_key" : "veo_3_1_upsampler_1080p" }
662662 }
663663}
@@ -1258,7 +1258,7 @@ async def _handle_video_generation(
12581258 # veo_3_1_i2v_s_fast_portrait_fl -> veo_3_1_i2v_s_fast_portrait_ultra_fl
12591259 # veo_3_1_t2v_fast -> veo_3_1_t2v_fast_ultra
12601260 # veo_3_1_t2v_fast_portrait -> veo_3_1_t2v_fast_portrait_ultra
1261- # veo_3_0_r2v_fast -> veo_3_0_r2v_fast_ultra
1261+ # veo_3_1_r2v_fast_landscape -> veo_3_1_r2v_fast_landscape_ultra
12621262 if "_fl" in model_key :
12631263 model_key = model_key .replace ("_fl" , "_ultra_fl" )
12641264 else :
@@ -1275,6 +1275,7 @@ async def _handle_video_generation(
12751275 if "ultra" in model_key :
12761276 # veo_3_1_i2v_s_fast_ultra_fl -> veo_3_1_i2v_s_fast_fl
12771277 # veo_3_1_t2v_fast_ultra -> veo_3_1_t2v_fast
1278+ # veo_3_1_r2v_fast_landscape_ultra -> veo_3_1_r2v_fast_landscape
12781279 model_key = model_key .replace ("_ultra_fl" , "_fl" ).replace ("_ultra" , "" )
12791280
12801281 if stream :
@@ -1308,10 +1309,14 @@ async def _handle_video_generation(
13081309 yield self ._create_error_response (error_msg )
13091310 return
13101311
1311- # R2V: 多图生成 - 支持多张图片,不限制数量
1312+ # R2V: 多图生成 - 当前上游协议最多 3 张参考图
13121313 elif video_type == "r2v" :
1313- # 不再限制最大图片数量
1314- pass
1314+ if max_images is not None and image_count > max_images :
1315+ error_msg = f"❌ 多图视频模型最多支持 { max_images } 张参考图,当前提供了 { image_count } 张"
1316+ if stream :
1317+ yield self ._create_stream_chunk (f"{ error_msg } \n " )
1318+ yield self ._create_error_response (error_msg )
1319+ return
13151320
13161321 # ========== 上传图片 ==========
13171322 start_media_id = None
@@ -1346,7 +1351,7 @@ async def _handle_video_generation(
13461351 if stream :
13471352 yield self ._create_stream_chunk (f"上传 { image_count } 张参考图片...\n " )
13481353
1349- for idx , img in enumerate ( images ): # 上传所有图片,不限制数量
1354+ for img in images :
13501355 media_id = await self .flow_client .upload_image (
13511356 token .at , img , model_config ["aspect_ratio" ], project_id = project_id
13521357 )
@@ -1752,4 +1757,3 @@ async def _log_request(
17521757 except Exception as e :
17531758 # 日志记录失败不影响主流程
17541759 debug_logger .log_error (f"Failed to log request: { e } " )
1755-
0 commit comments