Skip to main content
Glama

gen_video

Generate educational tutorial videos in 10-20 minutes. Input text or image-based questions and answers, adjust video quality, and receive a task ID for tracking.

Instructions

生成教学讲解视频,生成时间大约需要10到20分钟,根据题目难度来定

Args: question: 问题内容(文本形式),question和questionImages中至少输入一个 answer: 参考答案(文本形式):确保生成的讲解内容准确(可选) question_images: 问题内容(图片形式),输入图片的URL或者base64(可选) answer_images: 参考答案(图片形式),输入图片的URL或者base64(可选) quality: 视频质量,可选值:l(低)、m(中)、h(高),默认为配置的默认质量

Returns: 包含任务ID的字典

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
answerNo
answer_imagesNo
qualityNom
questionNo
question_imagesNo

Implementation Reference

  • The gen_video tool handler function. Decorated with @mcp.tool() for automatic registration in FastMCP. Proxies video generation requests to the Scenext API endpoint, handles authentication via headers, input validation, and error handling.
    @mcp.tool() async def gen_video( question: str = "", answer: str = "", question_images: Optional[List[str]] = None, answer_images: Optional[List[str]] = None, quality: str = DEFAULT_QUALITY ) -> Dict[str, Any]: """ 生成教学讲解视频,生成时间大约需要10到20分钟,根据题目难度来定 Args: question: 问题内容(文本形式),question和questionImages中至少输入一个 answer: 参考答案(文本形式):确保生成的讲解内容准确(可选) question_images: 问题内容(图片形式),输入图片的URL或者base64(可选) answer_images: 参考答案(图片形式),输入图片的URL或者base64(可选) quality: 视频质量,可选值:l(低)、m(中)、h(高),默认为配置的默认质量 Returns: 包含任务ID的字典 """ # 从请求头获取API KEY api_key = get_api_key_from_headers() if not api_key or api_key == "YOUR_API_KEY": return {"error": "请在请求头中提供有效的API Key,支持Authorization: Bearer <token>或X-API-Key: <token>"} # 验证至少有question或questionImages其中一个 if not question.strip() and not (question_images and len(question_images) > 0): return {"error": "question和questionImages中至少输入一个"} url = f"{API_BASE_URL}/gen_video" headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" } data = { "question": question, "answer": answer, "questionImages": question_images or [], "answerImages": answer_images or [], "quality": quality, } try: async with aiohttp.ClientSession() as session: async with session.post(url, json=data, headers=headers) as response: if response.status == 200: result = await response.json() logger.info(f"视频生成请求成功: {result}") if result.get("status") == "success": return { "status": "success", "task_id": result.get("data", {}).get("task_id"), "message": "视频生成任务创建成功" } else: return { "error": "API返回错误状态", "details": result } else: error_text = await response.text() logger.error(f"API请求失败: {response.status} - {error_text}") return { "error": f"API请求失败: {response.status}", "details": error_text } except aiohttp.ClientError as e: logger.error(f"网络请求错误: {e}") return {"error": f"网络请求错误: {str(e)}"} except Exception as e: logger.error(f"未知错误: {e}") return {"error": f"未知错误: {str(e)}"}
  • Helper function used by gen_video (and query_video_status) to retrieve the API key from HTTP headers or fallback to environment variable.
    def get_api_key_from_headers() -> str: """从HTTP请求头中获取API KEY""" try: headers = get_http_headers(include_all=True) # 尝试从Authorization header获取Bearer token auth_header = headers.get("authorization", "") if auth_header.startswith("Bearer "): return auth_header[7:] # 移除 "Bearer " 前缀 # 尝试从自定义header获取 api_key = headers.get("x-api-key", "") if api_key: return api_key # 如果都没有,返回环境变量中的默认值 return os.getenv("SCENEXT_API_KEY", "") except RuntimeError: # 如果不在HTTP请求上下文中,使用环境变量 return os.getenv("SCENEXT_API_KEY", "")
  • Function signature and docstring defining the input schema (parameters with types and descriptions) and output type for the gen_video tool.
    async def gen_video( question: str = "", answer: str = "", question_images: Optional[List[str]] = None, answer_images: Optional[List[str]] = None, quality: str = DEFAULT_QUALITY ) -> Dict[str, Any]: """ 生成教学讲解视频,生成时间大约需要10到20分钟,根据题目难度来定 Args: question: 问题内容(文本形式),question和questionImages中至少输入一个 answer: 参考答案(文本形式):确保生成的讲解内容准确(可选) question_images: 问题内容(图片形式),输入图片的URL或者base64(可选) answer_images: 参考答案(图片形式),输入图片的URL或者base64(可选) quality: 视频质量,可选值:l(低)、m(中)、h(高),默认为配置的默认质量 Returns: 包含任务ID的字典

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/typing233/scenext-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server