feat(uapi): MiniMax-H3 setup DSPY with pricing - uapiio, uapi x2, upapp, upappkey, pricing_program x2 (2K:0.80/s, 768P:0.50/s)
This commit is contained in:
parent
258b46e600
commit
148ce17f82
@ -1,123 +1,139 @@
|
||||
"""
|
||||
MiniMax-H3 uapi integration DSPY
|
||||
部署到: uapi/wwwroot/api/minimax_h3_setup.dspy
|
||||
调用: POST /uapi/api/minimax_h3_setup.dspy
|
||||
MiniMax-H3 complete setup: uapi + pricing
|
||||
POST /uapi/api/minimax_h3_setup.dspy
|
||||
Body: {"apikey": "YOUR_MINIMAX_API_KEY"}
|
||||
"""
|
||||
import json
|
||||
|
||||
async def main():
|
||||
dbname = env.get_module_dbname('uapi')
|
||||
pricing_dbname = env.get_module_dbname('pricing')
|
||||
db = DBPools()
|
||||
|
||||
results = {}
|
||||
|
||||
|
||||
# ============================================================
|
||||
# PART 1: UAPI records
|
||||
# ============================================================
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
# 1. uapiio
|
||||
uapiio_id = 'm_h3_video_gen_io'
|
||||
|
||||
# uapiio
|
||||
existing = await sor.R('uapiio', {'id': uapiio_id})
|
||||
if not existing:
|
||||
io_data = {
|
||||
await sor.C('uapiio', {
|
||||
'id': uapiio_id,
|
||||
'name': 'MiniMax-H3 视频生成',
|
||||
'description': 'MiniMax-H3 视频生成v2接口输入输出定义。支持文生视频、图生视频(首尾帧)、多模态参考生视频。',
|
||||
'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:
|
||||
# uapi - create
|
||||
cid = 'm_h3_create_task'
|
||||
if not await sor.R('uapi', {'id': cid}):
|
||||
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',
|
||||
'id': cid, 'upappid': 'minimax', 'name': 'video_generation_v2',
|
||||
'title': 'MiniMax-H3 创建视频任务', 'description': '创建 MiniMax-H3 视频生成任务',
|
||||
'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,
|
||||
'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:
|
||||
# uapi - query
|
||||
qid = 'm_h3_query_task'
|
||||
if not await sor.R('uapi', {'id': qid}):
|
||||
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': '',
|
||||
'id': qid, 'upappid': 'minimax', 'name': 'query_video_generation',
|
||||
'title': 'MiniMax-H3 查询视频任务', 'description': '按task_id查询任务状态',
|
||||
'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,
|
||||
'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:
|
||||
# upapp
|
||||
if not await sor.R('upapp', {'id': 'minimax'}):
|
||||
await sor.C('upapp', {
|
||||
'id': 'minimax',
|
||||
'name': 'minimax',
|
||||
'baseurl': 'https://api.minimax.chat',
|
||||
'myappid': 'minimax',
|
||||
'ownerid': 'platform',
|
||||
'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)
|
||||
# upappkey
|
||||
apikey_val = params_kw.get('apikey', '')
|
||||
if apikey_val:
|
||||
existing = await sor.R('upappkey', {'id': 'mk_minimax_default'})
|
||||
if not existing:
|
||||
await sor.C('upappkey', {
|
||||
'id': 'mk_minimax_default',
|
||||
'upappid': 'minimax',
|
||||
'orgid': 'platform',
|
||||
'apikey': encoded,
|
||||
'enabled_date': '2025-01-01',
|
||||
'expired_date': '9999-12-31',
|
||||
'id': 'mk_minimax_default', 'upappid': 'minimax', 'orgid': 'platform',
|
||||
'apikey': env.password_encode(apikey_val),
|
||||
'enabled_date': '2025-01-01', 'expired_date': '9999-12-31',
|
||||
})
|
||||
results['upappkey'] = 'created'
|
||||
else:
|
||||
results['upappkey'] = 'exists'
|
||||
else:
|
||||
results['upappkey'] = 'exists'
|
||||
results['upappkey'] = 'skipped (no apikey)'
|
||||
|
||||
# ============================================================
|
||||
# PART 2: Pricing records
|
||||
# ============================================================
|
||||
async with db.sqlorContext(pricing_dbname) as sor:
|
||||
# Inspect table structure
|
||||
cols = await sor.I('pricing_program')
|
||||
results['pp_cols'] = [c.get('Field') + ' ' + c.get('Type') for c in cols[:15]]
|
||||
|
||||
# Insert 2 pricing programs: 2K and 768P
|
||||
programs = [
|
||||
{
|
||||
'id': 'minimax_h3_2k',
|
||||
'name': 'MiniMax-H3-2K',
|
||||
'description': 'MiniMax-H3 2K分辨率视频生成',
|
||||
'unit': 'second',
|
||||
'unit_price': 0.80,
|
||||
'currency': 'CNY',
|
||||
'category': 'video_generation',
|
||||
'provider': 'minimax',
|
||||
'model': 'MiniMax-H3',
|
||||
'resolution': '2K',
|
||||
},
|
||||
{
|
||||
'id': 'minimax_h3_768p',
|
||||
'name': 'MiniMax-H3-768P',
|
||||
'description': 'MiniMax-H3 768P分辨率视频生成',
|
||||
'unit': 'second',
|
||||
'unit_price': 0.50,
|
||||
'currency': 'CNY',
|
||||
'category': 'video_generation',
|
||||
'provider': 'minimax',
|
||||
'model': 'MiniMax-H3',
|
||||
'resolution': '768P',
|
||||
},
|
||||
]
|
||||
for prog in programs:
|
||||
existing = await sor.R('pricing_program', {'id': prog['id']})
|
||||
if not existing:
|
||||
await sor.C('pricing_program', prog)
|
||||
results['pricing_' + prog['id']] = 'created'
|
||||
else:
|
||||
results['pricing_' + prog['id']] = 'exists'
|
||||
|
||||
return {'status': 'ok', 'results': results}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user