利用 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 Anthropic Claude provider
Jeff8d0e188ea845
diff --git a/README-en.md b/README-en.mdindex 61cc8d0a..12123b44 100644--- a/README-en.md+++ b/README-en.md@@ -132,7 +132,7 @@ Thanks to [Kimi](https://platform.kimi.ai?track_id=track-f6b0a640d35c41deb03b247- [x] Supports random or custom **background music** with adjustable volume- [x] Supports your own **local assets** and free-to-use HD footage from **Pexels**, **Pixabay**, and **Coverr**- [x] Supports **AI-generated footage**: [WaveSpeed AI](https://wavespeed.ai) text-to-video models (Seedance by default) create brand-new visuals from your script keywords instead of relying on stock libraries-- [x] Supports leading model providers including **Kimi / Moonshot AI**, **OpenAI**, **Google Gemini**, **DeepSeek**, **Alibaba Cloud Qwen**, **Microsoft Azure OpenAI**, **ByteDance VolcEngine Ark**, **xAI Grok**, **MiniMax**, and **Xiaomi MiMo**, plus unified gateways, aggregators, and local runtimes such as **Cloudflare AI Gateway**, **Alibaba ModelScope**, **AIHubMix**, **AIML API**, **EvoLink**, **Ollama**, **OneAPI**, **LiteLLM**, **Groq**, and **Pollinations AI**+- [x] Supports leading model providers including **Kimi / Moonshot AI**, **OpenAI**, **Anthropic Claude**, **Google Gemini**, **DeepSeek**, **Alibaba Cloud Qwen**, **Microsoft Azure OpenAI**, **ByteDance VolcEngine Ark**, **xAI Grok**, **MiniMax**, and **Xiaomi MiMo**, plus unified gateways, aggregators, and local runtimes such as **Cloudflare AI Gateway**, **Alibaba ModelScope**, **AIHubMix**, **AIML API**, **EvoLink**, **Ollama**, **OneAPI**, **LiteLLM**, **Groq**, and **Pollinations AI**- [x] Supports one-click **cross-platform publishing** to **TikTok**, **Instagram**, and **YouTube Shorts** after video generation- [x] Supports **exporting and importing generation settings** as a preset file, and backing up and restoring every **API key** from the settings dialogdiff --git a/README.md b/README.mdindex 1bffc636..9ef61cd6 100644--- a/README.md+++ b/README.md@@ -142,7 +142,7 @@- [x] 支持 **背景音乐**,可随机选择或使用指定音乐,并调整音量- [x] 支持使用自己的 **本地素材**,也可从 **Pexels**、**Pixabay** 和 **Coverr** 获取可免费使用的高清素材- [x] 支持 **AI 生成素材**:接入 [WaveSpeed AI](https://wavespeed.ai) 文生视频模型(默认 Seedance),按脚本关键词直接生成全新画面,不再受限于库存素材-- [x] 支持 **Kimi / Moonshot AI**、**OpenAI**、**Google Gemini**、**DeepSeek**、**阿里云通义千问**、**Microsoft Azure OpenAI**、**火山引擎方舟**、**xAI Grok**、**MiniMax**、**小米 MiMo** 等主流模型服务,并兼容 **Cloudflare AI Gateway**、**魔搭 ModelScope**、**AIHubMix**、**AIML API**、**EvoLink**、**Ollama**、**OneAPI**、**LiteLLM**、**Groq**、**Pollinations AI** 等统一网关、聚合平台和本地运行环境+- [x] 支持 **Kimi / Moonshot AI**、**OpenAI**、**Anthropic Claude**、**Google Gemini**、**DeepSeek**、**阿里云通义千问**、**Microsoft Azure OpenAI**、**火山引擎方舟**、**xAI Grok**、**MiniMax**、**小米 MiMo** 等主流模型服务,并兼容 **Cloudflare AI Gateway**、**魔搭 ModelScope**、**AIHubMix**、**AIML API**、**EvoLink**、**Ollama**、**OneAPI**、**LiteLLM**、**Groq**、**Pollinations AI** 等统一网关、聚合平台和本地运行环境- [x] 支持一键 **跨平台发布**,生成完成后可自动上传至 **TikTok**、**Instagram** 和 **YouTube Shorts**- [x] 支持将生成设置**导出和导入**为预设文件,并在设置弹窗中备份和恢复所有 **API Key**diff --git a/app/models/llm_provider.py b/app/models/llm_provider.pyindex 8f57c3d6..7b6fe263 100644--- a/app/models/llm_provider.py+++ b/app/models/llm_provider.py@@ -233,6 +233,13 @@ LLM_PROVIDER_REGISTRY = (default_model="gpt-5.5",default_base_url="https://api.openai.com/v1",),+ LLMProviderSpec(+ "anthropic",+ "Anthropic Claude",+ api_key_url="https://platform.claude.com/settings/keys",+ default_model="claude-sonnet-5",+ default_base_url="https://api.anthropic.com/v1/",+ ),LLMProviderSpec("gemini","Google Gemini",diff --git a/config.example.toml b/config.example.tomlindex 9693ac98..2b29c3ec 100644--- a/config.example.toml+++ b/config.example.toml@@ -134,6 +134,12 @@ openai_api_key = ""openai_base_url = ""openai_model_name = ""+# Anthropic Claude, called through the OpenAI-compatible endpoint.+# API key: https://platform.claude.com/settings/keys+anthropic_api_key = ""+anthropic_base_url = ""+anthropic_model_name = ""+# Google Gemini# API key: https://aistudio.google.com/app/apikeygemini_api_key = ""diff --git a/test/services/test_llm.py b/test/services/test_llm.pyindex c766269c..177b37b7 100644--- a/test/services/test_llm.py+++ b/test/services/test_llm.py@@ -264,6 +264,11 @@ class TestLiteLLMProvider(unittest.TestCase):def test_current_default_model_names(self):"""WebUI 与服务层必须共享同一组默认模型,避免展示值和请求值漂移。"""self.assertEqual(get_llm_provider("openai").default_model, "gpt-5.5")+ anthropic = get_llm_provider("anthropic")+ self.assertEqual(anthropic.default_model, "claude-sonnet-5")+ self.assertEqual(anthropic.default_base_url, "https://api.anthropic.com/v1/")+ self.assertEqual(anthropic.adapter, "openai_compatible")+ self.assertTrue(anthropic.requires_api_key)self.assertEqual(get_llm_provider("aimlapi").default_model, "openai/gpt-5-5")self.assertEqual(get_llm_provider("deepseek").default_model, "deepseek-v4-pro")self.assertEqual(@@ -311,6 +316,7 @@ class TestLiteLLMProvider(unittest.TestCase):["moonshot","openai",+ "anthropic","gemini","deepseek","qwen",@@ -679,6 +685,48 @@ class TestLiteLLMProvider(unittest.TestCase):)self.assertEqual(result, "hello\npollinations")+ def test_anthropic_uses_openai_compatible_chat_completions(self):+ """Claude 走 Anthropic 的 OpenAI 兼容端点,不需要额外适配器分支。"""+ config.app.update(+ {+ "llm_provider": "anthropic",+ "anthropic_api_key": "anthropic-test-key",+ "anthropic_base_url": "",+ "anthropic_model_name": "",+ }+ )++ class FakeCompletions:+ def create(self, **kwargs):+ self.kwargs = kwargs+ message = types.SimpleNamespace(content="hello\nclaude")+ 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="anthropic-test-key",+ base_url="https://api.anthropic.com/v1/",+ )+ self.assertEqual(+ fake_completions.kwargs,+ {+ "model": "claude-sonnet-5",+ "messages": [{"role": "user", "content": "Say hello"}],+ },+ )+ self.assertEqual(result, "hello\nclaude")+def test_gemini_uses_google_genai_client(self):"""Gemini 适配器应通过新版 SDK 的统一 Client 发起内容生成请求。"""config.app.update(diff --git a/webui/i18n/en.json b/webui/i18n/en.jsonindex 6108b763..90bffdd4 100644--- a/webui/i18n/en.json+++ b/webui/i18n/en.json@@ -348,6 +348,7 @@"llm_provider_tips.ollama": "##### Ollama Configuration\n- **API Key**: not required\n- **Base Url**: usually `http://localhost:11434/v1` for local runs or `http://host.docker.internal:11434/v1` for Docker{docker_hint}\n- **Model Name**: required; run `ollama list` and enter an installed model, such as `qwen:7b`","llm_provider_tips.ollama.docker_hint": "\n > Container environment detected. If Base Url is empty, `http://host.docker.internal:11434/v1` is used by default.\n","llm_provider_tips.openai": "##### OpenAI Configuration\n- **API Key**: create one on the [OpenAI Platform]({api_key_url})\n- **Base Url**: defaults to `{default_base_url}`; enter another endpoint when using a compatible service\n- **Model Name**: defaults to `{default_model}`; you can also enter another model ID available to your account\n> Accessing the official service may require a network proxy in some regions",+ "llm_provider_tips.anthropic": "##### Anthropic Claude Configuration\n- **API Key**: create one in the [Claude Console]({api_key_url})\n- **Base Url**: defaults to `{default_base_url}`, the OpenAI-compatible endpoint provided by Anthropic\n- **Model Name**: defaults to `{default_model}`; you can also enter another Claude model ID available to your account","llm_provider_tips.shengsuanyun": "##### Shengsuan Cloud Configuration\n- **API Key**: register and create one through the [Shengsuan Cloud API Key page]({api_key_url}); new MoneyPrinterTurbo users can receive a CNY 10 token voucher\n- **Base Url**: defaults to `{default_base_url}`\n- **Model Name**: defaults to `{default_model}`; [view the model list](https://global.modelmesh.info/model)\n\nWhen selected, LoomLoom script and video generation automatically reuse this API Key.","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",diff --git a/webui/i18n/zh.json b/webui/i18n/zh.jsonindex 4c64723a..805ca6c3 100644--- a/webui/i18n/zh.json+++ b/webui/i18n/zh.json@@ -348,6 +348,7 @@"llm_provider_tips.ollama": "##### Ollama 配置说明\n- **API Key**: 无需填写\n- **Base Url**: 本机运行时通常为 `http://localhost:11434/v1`;Docker 部署时通常为 `http://host.docker.internal:11434/v1`{docker_hint}\n- **Model Name**: 必填;运行 `ollama list` 查看本机已安装的模型,例如 `qwen:7b`","llm_provider_tips.ollama.docker_hint": "\n > 检测到容器环境,未配置 Base Url 时会默认使用 `http://host.docker.internal:11434/v1`\n","llm_provider_tips.openai": "##### OpenAI 配置说明\n- **API Key**: 在 [OpenAI Platform]({api_key_url}) 创建\n- **Base Url**: 默认 `{default_base_url}`;使用兼容服务时可填写对应地址\n- **Model Name**: 默认 `{default_model}`;也可以填写当前账号支持的其它模型 ID\n> 部分地区访问官方服务时可能需要配置网络代理",+ "llm_provider_tips.anthropic": "##### Anthropic Claude 配置说明\n- **API Key**: 在 [Claude Console]({api_key_url}) 创建\n- **Base Url**: 默认 `{default_base_url}`,即 Anthropic 提供的 OpenAI 兼容端点\n- **Model Name**: 默认 `{default_model}`;也可以填写当前账号支持的其它 Claude 模型 ID","llm_provider_tips.shengsuanyun": "##### 胜算云配置说明\n- **API Key**: 通过 [胜算云 API Key 获取入口]({api_key_url}) 注册并创建;MoneyPrinterTurbo 新用户可领取 10 元 Token 券\n- **Base Url**: 默认 `{default_base_url}`\n- **Model Name**: 默认 `{default_model}`;[查看模型列表](https://global.modelmesh.info/model)\n\n选择胜算云后,文案和视频设置中的 LoomLoom 功能会自动复用此 API Key。","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",