Skip to content

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

feat(llm): add Infistar provider

harry0703ebb0e28300eb
diff --git a/app/models/llm_provider.py b/app/models/llm_provider.py
index 9b99837d..a07ace76 100644
--- a/app/models/llm_provider.py
+++ b/app/models/llm_provider.py
@@ -374,6 +374,14 @@ LLM_PROVIDER_REGISTRY = (
model_docs_url="https://maas.xfyun.cn/modelSquare",
),
# 聚合与统一接入平台
+ LLMProviderSpec(
+ "infistar",
+ "Infistar",
+ api_key_url="https://infistar.cc/keys",
+ default_model="gpt-6-luna",
+ default_base_url="https://infistar.cc/v1",
+ model_docs_url="https://infistar.cc/pricing",
+ ),
LLMProviderSpec(
"shengsuanyun",
"Shengsuan Cloud",
diff --git a/config.example.toml b/config.example.toml
index 925a00d3..96563609 100644
--- a/config.example.toml
+++ b/config.example.toml
@@ -258,6 +258,13 @@ moonshot_api_key = ""
moonshot_base_url = ""
moonshot_model_name = ""
+# 无限星河 AI(Infistar),项目赞助商,提供 OpenAI 兼容接口。
+# 密钥:https://infistar.cc/keys;模型列表:https://infistar.cc/pricing
+# 地址和模型留空时使用 https://infistar.cc/v1 和 gpt-6-luna。
+infistar_api_key = ""
+infistar_base_url = ""
+infistar_model_name = ""
+
# Shengsuan Cloud, OpenAI-compatible multi-model API.
# API docs: https://lean.shengsuanyun.com/apidocs/api/openai-api
shengsuanyun_api_key = ""
diff --git a/test/services/test_infistar.py b/test/services/test_infistar.py
new file mode 100644
index 00000000..742f4425
--- /dev/null
+++ b/test/services/test_infistar.py
@@ -0,0 +1,89 @@
+"""验证 Infistar 的真实 SDK 请求、默认配置和自定义覆盖。"""
+
+import json
+from unittest.mock import patch
+
+import httpx
+from openai import OpenAI
+import pytest
+
+from app.config import config
+from app.services import llm
+
+
+ "base_url,model,expected_url,expected_model",
+ [
+ ("", "", "https://infistar.cc/v1/chat/completions", "gpt-6-luna"),
+ (
+ "https://gateway.example.com/v1",
+ "custom-model",
+ "https://gateway.example.com/v1/chat/completions",
+ "custom-model",
+ ),
+ ],
+)
+def test_infistar_chat_completion_request(
+ base_url, model, expected_url, expected_model
+):
+ """通过真实 OpenAI SDK 编解码,避免只检查模拟客户端的调用参数。"""
+ received = []
+
+ def respond(request):
+ received.append(request)
+ return httpx.Response(
+ 200,
+ json={
+ "id": "infistar-test",
+ "object": "chat.completion",
+ "created": 0,
+ "model": expected_model,
+ "choices": [
+ {
+ "index": 0,
+ "message": {"role": "assistant", "content": "测试成功"},
+ "finish_reason": "stop",
+ }
+ ],
+ },
+ )
+
+ def make_client(**kwargs):
+ return OpenAI(
+ **kwargs, http_client=httpx.Client(transport=httpx.MockTransport(respond))
+ )
+
+ app_config = dict(
+ config.app,
+ llm_provider="infistar",
+ infistar_api_key="test-infistar-key",
+ infistar_base_url=base_url,
+ infistar_model_name=model,
+ )
+ with (
+ patch.object(config, "app", app_config),
+ patch.object(llm, "OpenAI", make_client),
+ ):
+ assert llm._generate_response("生成视频文案") == "测试成功"
+
+ assert len(received) == 1
+ request = received[0]
+ assert str(request.url) == expected_url
+ assert request.headers["Authorization"] == "Bearer test-infistar-key"
+ assert json.loads(request.content) == {
+ "model": expected_model,
+ "messages": [{"role": "user", "content": "生成视频文案"}],
+ }
+
+
+def test_infistar_missing_key_does_not_send_request():
+ """选择新 Provider 后必须使用专属 Key,不能意外复用其他服务的凭据。"""
+ app_config = dict(
+ config.app,
+ llm_provider="infistar",
+ infistar_api_key="",
+ openai_api_key="other-key",
+ )
+ with patch.object(config, "app", app_config), patch.object(llm, "OpenAI") as client:
+ assert "infistar: api_key is not set" in llm._generate_response("test")
+ client.assert_not_called()
diff --git a/test/services/test_llm.py b/test/services/test_llm.py
index d7cc3850..94a5a753 100644
--- a/test/services/test_llm.py
+++ b/test/services/test_llm.py
@@ -675,6 +675,7 @@ class TestLiteLLMProvider(unittest.TestCase):
"minimax",
"mimo",
"iflytek",
+ "infistar",
"shengsuanyun",
"apimart",
"cloudflare",
diff --git a/test/services/test_webui_i18n.py b/test/services/test_webui_i18n.py
index bab2f54a..e77451de 100644
--- a/test/services/test_webui_i18n.py
+++ b/test/services/test_webui_i18n.py
@@ -64,6 +64,7 @@ ENGLISH_FALLBACK_KEYS = frozenset(
"llm_provider_label.onomeo",
"llm_provider_label.empiriolabs",
"llm_provider_label.shengsuanyun",
+ "llm_provider_label.infistar",
"llm_provider_label.muse_spark",
"llm_provider_label.kimi_code",
"kimi_code.oauth.login",
diff --git a/test/services/test_webui_llm_settings.py b/test/services/test_webui_llm_settings.py
index 0efa7de8..9cee7c0d 100644
--- a/test/services/test_webui_llm_settings.py
+++ b/test/services/test_webui_llm_settings.py
@@ -90,6 +90,56 @@ def test_fluxionai_settings_defaults_and_connection_button():
assert not app.exception
+def test_infistar_settings_defaults_and_custom_configuration():
+ """真实运行设置页,确认默认模型、赞助商说明及可保存的自定义配置。"""
+ app_config = dict(
+ config.app,
+ llm_provider="infistar",
+ infistar_api_key="",
+ infistar_base_url="",
+ infistar_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 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 == "infistar"
+ assert (
+ _widget_by_key(app.text_input, "infistar_base_url_custom_input").value
+ == "https://infistar.cc/v1"
+ )
+ assert (
+ _widget_by_key(app.text_input, "infistar_model_name_input").value
+ == "gpt-6-luna"
+ )
+ assert app_config["infistar_base_url"] == ""
+ assert app_config["infistar_model_name"] == ""
+ assert any("项目赞助商" in str(item.value) for item in app.info)
+
+ _widget_by_key(app.text_input, "infistar_api_key_input").set_value(
+ "test-ui-key"
+ ).run()
+ _widget_by_key(app.text_input, "infistar_model_name_input").set_value(
+ "custom-model"
+ ).run()
+ _widget_by_key(app.text_input, "infistar_base_url_custom_input").set_value(
+ "https://gateway.example.com/v1"
+ ).run()
+ assert app_config["infistar_api_key"] == "test-ui-key"
+ assert app_config["infistar_model_name"] == "custom-model"
+ assert app_config["infistar_base_url"] == "https://gateway.example.com/v1"
+ _widget_by_key(app.button, "test_llm_connection_button").click().run()
+ 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 cf3d3d19..6984f2ec 100644
--- a/webui/i18n/en.json
+++ b/webui/i18n/en.json
@@ -234,6 +234,8 @@
"Recommended": "Recommended",
"llm_provider_label.moonshot": "Kimi / Moonshot AI (Recommended)",
"llm_provider_label.muse_spark": "Muse Spark",
+ "llm_provider_label.infistar": "Infistar",
+ "llm_provider_tips.infistar": "##### Infistar Configuration\n- **API Key**: Create a key in the [Infistar console]({api_key_url})\n- **Base Url**: Defaults to `{default_base_url}`\n- **Model Name**: Defaults to `{default_model}`; see the [model list]({model_docs_url}) for other model IDs\n\nInfistar sponsors MoneyPrinterTurbo and provides an OpenAI-compatible API.",
"llm_provider_label.shengsuanyun": "Shengsuan Cloud",
"llm_provider_label.apimart": "APIMart",
"llm_provider_label.openrouter": "OpenRouter",
diff --git a/webui/i18n/zh.json b/webui/i18n/zh.json
index 62f021a3..ef65798a 100644
--- a/webui/i18n/zh.json
+++ b/webui/i18n/zh.json
@@ -234,6 +234,8 @@
"Recommended": "推荐",
"llm_provider_label.moonshot": "Kimi / Moonshot AI(推荐)",
"llm_provider_label.muse_spark": "Muse Spark",
+ "llm_provider_label.infistar": "无限星河 AI / Infistar",
+ "llm_provider_tips.infistar": "##### 无限星河 AI 配置说明\n- **API Key**:在[无限星河控制台]({api_key_url})创建密钥\n- **Base Url**:默认 `{default_base_url}`\n- **Model Name**:默认 `{default_model}`;其他模型 ID 请查看[模型列表]({model_docs_url})\n\nInfistar 是 MoneyPrinterTurbo 的项目赞助商,提供 OpenAI 兼容接口。",
"llm_provider_label.shengsuanyun": "胜算云",
"llm_provider_label.apimart": "APIMart",
"llm_provider_label.openrouter": "OpenRouter",