MCPcopy Create free account
hub / github.com/Tencent/digitalhuman / Api

Class Api

ScriptAgent/code/director_agent.py:1333–1556  ·  view source on GitHub ↗

Unified client for calling video generation APIs (supports multiple models)

Source from the content-addressed store, hash-verified

1331
1332
1333class Api:
1334 """Unified client for calling video generation APIs (supports multiple models)"""
1335
1336 def __init__(self, user: str, apikey: str) -> None:
1337 LOGGER.info("Initializing API client, account: %s", user)
1338 HOST = "trpc-gpt-eval.production.polaris"
1339 self.host = "http://{}:8080".format(HOST)
1340 self.user = user
1341 self.apikey = apikey
1342 self.timeout = 3600
1343 self.models = {
1344 "sora2-pro": "api_openai_sora-2-pro",
1345 "sora2": "api_openai_sora-2",
1346 "veo3.1": "api_google_veo-3.1-generate-preview",
1347 "veo3.1-fast": "api_google_veo-3.1-fast-generate-preview",
1348 "jimeng": "api_doubao_jimeng_ti2v_v30_pro",
1349 "keling": "api_klingai_text2video:kling-v2-5-turbo",
1350 "vidu_refer": "api_vidu_reference-to-video_viduq2",
1351 "vidu_image": "api_vidu_img2video_viduq2-pro",
1352 # "wan_t2v": "api_ali_wan2.5-t2v-preview",
1353 # "wan_i2v": "api_ali_wan2.5-i2v-preview",
1354 "wan_t2v": "api_ali_wan2.6-t2v",
1355 "wan_i2v": "api_ali_wan2.6-i2v",
1356 "Wan2.5": "api_ali_wan2.6-i2v", # Placeholder, will switch dynamically
1357 "ViduQ2": "api_vidu_reference-to-video_viduq2", # Placeholder, will switch dynamically
1358 }
1359
1360 def get_header(self) -> Dict[str, str]:
1361 source = "VideoEvaluate"
1362 sign, date_time = get_simple_auth(source, self.user, self.apikey)
1363 return {
1364 "Apiversion": API_VERSION,
1365 "Authorization": sign,
1366 "Date": date_time,
1367 "Source": source,
1368 }
1369 def call_data_eval(
1370 self,
1371 text: str,
1372 pic_path: Optional[List[str]],
1373 pic_func: Optional[List[str]],
1374 output_path: str,
1375 model: str,
1376 size: str,
1377 seconds: int,
1378 **kargs: Any,
1379 ) -> Optional[str]:
1380 if model not in self.models:
1381 raise ValueError("Unknown model: {}".format(model))
1382 if requests is None:
1383 raise RuntimeError("requests not found, please install it first.")
1384
1385 base_url = self.host + "/api/v1/data_eval"
1386
1387 # Build request data
1388 data: Dict[str, Any] = {
1389 "request_id": str(uuid.uuid4()),
1390 "model_marker": self.models[model],

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected