Skip to content

利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.

feat(llm): add Fluxion AI provider

harry0703b66674be0fc3
diff --git a/README-en.md b/README-en.md
index fa3e8816..9668f092 100644
--- a/README-en.md
+++ b/README-en.md
@@ -124,6 +124,14 @@ Thanks to [Kimi](https://platform.kimi.ai?track_id=track-f6b0a640d35c41deb03b247
🎁 <strong>Exclusive offer for MoneyPrinterTurbo users</strong>: register through <a href="https://www.ucloud.cn/site/active/astraflow?ytag=geo_waituo_Money">our referral link</a> to receive new-user credits and get started right away! <a href="https://f.howxm.com/xs/u/HVFW5X8EIYV1">Claim CNY 50 in compute credits</a>.
</td>
</tr>
+ <tr>
+ <td align="center" width="120">
+ <a href="https://fluxionai.space/register?source=github&amp;campaign=moneyprinterturbo&amp;promo=MONEYPRINTERTURBO"><img src="docs/sponsors/fluxionai-logo.png" alt="Fluxion AI" width="120"></a>
+ </td>
+ <td align="left">
+ Thanks to <a href="https://fluxionai.space/register?source=github&amp;campaign=moneyprinterturbo&amp;promo=MONEYPRINTERTURBO">Fluxion AI</a> for sponsoring this project! <strong>One gateway to access and manage leading AI models worldwide.</strong> Built for individual developers, technical teams, and enterprises, Fluxion AI offers a unified API with dynamic routing across multiple providers to improve availability, plus transparent model performance, response times, and costs. Depending on the model and route, <strong>API costs can be 40%–98% lower than official or benchmark rates</strong>. Sign up through <a href="https://fluxionai.space/register?source=github&amp;campaign=moneyprinterturbo&amp;promo=MONEYPRINTERTURBO">our exclusive link</a> to receive <strong>&#36;3 in API credits</strong>.
+ </td>
+ </tr>
<tr>
<td align="center" width="120">
<a href="https://reccloud.com"><img src="docs/sponsors/reccloud-logo.svg" alt="RecCloud" height="36"></a><br>
diff --git a/README-ja.md b/README-ja.md
index 94ff96ed..597f204b 100644
--- a/README-ja.md
+++ b/README-ja.md
@@ -103,6 +103,14 @@
🎁 <a href="https://www.shengsuanyun.com/?from=CH_XUQ4OTSK">こちらのリンク</a>から新規登録すると、10 元分のトライアルクレジットを受け取れます。
</td>
</tr>
+ <tr>
+ <td align="center" width="120">
+ <a href="https://fluxionai.space/register?source=github&amp;campaign=moneyprinterturbo&amp;promo=MONEYPRINTERTURBO"><img src="docs/sponsors/fluxionai-logo.png" alt="Fluxion AI" width="120"></a>
+ </td>
+ <td align="left">
+ 本プロジェクトを支援してくださっている <a href="https://fluxionai.space/register?source=github&amp;campaign=moneyprinterturbo&amp;promo=MONEYPRINTERTURBO">Fluxion AI</a> に感謝します! <strong>世界の主要 AI モデルへのアクセスと管理を、ひとつの窓口で。</strong>個人開発者、技術チーム、企業向けに、統一 API を通じて主要モデルを利用できるプラットフォームです。複数の接続経路を動的に切り替えることで可用性を高め、モデルの性能、応答時間、利用料金を透明に確認できます。モデルや接続経路によって、<strong>API 利用コストを公式料金や基準価格より 40%~98% 削減できます</strong>。<a href="https://fluxionai.space/register?source=github&amp;campaign=moneyprinterturbo&amp;promo=MONEYPRINTERTURBO">専用リンクから登録</a>すると、<strong>3 米ドル分の API クレジット</strong>を受け取れます。
+ </td>
+ </tr>
<tr>
<td align="center" width="120">
<a href="https://reccloud.com"><img src="docs/sponsors/reccloud-logo.svg" alt="RecCloud" height="36"></a><br>
diff --git a/README.md b/README.md
index acd89e6f..f5397c58 100644
--- a/README.md
+++ b/README.md
@@ -124,6 +124,14 @@
🎁 <strong>MoneyPrinterTurbo 用户专属福利</strong>:通过<a href="https://www.ucloud.cn/site/active/astraflow?ytag=geo_waituo_Money">专属推广链接</a>注册,即享新用户赠送额度,开箱即用!<a href="https://f.howxm.com/xs/u/HVFW5X8EIYV1">点击领取 50 元算力金</a>
</td>
</tr>
+ <tr>
+ <td align="center" width="120">
+ <a href="https://fluxionai.space/register?source=github&amp;campaign=moneyprinterturbo&amp;promo=MONEYPRINTERTURBO"><img src="docs/sponsors/fluxionai-logo.png" alt="Fluxion AI" width="120"></a>
+ </td>
+ <td align="left">
+ 感谢 <a href="https://fluxionai.space/register?source=github&amp;campaign=moneyprinterturbo&amp;promo=MONEYPRINTERTURBO">Fluxion AI</a> 赞助本项目!<strong>一个入口,接入并管理全球主流 AI 模型。</strong>面向个人开发者、技术团队与企业,通过统一 API 接入主流模型,多线路动态调度提升可用性,模型表现、响应时间与费用透明可查。根据不同模型与线路,<strong>API 调用成本较官方或基准价格可降低 40%~98%</strong>。通过<a href="https://fluxionai.space/register?source=github&amp;campaign=moneyprinterturbo&amp;promo=MONEYPRINTERTURBO">专属链接注册</a>,即可获得 <strong>&#36;3 API 额度</strong>。
+ </td>
+ </tr>
<tr>
<td align="center" width="120">
<a href="https://reccloud.cn"><img src="docs/sponsors/reccloud-logo.svg" alt="录咖" height="36"></a><br>
diff --git a/app/models/llm_provider.py b/app/models/llm_provider.py
index 48d831fb..ce72203f 100644
--- a/app/models/llm_provider.py
+++ b/app/models/llm_provider.py
@@ -398,6 +398,20 @@ LLM_PROVIDER_REGISTRY = (
default_base_url="https://www.api-route.com/v1",
model_docs_url="https://www.api-route.com/pricing",
),
+ # Fluxion 的 OpenAI 分组使用 /v1 接口,复用现有 Chat Completions 适配器。
+ # 分组决定可用模型和地址,因此这里只提供默认值,保留用户覆盖配置的能力;
+ # Anthropic/Gemini 原生分组不能直接使用这个入口,避免协议不匹配。
+ LLMProviderSpec(
+ "fluxionai",
+ "Fluxion AI",
+ api_key_url=(
+ "https://fluxionai.space/register?source=github"
+ "&campaign=moneyprinterturbo&promo=MONEYPRINTERTURBO"
+ ),
+ default_model="gpt-5.5",
+ default_base_url="https://fluxionai.space/v1",
+ model_docs_url="https://fluxionai.space/model-plaza",
+ ),
# 本地部署与通用网关
LLMProviderSpec(
"ollama",
diff --git a/config.example.toml b/config.example.toml
index ec5e2631..ea0e2dbe 100644
--- a/config.example.toml
+++ b/config.example.toml
@@ -243,6 +243,13 @@ apimart_api_key = ""
apimart_base_url = ""
apimart_model_name = ""
+# Fluxion AI:使用 OpenAI 接口分组的 API Key,地址和模型可按分组覆盖。
+# 留空时默认使用 https://fluxionai.space/v1 和 gpt-5.5。
+# 模型广场:https://fluxionai.space/model-plaza
+fluxionai_api_key = ""
+fluxionai_base_url = ""
+fluxionai_model_name = ""
+
# OpenAI or another OpenAI Chat Completions-compatible provider.
# API key: https://platform.openai.com/api-keys
openai_api_key = ""
diff --git a/docs/sponsors/fluxionai-logo.png b/docs/sponsors/fluxionai-logo.png
new file mode 100644
index 00000000..22c691b1
Binary files /dev/null and b/docs/sponsors/fluxionai-logo.png differ
diff --git a/test/services/test_fluxionai_llm.py b/test/services/test_fluxionai_llm.py
new file mode 100644
index 00000000..fa0ad668
--- /dev/null
+++ b/test/services/test_fluxionai_llm.py
@@ -0,0 +1,138 @@
+"""Fluxion AI 接入回归:使用真实 SDK 编解码,HTTP 层不访问外网或消耗额度。"""
+
+import json
+from unittest.mock import patch
+
+import httpx
+import pytest
+from openai import OpenAI
+
+from app.config import config
+from app.models.llm_provider import get_llm_provider
+from app.services import llm
+
+
+ "base_url,model,expected_url,expected_model",
+ [
+ ("", "", "https://fluxionai.space/v1/chat/completions", "gpt-5.5"),
+ (" ", " ", "https://fluxionai.space/v1/chat/completions", "gpt-5.5"),
+ (
+ "https://gateway.example.com/custom/v1/",
+ "custom-group-model",
+ "https://gateway.example.com/custom/v1/chat/completions",
+ "custom-group-model",
+ ),
+ ],
+)
+def test_fluxionai_defaults_and_group_overrides(
+ base_url, model, expected_url, expected_model
+):
+ """空配置使用默认值,分组自定义值不被覆盖;其他 Provider 的配置保持原样。"""
+ snapshot = dict(config.app)
+ requests = []
+
+ def respond(request):
+ requests.append(request)
+ assert str(request.url) == expected_url
+ assert request.headers["Authorization"] == "Bearer test-fluxion-key"
+ assert json.loads(request.content) == {
+ "model": expected_model,
+ "messages": [{"role": "user", "content": "生成中文文案"}],
+ }
+ return httpx.Response(
+ 200,
+ json={
+ "id": "test-completion",
+ "object": "chat.completion",
+ "created": 0,
+ "model": expected_model,
+ "choices": [
+ {
+ "index": 0,
+ "message": {"role": "assistant", "content": "你好,世界!"},
+ "finish_reason": "stop",
+ }
+ ],
+ },
+ )
+
+ # 保留真实 SDK 的 URL 拼接和响应解析,只替换 HTTP 传输层,避免 mock 掩盖协议问题。
+ with httpx.Client(transport=httpx.MockTransport(respond)) as http_client:
+ with OpenAI(
+ api_key="test-fluxion-key",
+ base_url=base_url.strip() or "https://fluxionai.space/v1",
+ http_client=http_client,
+ max_retries=0,
+ ) as client:
+ with patch.object(llm, "OpenAI", return_value=client) as factory:
+ result = llm._generate_response(
+ "生成中文文案",
+ app_config={
+ "llm_provider": "fluxionai",
+ "fluxionai_api_key": "test-fluxion-key",
+ "fluxionai_base_url": base_url,
+ "fluxionai_model_name": model,
+ },
+ )
+ factory.assert_called_once_with(
+ api_key="test-fluxion-key",
+ base_url=base_url.strip() or "https://fluxionai.space/v1",
+ )
+ assert result == "你好,世界!"
+ assert len(requests) == 1
+ assert config.app == snapshot
+
+
+def test_fluxionai_missing_key_fails_before_network():
+ """缺少密钥时沿用统一错误提示,不创建客户端或发起付费请求。"""
+ with patch.object(llm, "OpenAI") as factory:
+ result = llm._generate_response(
+ "test", app_config={"llm_provider": "fluxionai"}
+ )
+ assert result.startswith("Error:")
+ assert "fluxionai: api_key is not set" in result
+ factory.assert_not_called()
+
+
[email protected]("status", [401, 403, 429, 500])
+def test_fluxionai_http_errors_are_not_successful_text(status):
+ """鉴权、分组权限、限流和服务端错误必须走错误路径,不能被当成正常文案。"""
+
+ def respond(request):
+ return httpx.Response(
+ status,
+ json={"error": {"message": "test upstream failure", "type": "api_error"}},
+ )
+
+ with httpx.Client(transport=httpx.MockTransport(respond)) as http_client:
+ with OpenAI(
+ api_key="test-key",
+ base_url="https://fluxionai.space/v1",
+ http_client=http_client,
+ max_retries=0,
+ ) as client:
+ with patch.object(llm, "OpenAI", return_value=client):
+ result = llm._generate_response(
+ "test",
+ app_config={
+ "llm_provider": "fluxionai",
+ "fluxionai_api_key": "test-key",
+ },
+ )
+ assert result.startswith("Error:")
+ assert str(status) in result
+
+
+def test_fluxionai_registry_metadata():
+ """锁定默认模型、协议、推广参数和模型链接,避免不同入口的信息不一致。"""
+ provider = get_llm_provider("fluxionai")
+ assert provider.default_model == "gpt-5.5"
+ assert provider.default_base_url == "https://fluxionai.space/v1"
+ assert provider.adapter == "openai_compatible"
+ assert provider.requires_api_key
+ assert (
+ provider.api_key_url
+ == "https://fluxionai.space/register?source=github&campaign=moneyprinterturbo&promo=MONEYPRINTERTURBO"
+ )
+ assert provider.model_docs_url == "https://fluxionai.space/model-plaza"
diff --git a/test/services/test_llm.py b/test/services/test_llm.py
index e8b01c96..69e18196 100644
--- a/test/services/test_llm.py
+++ b/test/services/test_llm.py
@@ -377,6 +377,7 @@ class TestLiteLLMProvider(unittest.TestCase):
"evolink",
"openrouter",
"api_route",
+ "fluxionai",
"ollama",
"claude_code",
"oneapi",
diff --git a/test/services/test_webui_i18n.py b/test/services/test_webui_i18n.py
index 4045afc2..3f2062ac 100644
--- a/test/services/test_webui_i18n.py
+++ b/test/services/test_webui_i18n.py
@@ -48,6 +48,7 @@ ENGLISH_FALLBACK_KEYS = frozenset(
"llm_provider_label.apimart",
"llm_provider_label.openrouter",
"llm_provider_label.api_route",
+ "llm_provider_label.fluxionai",
"llm_provider_label.shengsuanyun",
"LoomLoom Poll Retry Pending",
"LoomLoom Poll Retry Warning",
diff --git a/test/services/test_webui_llm_settings.py b/test/services/test_webui_llm_settings.py
index 0e23ea9d..7376d2a6 100644
--- a/test/services/test_webui_llm_settings.py
+++ b/test/services/test_webui_llm_settings.py
@@ -20,6 +20,55 @@ def _widget_by_key(elements, key):
)
+def test_fluxionai_settings_defaults_and_connection_button():
+ """真实运行 Streamlit 组件:检查默认值、配置覆盖及连接测试入口,不写用户配置。"""
+ app_config = dict(
+ config.app,
+ llm_provider="fluxionai",
+ fluxionai_api_key="",
+ fluxionai_base_url="",
+ fluxionai_model_name="",
+ )
+ with (
+ patch.object(config, "app", app_config),
+ patch.object(config, "ui", dict(config.ui, language="zh")),
+ patch.object(config, "try_save_config", return_value=True),
+ patch.object(llm, "test_connection", return_value=(True, "", 0.1)) as test_connection,
+ ):
+ app = AppTest.from_file(str(WEBUI_MAIN), default_timeout=60)
+ app.session_state["ui_language"] = "zh"
+ app.session_state["settings_dialog_open"] = True
+ app.run()
+ assert not app.exception
+ assert _widget_by_key(app.selectbox, "llm_provider_select").value == "fluxionai"
+ assert (
+ _widget_by_key(app.text_input, "fluxionai_base_url_custom_input").value
+ == "https://fluxionai.space/v1"
+ )
+ assert (
+ _widget_by_key(app.text_input, "fluxionai_model_name_input").value
+ == "gpt-5.5"
+ )
+ assert app_config["fluxionai_base_url"] == ""
+ assert app_config["fluxionai_model_name"] == ""
+ assert any("OpenAI 接口分组" in str(item.value) for item in app.info)
+ _widget_by_key(app.text_input, "fluxionai_api_key_input").set_value(
+ "test-ui-key"
+ ).run()
+ _widget_by_key(app.text_input, "fluxionai_model_name_input").set_value(
+ "custom-model"
+ ).run()
+ _widget_by_key(app.text_input, "fluxionai_base_url_custom_input").set_value(
+ "https://gateway.example.com/v1"
+ ).run()
+ assert app_config["fluxionai_api_key"] == "test-ui-key"
+ assert app_config["fluxionai_model_name"] == "custom-model"
+ assert app_config["fluxionai_base_url"] == "https://gateway.example.com/v1"
+ _widget_by_key(app.button, "test_llm_connection_button").click().run()
+ test_connection.assert_called_once()
+ assert not app.exception
+
+
def test_kimi_platform_selection_keeps_endpoint_configuration_consistent():
"""Kimi 平台切换必须同步 Base URL,并只允许自定义模式编辑地址。"""
app_config = dict(
diff --git a/webui/i18n/en.json b/webui/i18n/en.json
index 30634db0..b3ecbf2e 100644
--- a/webui/i18n/en.json
+++ b/webui/i18n/en.json
@@ -232,6 +232,8 @@
"llm_provider_label.apimart": "APIMart",
"llm_provider_label.openrouter": "OpenRouter",
"llm_provider_label.api_route": "API Route",
+ "llm_provider_label.fluxionai": "Fluxion AI",
+ "llm_provider_tips.fluxionai": "##### Fluxion AI Configuration\n- **API Key**: Sign up through the [referral link]({api_key_url}) and create a key for an **OpenAI API group** in the console\n- **Base Url**: Defaults to `{default_base_url}`. If your group uses another endpoint, enter its OpenAI-compatible API base URL (including `/v1`), not the full `/chat/completions` path\n- **Model Name**: Defaults to `{default_model}`. Available models depend on your group; check the [model plaza]({model_docs_url})\n\nUsed to generate video scripts and stock-footage search terms. Native Anthropic and Gemini API groups are not supported by this entry.",
"API Key": "API Key",
"Base Url": "Base Url",
"Account ID": "Account ID",
diff --git a/webui/i18n/zh.json b/webui/i18n/zh.json
index 6ea1e175..e9bcd24f 100644
--- a/webui/i18n/zh.json
+++ b/webui/i18n/zh.json
@@ -232,6 +232,8 @@
"llm_provider_label.apimart": "APIMart",
"llm_provider_label.openrouter": "OpenRouter",
"llm_provider_label.api_route": "API Route",
+ "llm_provider_label.fluxionai": "Fluxion AI",
+ "llm_provider_tips.fluxionai": "##### Fluxion AI 配置说明\n- **API Key**:通过[专属链接]({api_key_url})注册,在控制台创建 **OpenAI 接口分组**的密钥\n- **Base Url**:默认 `{default_base_url}`;如分组提供其他地址,请填写对应的 OpenAI 兼容 API 地址(包含 `/v1`),不要填写完整的 `/chat/completions` 路径\n- **Model Name**:默认 `{default_model}`;可用模型随分组不同而变化,请在[模型广场]({model_docs_url})查看\n\n用于生成视频文案和素材搜索关键词。Anthropic 或 Gemini 原生接口分组不适用于此入口。",
"API Key": "API Key",
"Base Url": "Base Url",
"Account ID": "Account ID",