利用 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
feat(llm): add API Route provider support
DennyHo09172367f372c54f
diff --git a/app/models/llm_provider.py b/app/models/llm_provider.pyindex dc6aea01..857ac9e4 100644--- a/app/models/llm_provider.py+++ b/app/models/llm_provider.py@@ -382,6 +382,13 @@ LLM_PROVIDER_REGISTRY = (default_model="minimax/minimax-m3:free",default_base_url="https://openrouter.ai/api/v1",),+ LLMProviderSpec(+ "api_route",+ "API Route",+ api_key_url="https://www.api-route.com",+ default_model="gpt-4o",+ default_base_url="https://www.api-route.com/v1",+ ),# 本地部署与通用网关LLMProviderSpec("ollama",diff --git a/config.example.toml b/config.example.tomlindex 71d3ae13..afb90201 100644--- a/config.example.toml+++ b/config.example.toml@@ -342,6 +342,12 @@ openrouter_api_key = ""openrouter_base_url = ""openrouter_model_name = ""+# API Route, an OpenAI-compatible multi-model routing platform.+# API key: https://www.api-route.com+api_route_api_key = ""+api_route_base_url = ""+api_route_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/test/services/test_llm.py b/test/services/test_llm.pyindex 73ff32aa..f046d982 100644--- a/test/services/test_llm.py+++ b/test/services/test_llm.py@@ -315,6 +315,11 @@ class TestLiteLLMProvider(unittest.TestCase):self.assertEqual(openrouter.default_base_url, "https://openrouter.ai/api/v1")self.assertEqual(openrouter.adapter, "openai_compatible")self.assertTrue(openrouter.requires_api_key)+ api_route = get_llm_provider("api_route")+ self.assertEqual(api_route.default_model, "gpt-4o")+ self.assertEqual(api_route.default_base_url, "https://www.api-route.com/v1")+ self.assertEqual(api_route.adapter, "openai_compatible")+ self.assertTrue(api_route.requires_api_key)pollinations = get_llm_provider("pollinations")self.assertEqual(pollinations.default_model, "openai-fast")self.assertEqual(@@ -371,6 +376,7 @@ class TestLiteLLMProvider(unittest.TestCase):"aimlapi","evolink","openrouter",+ "api_route","ollama","claude_code","oneapi",@@ -410,6 +416,13 @@ class TestLiteLLMProvider(unittest.TestCase):)self.assertEqual(openrouter.default_model, "minimax/minimax-m3:free")self.assertEqual(openrouter.default_base_url, "https://openrouter.ai/api/v1")+ api_route = get_llm_provider("api_route")+ self.assertEqual(+ api_route.api_key_url,+ "https://www.api-route.com",+ )+ self.assertEqual(api_route.default_model, "gpt-4o")+ self.assertEqual(api_route.default_base_url, "https://www.api-route.com/v1")def test_provider_registry_uses_conventional_locale_and_config_keys(self):"""统一命名规则可避免 WebUI 为每个 Provider 增加硬编码映射。"""@@ -1325,6 +1338,47 @@ class TestLiteLLMProvider(unittest.TestCase):)self.assertEqual(result, "hello\nopenrouter")+ def test_api_route_provider_uses_openai_compatible_client(self):+ """+ API Route exposes OpenAI-compatible Chat Completions through one+ unified endpoint with intelligent routing and high availability.+ """+ config.app["llm_provider"] = "api_route"+ config.app["api_route_api_key"] = "api-route-key"+ config.app["api_route_base_url"] = ""+ config.app["api_route_model_name"] = ""++ class FakeCompletions:+ def create(self, **kwargs):+ self.kwargs = kwargs+ message = types.SimpleNamespace(content="hello\napi_route")+ 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="api-route-key",+ base_url="https://www.api-route.com/v1",+ )+ self.assertEqual(+ fake_completions.kwargs,+ {+ "model": "gpt-4o",+ "messages": [{"role": "user", "content": "Say hello"}],+ },+ )+ self.assertEqual(result, "hello\napi_route")+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 08c2c236..4045afc2 100644--- a/test/services/test_webui_i18n.py+++ b/test/services/test_webui_i18n.py@@ -47,6 +47,7 @@ ENGLISH_FALLBACK_KEYS = frozenset("Local LLM Script Generation","llm_provider_label.apimart","llm_provider_label.openrouter",+ "llm_provider_label.api_route","llm_provider_label.shengsuanyun","LoomLoom Poll Retry Pending","LoomLoom Poll Retry Warning",diff --git a/webui/i18n/en.json b/webui/i18n/en.jsonindex bd08430c..8021ca13 100644--- a/webui/i18n/en.json+++ b/webui/i18n/en.json@@ -231,6 +231,7 @@"llm_provider_label.shengsuanyun": "Shengsuan Cloud","llm_provider_label.apimart": "APIMart","llm_provider_label.openrouter": "OpenRouter",+ "llm_provider_label.api_route": "API Route","API Key": "API Key","Base Url": "Base Url","Account ID": "Account ID",@@ -455,6 +456,7 @@"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.api_route": "##### API Route Configuration\n- **API Key**: Register and obtain an API key at [API Route]({api_key_url})\n- **Base Url**: Defaults to `{default_base_url}`\n- **Model Name**: Defaults to `{default_model}`; you can also enter any other model ID supported by the platform (such as claude-3-7-sonnet, deepseek-chat, etc.)\n\nAPI Route provides high-availability multi-model AI routing with standard OpenAI compatibility.","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 452dbe6f..6191ca09 100644--- a/webui/i18n/zh.json+++ b/webui/i18n/zh.json@@ -231,6 +231,7 @@"llm_provider_label.shengsuanyun": "胜算云","llm_provider_label.apimart": "APIMart","llm_provider_label.openrouter": "OpenRouter",+ "llm_provider_label.api_route": "API Route","API Key": "API Key","Base Url": "Base Url","Account ID": "Account ID",@@ -455,6 +456,7 @@"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.api_route": "##### API Route 配置说明\n- **API Key**: 在 [API Route 官网]({api_key_url}) 注册并获取 API Key\n- **Base Url**: 默认 `{default_base_url}`\n- **Model Name**: 默认 `{default_model}`;支持填写平台上的其它主流模型(如 claude-3-7-sonnet、deepseek-chat 等)\n\nAPI Route 提供高可用多模型聚合路由服务,兼容 OpenAI 标准接口。","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",