MuleRouter API
Generate images and videos using MuleRouter or MuleRun multimodal APIs.
Required Environment Variables
This skill requires the following environment variables to be set before use:
| Variable | Required | Description |
|---|
| INLINECODE0 | Yes | API key for authentication (get one here) |
| INLINECODE1 |
Yes* | Custom API base URL (e.g.,
https://api.mulerouter.ai). Takes priority over SITE. |
|
MULEROUTER_SITE |
Yes* | API site:
mulerouter or
mulerun. Used if BASE_URL is not set. |
*At least one of MULEROUTER_BASE_URL or MULEROUTER_SITE must be set.
The API key is included in Authorization: Bearer headers when making network calls to the configured API endpoint.
If any of these variables are missing, the scripts will fail with a configuration error. Check the Configuration section below to set them up.
Configuration Check
Before running any commands, verify the environment is configured:
Step 1: Check for existing configuration
Run the built-in config check script:
CODEBLOCK0
If this prints "Configuration OK", skip to Step 3. If it raises a ValueError, proceed to Step 2.
Step 2: Configure if needed
If the variables above are not set, ask the user to provide their API key and preferred endpoint.
Create a .env file in the skill's working directory:
CODEBLOCK1
Note: MULEROUTER_BASE_URL takes priority over MULEROUTER_SITE. If both are set, MULEROUTER_BASE_URL is used.
Note: The skill only loads variables prefixed with MULEROUTER_ from the .env file. Other variables in the file are ignored.
Important: Do NOT use export shell commands to set credentials. Use a .env file or ensure the variables are already present in your shell environment before invoking the skill.
Step 3: Using uv to run scripts
The skill uses uv for dependency management and execution. Make sure uv is installed and available in your PATH.
Run uv sync to install dependencies.
Quick Start
1. List available models
CODEBLOCK2
2. Check model parameters
CODEBLOCK3
3. Generate content
Text-to-Video:
CODEBLOCK4
Text-to-Image:
CODEBLOCK5
Image-to-Video:
uv run python models/alibaba/wan2.6-i2v/generation.py --prompt "Gentle zoom in" --image "https://example.com/photo.jpg" #remote image url
CODEBLOCK7
Image Input
For image parameters (--image, --images, etc.), prefer local file paths over base64.
CODEBLOCK8
Local file paths are validated before reading: only files with recognized image extensions (.png, .jpg, .jpeg, .gif, .bmp, .webp, .tiff, .tif, .svg, .ico, .heic, .heif, .avif) are accepted. Paths pointing to sensitive system directories or non-image files are rejected. Valid image files are converted to base64 and sent to the API, avoiding command-line length limits that occur with raw base64 strings.
Workflow
- 1. Check configuration: verify
MULEROUTER_API_KEY and either MULEROUTER_BASE_URL or MULEROUTER_SITE are set - Install dependencies: run INLINECODE40
- Run
uv run python scripts/list_models.py to discover available models - Run
uv run python models/<path>/<action>.py --list-params to see parameters - Execute with appropriate parameters
- Parse output URLs from results
Model Selection
When listing models, each model's tags (e.g., [SOTA]) are displayed by default next to its name. Tags help identify model characteristics at a glance — for example, SOTA indicates a state-of-the-art model.
You can also filter models by tag using --tag:
CODEBLOCK9
If you are unsure which model to use, present the available options to the user and let them choose. Use the AskUserQuestion tool (or equivalent interactive prompt) to ask the user which model they prefer. For example, if the user asks to "generate an image" without specifying a model, list the relevant image generation models with their tags and descriptions, and ask the user to pick one.
Tips
- 1. For an image generation model, a suggested timeout is 5 minutes.
- For a video generation model, a suggested timeout is 15 minutes.
References
MuleRouter API
使用MuleRouter或MuleRun多模态API生成图像和视频。
必需的环境变量
使用此技能前,需要设置以下环境变量:
| 变量 | 必需 | 描述 |
|---|
| MULEROUTERAPIKEY | 是 | 用于身份验证的API密钥(在此获取) |
| MULEROUTERBASEURL |
是* | 自定义API基础URL(例如 https://api.mulerouter.ai)。优先级高于SITE。 |
| MULEROUTER
SITE | 是* | API站点:mulerouter 或 mulerun。如果未设置BASEURL则使用此项。 |
*MULEROUTERBASEURL 或 MULEROUTER_SITE 至少需要设置一个。
API密钥会在调用配置的API端点时包含在 Authorization: Bearer 请求头中。
如果缺少任何这些变量,脚本将因配置错误而失败。 请查看下面的配置部分进行设置。
配置检查
在运行任何命令之前,请验证环境是否已配置:
步骤1:检查现有配置
运行内置配置检查脚本:
bash
uv run python -c from core.config import loadconfig; loadconfig(); print(Configuration OK)
如果打印出Configuration OK,请跳至步骤3。如果抛出 ValueError,请继续执行步骤2。
步骤2:按需配置
如果上述变量未设置,请询问用户提供其API密钥和首选端点。
在技能的工作目录中创建 .env 文件:
env
选项1:使用自定义基础URL(优先级高于SITE)
MULEROUTER
BASEURL=https://api.mulerouter.ai
MULEROUTER
APIKEY=your-api-key
选项2:使用站点(如果未设置BASE_URL)
MULEROUTER_SITE=mulerun
MULEROUTERAPIKEY=your-api-key
注意: MULEROUTERBASEURL 优先级高于 MULEROUTERSITE。如果两者都设置,则使用 MULEROUTERBASE_URL。
注意: 该技能仅从 .env 文件中加载以 MULEROUTER_ 为前缀的变量。文件中的其他变量将被忽略。
重要: 不要使用 export shell命令来设置凭证。请使用 .env 文件,或在调用技能前确保变量已存在于shell环境中。
步骤3:使用 uv 运行脚本
该技能使用 uv 进行依赖管理和执行。请确保 uv 已安装并可在PATH中找到。
运行 uv sync 安装依赖。
快速入门
1. 列出可用模型
bash
uv run python scripts/list_models.py
2. 检查模型参数
bash
uv run python models/alibaba/wan2.6-t2v/generation.py --list-params
3. 生成内容
文本转视频:
bash
uv run python models/alibaba/wan2.6-t2v/generation.py --prompt 一只猫在花园里行走
文本转图像:
bash
uv run python models/alibaba/wan2.6-t2i/generation.py --prompt 宁静的山间湖泊
图像转视频:
bash
uv run python models/alibaba/wan2.6-i2v/generation.py --prompt 缓慢放大 --image https://example.com/photo.jpg #远程图像URL
bash
uv run python models/alibaba/wan2.6-i2v/generation.py --prompt 缓慢放大 --image /path/to/local/image.png #本地图像路径
图像输入
对于图像参数(--image、--images 等),优先使用本地文件路径而非base64。
bash
推荐:本地文件路径(自动转换为base64)
--image /tmp/photo.png
--images [/tmp/photo.png]
本地文件路径在读取前会进行验证:仅接受具有可识别图像扩展名(.png、.jpg、.jpeg、.gif、.bmp、.webp、.tiff、.tif、.svg、.ico、.heic、.heif、.avif)的文件。指向敏感系统目录或非图像文件的路径将被拒绝。有效的图像文件会转换为base64并发送到API,从而避免原始base64字符串导致的命令行长度限制。
工作流程
- 1. 检查配置:验证 MULEROUTERAPIKEY 以及 MULEROUTERBASEURL 或 MULEROUTERSITE 是否已设置
- 安装依赖:运行 uv sync
- 运行 uv run python scripts/listmodels.py 发现可用模型
- 运行 uv run python models/<路径>/<操作>.py --list-params 查看参数
- 使用适当参数执行
- 从结果中解析输出URL
模型选择
列出模型时,每个模型的标签(例如 [SOTA])默认会显示在其名称旁边。标签有助于快速识别模型特性——例如,SOTA 表示最先进的模型。
您还可以使用 --tag 按标签筛选模型:
bash
uv run python scripts/list_models.py --tag SOTA
如果不确定使用哪个模型,请向用户展示可用选项,让他们选择。使用 AskUserQuestion 工具(或等效的交互式提示)询问用户偏好的模型。例如,如果用户要求生成一张图像但没有指定模型,请列出相关的图像生成模型及其标签和描述,并让用户选择一个。
提示
- 1. 对于图像生成模型,建议超时时间为5分钟。
- 对于视频生成模型,建议超时时间为15分钟。
参考