import '../api_client.dart'; import '../proxy_client.dart'; /// 图片/视频生成相关 API abstract final class ImageApi { static final _client = ApiClient.instance.proxy; /// 获取图转视频分类列表 static Future getCategoryList() async { return _client.request( path: '/v1/image/img2video/categories', method: 'GET', ); } /// 获取图转视频任务列表 /// insignia: categoryId static Future getImg2VideoTasks({int? insignia}) async { return _client.request( path: '/v1/image/img2video/tasks', method: 'GET', queryParams: insignia != null ? {'insignia': insignia.toString()} : null, ); } /// 获取推荐提示词 static Future getPromptRecommends({ required String sentinel, String? crest, String? asset, }) async { return _client.request( path: '/v1/image/prompt/recomends', method: 'GET', queryParams: { 'sentinel': sentinel, if (crest != null) 'crest': crest, if (asset != null) 'asset': asset, }, ); } /// 创建文生图任务 static Future createTxt2Img({ required String sentinel, required String ledger, String? crest, String? asset, String? quest, }) async { return _client.request( path: '/v1/image/txt2img_create', method: 'POST', queryParams: { 'sentinel': sentinel, if (crest != null) 'crest': crest, if (asset != null) 'asset': asset, }, body: { 'declaration': 1, if (quest != null) 'quest': quest, 'ledger': ledger, }, ); } /// 创建图转视频姿态任务 static Future createImg2VideoPose({ required String sentinel, required String asset, String? congregation, String? profit, String? compendium, String? notification, String? allowance, String? cosmos, }) async { return _client.request( path: '/v1/image/img2video_pose_task', method: 'POST', queryParams: { 'sentinel': sentinel, 'asset': asset, if (congregation != null) 'congregation': congregation, if (notification != null) 'notification': notification, if (allowance != null) 'allowance': allowance, if (cosmos != null) 'cosmos': cosmos, if (profit != null) 'profit': profit, if (compendium != null) 'compendium': compendium, }, ); } /// 查询任务进度 static Future getProgress({ required String sentinel, required String tree, String? asset, }) async { return _client.request( path: '/v1/image/progress', method: 'GET', queryParams: { 'sentinel': sentinel, 'tree': tree, if (asset != null) 'asset': asset, }, ); } /// 获取图转视频姿态模板 static Future getImg2VideoPoseTemplates({ required String sentinel, String? crest, String? asset, String? insignia, }) async { return _client.request( path: '/v1/image/img2Video_pose_template', method: 'GET', queryParams: { 'sentinel': sentinel, if (crest != null) 'crest': crest, if (asset != null) 'asset': asset, if (insignia != null) 'insignia': insignia, }, ); } /// 获取预签名上传 URL(图片上传不经过代理,直接 PUT 到返回的 URL) static Future getUploadPresignedUrl({ required String fileName1, String? fileName2, required String contentType, required int expectedSize, }) async { return _client.request( path: '/v1/image/upload-presigned-url', method: 'POST', body: { 'gateway': fileName1, 'action': fileName2 ?? '', 'pauldron': contentType, 'stronghold': expectedSize, }, ); } /// 创建生图/视频任务 static Future createTask({ required String asset, String? guild, String? commission, String? ledger, String? cipher, String? heatmap, String? congregation, bool allowance = false, String? ext, }) async { return _client.request( path: '/v1/image/create-task', method: 'POST', queryParams: {'asset': asset}, body: { if (guild != null) 'guild': guild, if (commission != null) 'commission': commission, if (ledger != null) 'ledger': ledger, if (cipher != null) 'cipher': cipher, if (heatmap != null) 'heatmap': heatmap, if (congregation != null) 'congregation': congregation, if (ext != null) 'nexus': ext, 'allowance': allowance, }, ); } /// 获取积分页面信息 static Future getCreditsPageInfo({ required String sentinel, String? asset, String? crest, }) async { return _client.request( path: '/v1/image/getCreditsPageInfo', method: 'GET', queryParams: { 'sentinel': sentinel, if (asset != null) 'asset': asset, if (crest != null) 'crest': crest, }, ); } }