利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
Add OpenRouter LLM provider
fabrizio-alzdf3df0baa961
diff --git a/app/models/llm_provider.py b/app/models/llm_provider.pyindex 9a42f049..2430f2ac 100644--- a/app/models/llm_provider.py+++ b/app/models/llm_provider.py@@ -375,6 +375,13 @@ LLM_PROVIDER_REGISTRY = (default_model="gpt-5.5",default_base_url="https://direct.evolink.ai/v1",),+ LLMProviderSpec(+ "openrouter",+ "OpenRouter",+ api_key_url="https://openrouter.ai/settings/keys",+ default_model="minimax/minimax-m3:free",+ default_base_url="https://openrouter.ai/api/v1",+ ),# 本地部署与通用网关LLMProviderSpec("ollama",diff --git a/config.example.toml b/config.example.tomlindex 4f96b5b3..d37c1f85 100644--- a/config.example.toml+++ b/config.example.toml@@ -239,6 +239,13 @@ evolink_api_key = ""evolink_base_url = ""evolink_model_name = ""+# OpenRouter, an OpenAI-compatible multi-model gateway.+# API key: https://openrouter.ai/settings/keys+# Free models: https://openrouter.ai/models?variant=free+openrouter_api_key = ""+openrouter_base_url = ""+openrouter_model_name = ""+# Ollama. Leave base_url empty to use the environment-aware local default.# Set model_name to a model installed by `ollama pull` or shown by `ollama list`.ollama_base_url = ""diff --git a/docs/MoneyPrinterTurbo.ipynb b/docs/MoneyPrinterTurbo.ipynbindex 22d42d90..d21305a4 100644--- a/docs/MoneyPrinterTurbo.ipynb+++ b/docs/MoneyPrinterTurbo.ipynb@@ -91,7 +91,7 @@"source": ["## 3. Launch the WebUI\n","\n",- "The cell waits for Streamlit to become healthy before creating the public URL. If startup fails, it includes the recent server log in the error. After opening the URL, use **Settings** to configure the required model and media API keys."+ "The cell waits for Streamlit to become healthy before creating the public URL. If startup fails, it includes the recent server log in the error. After opening the URL, use **Settings** to configure the required model and media API keys. To use OpenRouter free LLMs, select **OpenRouter**, enter your OpenRouter API key, and keep the default `minimax/minimax-m3:free` model or choose another model from https://openrouter.ai/models?variant=free."]},{diff --git a/test/services/test_llm.py b/test/services/test_llm.pyindex 35eae67c..028b883f 100644--- a/test/services/test_llm.py+++ b/test/services/test_llm.py@@ -312,6 +312,11 @@ class TestLiteLLMProvider(unittest.TestCase):self.assertEqual(get_llm_provider("gemini").default_model, "gemini-3.1-pro-preview")+ openrouter = get_llm_provider("openrouter")+ self.assertEqual(openrouter.default_model, "minimax/minimax-m3:free")+ self.assertEqual(openrouter.default_base_url, "https://openrouter.ai/api/v1")+ self.assertEqual(openrouter.adapter, "openai_compatible")+ self.assertTrue(openrouter.requires_api_key)pollinations = get_llm_provider("pollinations")self.assertEqual(pollinations.default_model, "openai-fast")self.assertEqual(@@ -367,6 +372,7 @@ class TestLiteLLMProvider(unittest.TestCase):"aihubmix","aimlapi","evolink",+ "openrouter","ollama","oneapi","litellm",@@ -398,6 +404,13 @@ class TestLiteLLMProvider(unittest.TestCase):)self.assertEqual(apimart.default_model, "gpt-5.6-terra")self.assertEqual(apimart.default_base_url, "https://api.apimart.ai/v1")+ openrouter = get_llm_provider("openrouter")+ self.assertEqual(+ openrouter.api_key_url,+ "https://openrouter.ai/settings/keys",+ )+ self.assertEqual(openrouter.default_model, "minimax/minimax-m3:free")+ self.assertEqual(openrouter.default_base_url, "https://openrouter.ai/api/v1")def test_provider_registry_uses_conventional_locale_and_config_keys(self):"""统一命名规则可避免 WebUI 为每个 Provider 增加硬编码映射。"""@@ -1275,6 +1288,48 @@ class TestLiteLLMProvider(unittest.TestCase):)self.assertEqual(result, "hello\nevolink")+ def test_openrouter_provider_uses_openai_compatible_client(self):+ """+ OpenRouter exposes OpenAI-compatible Chat Completions through one+ unified endpoint. The default model stays on a currently free text model+ suitable for script and keyword generation.+ """+ config.app["llm_provider"] = "openrouter"+ config.app["openrouter_api_key"] = "openrouter-key"+ config.app["openrouter_base_url"] = ""+ config.app["openrouter_model_name"] = ""++ class FakeCompletions:+ def create(self, **kwargs):+ self.kwargs = kwargs+ message = types.SimpleNamespace(content="hello\nopenrouter")+ choice = types.SimpleNamespace(message=message)+ return types.SimpleNamespace(choices=[choice])++ fake_completions = FakeCompletions()+ fake_client = types.SimpleNamespace(+ chat=types.SimpleNamespace(completions=fake_completions)+ )++ with (+ patch.object(llm, "OpenAI", return_value=fake_client) as openai_client,+ patch.object(llm, "ChatCompletion", types.SimpleNamespace),+ ):+ result = llm._generate_response("Say hello")++ openai_client.assert_called_once_with(+ api_key="openrouter-key",+ base_url="https://openrouter.ai/api/v1",+ )+ self.assertEqual(+ fake_completions.kwargs,+ {+ "model": "minimax/minimax-m3:free",+ "messages": [{"role": "user", "content": "Say hello"}],+ },+ )+ self.assertEqual(result, "hello\nopenrouter")+def test_volcengine_provider_uses_openai_compatible_client(self):"""VolcEngine Ark 暴露 OpenAI-compatible Chat Completions。diff --git a/test/services/test_webui_i18n.py b/test/services/test_webui_i18n.pyindex 56d26cdb..5bf485a5 100644--- a/test/services/test_webui_i18n.py+++ b/test/services/test_webui_i18n.py@@ -39,6 +39,7 @@ ENGLISH_FALLBACK_KEYS = frozenset("llm_provider_authentication_error.moonshot","Local LLM Script Generation","llm_provider_label.apimart",+ "llm_provider_label.openrouter","llm_provider_label.shengsuanyun","LoomLoom Poll Retry Pending","LoomLoom Poll Retry Warning",diff --git a/webui/i18n/en.json b/webui/i18n/en.jsonindex cce3f7c3..bc3ade7b 100644--- a/webui/i18n/en.json+++ b/webui/i18n/en.json@@ -205,6 +205,7 @@"llm_provider_label.moonshot": "Kimi / Moonshot AI (Recommended)","llm_provider_label.shengsuanyun": "Shengsuan Cloud","llm_provider_label.apimart": "APIMart",+ "llm_provider_label.openrouter": "OpenRouter","API Key": "API Key","Base Url": "Base Url","Account ID": "Account ID",@@ -359,6 +360,7 @@"llm_provider_tips.aihubmix": "##### AIHubMix Configuration\n- **API Key**: create one in the [AIHubMix console]({api_key_url})\n- **Base Url**: defaults to `{default_base_url}`\n- **Model Name**: defaults to `{default_model}`; you can also enter another supported model ID","llm_provider_tips.aimlapi": "##### AIML API Configuration\n- **API Key**: create one at [AIML API]({api_key_url})\n- **Base Url**: defaults to `{default_base_url}`\n- **Model Name**: defaults to `{default_model}`; you can also enter another supported model ID","llm_provider_tips.evolink": "##### EvoLink Configuration\n- **API Key**: create one on [EvoLink]({api_key_url})\n- **Base Url**: defaults to `{default_base_url}`\n- **Model Name**: defaults to `{default_model}`; you can also enter another supported model ID",+ "llm_provider_tips.openrouter": "##### OpenRouter Configuration\n- **API Key**: create one in [OpenRouter Keys]({api_key_url})\n- **Base Url**: defaults to `{default_base_url}`\n- **Model Name**: defaults to `{default_model}`; use another model ID from the [free model list](https://openrouter.ai/models?variant=free) if availability changes\n\nRecommended free alternatives for this workflow: `z-ai/glm-5.2:free` or `openrouter/free`. Free endpoints are rate limited and may change availability.","llm_provider_tips.volcengine": "##### VolcEngine Ark Configuration\n- **API Key**: create one in the Ark console; [register on VolcEngine]({api_key_url})\n- **Base Url**: defaults to `{default_base_url}`\n- **Model Name**: defaults to `{default_model}`; make sure the model is enabled in your Ark account","llm_provider_tips.moonshot": "##### Kimi / Moonshot Configuration\n- **API Key**: register through the [MoneyPrinterTurbo link (10% bonus API credit on your first top-up)]({api_key_url}) and create one in the console\n- **Base Url**: defaults to `{default_base_url}`\n- **Model Name**: defaults to `{default_model}`; see the [model list]({model_docs_url})\n\nWhy recommended:\n- **Fits the video creation workflow**: helps generate scripts, extract stock-footage search keywords, and improve final footage relevance\n- **Strong long-context capability**: useful for longer topics, batch scripts, and complex prompts\n- **Exclusive offer for new users**: receive bonus API credit equal to 10% of the first successful top-up, up to CNY 1,000; offer ends September 30, 2026","llm_provider_tips.oneapi": "##### OneAPI Configuration\n- **API Key**: create one in your own OneAPI deployment; see the [OneAPI project]({api_key_url})\n- **Base Url**: required; enter the OneAPI service endpoint\n- **Model Name**: required; enter a model ID configured in OneAPI",diff --git a/webui/i18n/zh.json b/webui/i18n/zh.jsonindex b98e0b86..c0bdeb8c 100644--- a/webui/i18n/zh.json+++ b/webui/i18n/zh.json@@ -205,6 +205,7 @@"llm_provider_label.moonshot": "Kimi / Moonshot AI(推荐)","llm_provider_label.shengsuanyun": "胜算云","llm_provider_label.apimart": "APIMart",+ "llm_provider_label.openrouter": "OpenRouter","API Key": "API Key","Base Url": "Base Url","Account ID": "Account ID",@@ -359,6 +360,7 @@"llm_provider_tips.aihubmix": "##### AIHubMix 配置说明\n- **API Key**: 在 [AIHubMix 控制台]({api_key_url}) 创建\n- **Base Url**: 默认 `{default_base_url}`\n- **Model Name**: 默认 `{default_model}`;也可以填写平台支持的其它模型 ID","llm_provider_tips.aimlapi": "##### AIML API 配置说明\n- **API Key**: 在 [AIML API]({api_key_url}) 创建\n- **Base Url**: 默认 `{default_base_url}`\n- **Model Name**: 默认 `{default_model}`;也可以填写平台支持的其它模型 ID","llm_provider_tips.evolink": "##### EvoLink 配置说明\n- **API Key**: 在 [EvoLink]({api_key_url}) 创建\n- **Base Url**: 默认 `{default_base_url}`\n- **Model Name**: 默认 `{default_model}`;也可以填写平台支持的其它模型 ID",+ "llm_provider_tips.openrouter": "##### OpenRouter 配置说明\n- **API Key**: 在 [OpenRouter Keys]({api_key_url}) 创建\n- **Base Url**: 默认 `{default_base_url}`\n- **Model Name**: 默认 `{default_model}`;如果可用性变化,也可以从 [免费模型列表](https://openrouter.ai/models?variant=free) 填写其它模型 ID\n\n当前工作流推荐的免费替代模型:`z-ai/glm-5.2:free` 或 `openrouter/free`。免费端点有速率限制,可用性可能变化。","llm_provider_tips.volcengine": "##### VolcEngine Ark 配置说明\n- **API Key**: 在火山引擎方舟控制台创建;[点击注册火山引擎]({api_key_url})\n- **Base Url**: 默认 `{default_base_url}`\n- **Model Name**: 默认 `{default_model}`;请确保已在方舟控制台开通对应模型","llm_provider_tips.moonshot": "##### Kimi / Moonshot 配置说明\n- **API Key**: 通过 [MoneyPrinterTurbo 专属链接(新用户首次充值赠送 10% API 额度)]({api_key_url}) 注册并在控制台创建\n- **Base Url**: 默认 `{default_base_url}`\n- **Model Name**: 默认 `{default_model}`;[查看模型列表]({model_docs_url})\n\n推荐理由:\n- **视频创作链路匹配**: 可用于生成视频文案、提炼素材搜索关键词,并影响最终素材匹配效果\n- **长上下文能力强**: 适合处理较长主题、批量脚本和复杂提示词\n- **新用户专属优惠**: 首次成功充值可获充值金额 10% 的 API 额度,最高赠送 ¥1000,活动截至 2026 年 9 月 30 日","llm_provider_tips.oneapi": "##### OneAPI 配置说明\n- **API Key**: 从您自己的 OneAPI 部署中创建;[查看 OneAPI 项目说明]({api_key_url})\n- **Base Url**: 必填;填写 OneAPI 服务地址\n- **Model Name**: 必填;填写 OneAPI 中已配置的模型 ID",