uapi/wwwroot/api/minimax_h3_setup.dspy
yumoqing 258b46e600 feat(uapi): MiniMax-H3 video generation API integration
- uapiio: MiniMax-H3 video gen input/output definition
- uapi x2: create task (POST /v2/video_generation) + query task (GET /v2/query/video_generation/{task_id})
- upapp: minimax platform registration (https://api.minimax.chat)
- upappkey: placeholder for API key
2026-08-06 16:35:57 +08:00

124 lines
5.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
MiniMax-H3 uapi integration DSPY
部署到: uapi/wwwroot/api/minimax_h3_setup.dspy
调用: POST /uapi/api/minimax_h3_setup.dspy
"""
import json
async def main():
dbname = env.get_module_dbname('uapi')
db = DBPools()
results = {}
async with db.sqlorContext(dbname) as sor:
# 1. uapiio
uapiio_id = 'm_h3_video_gen_io'
existing = await sor.R('uapiio', {'id': uapiio_id})
if not existing:
io_data = {
'id': uapiio_id,
'name': 'MiniMax-H3 视频生成',
'description': 'MiniMax-H3 视频生成v2接口输入输出定义。支持文生视频、图生视频(首尾帧)、多模态参考生视频。',
'input_fields': json.dumps({
"model": {"type": "string", "required": True, "title": "模型名称", "enum": ["MiniMax-H3"]},
"content": {"type": "array", "required": True, "title": "多模态输入内容"},
"resolution": {"type": "string", "required": True, "title": "分辨率", "enum": ["768P", "2K"]},
"duration": {"type": "integer", "required": True, "title": "时长(秒)", "enum": [4,5,6,7,8,9,10,11,12,13,14,15]},
"ratio": {"type": "string", "title": "宽高比", "enum": ["adaptive","21:9","16:9","4:3","1:1","3:4","9:16"]},
"callback_url": {"type": "string", "title": "回调地址"},
"aigc_watermark": {"type": "boolean", "title": "AIGC水印"}
}, ensure_ascii=False)
}
await sor.C('uapiio', io_data)
results['uapiio'] = 'created'
else:
results['uapiio'] = 'exists'
# 2. uapi - create task
create_id = 'm_h3_create_task'
existing = await sor.R('uapi', {'id': create_id})
if not existing:
await sor.C('uapi', {
'id': create_id,
'upappid': 'minimax',
'name': 'video_generation_v2',
'title': 'MiniMax-H3 创建视频任务',
'description': '创建 MiniMax-H3 视频生成任务。返回 task_id用查询接口轮询结果。',
'need_auth': '0',
'stream': 'async',
'path': '/v2/video_generation',
'httpmethod': 'POST',
'chunk_match': 'task_id',
'headers': '{"Content-Type": "application/json", "Authorization": "Bearer {{apikey}}"}',
'params': None,
'data': '{{jsondata}}',
'response': '{{response}}',
'ioid': uapiio_id,
})
results['uapi_create'] = 'created'
else:
results['uapi_create'] = 'exists'
# 3. uapi - query task
query_id = 'm_h3_query_task'
existing = await sor.R('uapi', {'id': query_id})
if not existing:
await sor.C('uapi', {
'id': query_id,
'upappid': 'minimax',
'name': 'query_video_generation',
'title': 'MiniMax-H3 查询视频任务',
'description': '按 task_id 查询 MiniMax-H3 视频生成任务状态与结果。',
'need_auth': '0',
'stream': 'sync',
'path': '/v2/query/video_generation/{{task_id}}',
'httpmethod': 'GET',
'chunk_match': '',
'headers': '{"Authorization": "Bearer {{apikey}}"}',
'params': None,
'data': None,
'response': '{{response}}',
'ioid': uapiio_id,
})
results['uapi_query'] = 'created'
else:
results['uapi_query'] = 'exists'
# 4. upapp
existing = await sor.R('upapp', {'id': 'minimax'})
if not existing:
await sor.C('upapp', {
'id': 'minimax',
'name': 'minimax',
'baseurl': 'https://api.minimax.chat',
'myappid': 'minimax',
'ownerid': 'platform',
'description': 'MiniMax 视频生成平台。提供 H3 视频生成模型。',
})
results['upapp'] = 'created'
else:
results['upapp'] = 'exists'
# 5. upappkey — placeholder, fill real key later
existing = await sor.R('upappkey', {'id': 'mk_minimax_default'})
if not existing:
apikey_value = params_kw.get('apikey', '')
if not apikey_value:
results['upappkey'] = 'skipped (no apikey provided)'
else:
encoded = env.password_encode(apikey_value)
await sor.C('upappkey', {
'id': 'mk_minimax_default',
'upappid': 'minimax',
'orgid': 'platform',
'apikey': encoded,
'enabled_date': '2025-01-01',
'expired_date': '9999-12-31',
})
results['upappkey'] = 'created'
else:
results['upappkey'] = 'exists'
return {'status': 'ok', 'results': results}