214 lines
5.5 KiB
Dart
214 lines
5.5 KiB
Dart
import '../api_client.dart';
|
||
import '../proxy_client.dart';
|
||
|
||
/// 图片/视频生成相关 API
|
||
abstract final class ImageApi {
|
||
static final _client = ApiClient.instance.proxy;
|
||
|
||
/// 获取图转视频分类列表
|
||
static Future<ApiResponse> getCategoryList() async {
|
||
return _client.request(
|
||
path: '/v1/image/img2video/categories',
|
||
method: 'GET',
|
||
);
|
||
}
|
||
|
||
/// 获取图转视频任务列表
|
||
/// insignia: categoryId
|
||
static Future<ApiResponse> getImg2VideoTasks({int? insignia}) async {
|
||
return _client.request(
|
||
path: '/v1/image/img2video/tasks',
|
||
method: 'GET',
|
||
queryParams: insignia != null ? {'insignia': insignia.toString()} : null,
|
||
);
|
||
}
|
||
|
||
/// 获取推荐提示词
|
||
static Future<ApiResponse> 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<ApiResponse> 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<ApiResponse> 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<ApiResponse> 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<ApiResponse> 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<ApiResponse> 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<ApiResponse> 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<ApiResponse> getMyTasks({
|
||
required String sentinel,
|
||
String? trophy,
|
||
String? heatmap,
|
||
String? platoon,
|
||
}) async {
|
||
return _client.request(
|
||
path: '/v1/image/my-tasks',
|
||
method: 'GET',
|
||
queryParams: {
|
||
'sentinel': sentinel,
|
||
if (trophy != null) 'trophy': trophy,
|
||
if (heatmap != null) 'heatmap': heatmap,
|
||
if (platoon != null) 'platoon': platoon,
|
||
},
|
||
);
|
||
}
|
||
|
||
/// 获取积分页面信息
|
||
static Future<ApiResponse> 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,
|
||
},
|
||
);
|
||
}
|
||
}
|