Skip to content

FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.

feat: add MiniMax as first-class LLM provider

octopuscc0cc04a649c
diff --git a/README.md b/README.md
index 2557f6680..b4b64e24a 100644
--- a/README.md
+++ b/README.md
@@ -47,7 +47,7 @@ State-of-the-art financial intelligence platform with CFA-level analytics, AI au
| **Feature** | **Description** |
|-------------|-----------------|
| 📊 **CFA-Level Analytics** | DCF models, portfolio optimization, risk metrics (VaR, Sharpe), derivatives pricing via embedded Python |
-| 🤖 **AI Agents** | 20+ investor personas (Buffett, Dalio, Graham), hedge fund strategies, local LLM support |
+| 🤖 **AI Agents** | 20+ investor personas (Buffett, Dalio, Graham), hedge fund strategies, local LLM support, multi-provider (OpenAI, Anthropic, Gemini, Groq, DeepSeek, MiniMax, OpenRouter, Ollama) |
| 🌐 **100+ Data Connectors** | DBnomics, Polygon, Kraken, Yahoo Finance, FRED, IMF, World Bank, AkShare, government APIs |
| 📈 **Real-Time Trading** | Crypto (Kraken/HyperLiquid WebSocket), equity, algo trading, paper trading engine |
| 🔬 **QuantLib Suite** | 18 quantitative analysis modules — pricing, risk, stochastic, volatility, fixed income |
diff --git a/fincept-qt/src/ai_chat/LlmService.cpp b/fincept-qt/src/ai_chat/LlmService.cpp
index 76a38673c..4344e5af7 100644
--- a/fincept-qt/src/ai_chat/LlmService.cpp
+++ b/fincept-qt/src/ai_chat/LlmService.cpp
@@ -228,6 +228,8 @@ QString LlmService::get_endpoint_url() const {
return "https://api.deepseek.com/v1/chat/completions";
if (p == "openrouter")
return "https://openrouter.ai/api/v1/chat/completions";
+ if (p == "minimax")
+ return "https://api.minimax.io/v1/chat/completions";
if (p == "ollama")
return "http://localhost:11434/v1/chat/completions";
return {};
@@ -277,7 +279,13 @@ QJsonObject LlmService::build_openai_request(const QString& user_message,
QJsonObject req;
req["model"] = model_;
req["messages"] = messages;
- req["temperature"] = temperature_;
+ // MiniMax requires temperature in (0.0, 1.0]; clamp if needed
+ if (provider_ == "minimax") {
+ double t = std::max(0.01, std::min(temperature_, 1.0));
+ req["temperature"] = t;
+ } else {
+ req["temperature"] = temperature_;
+ }
req["max_tokens"] = max_tokens_;
if (stream)
req["stream"] = true;
@@ -1491,6 +1499,7 @@ QString LlmService::get_models_url(const QString& provider, const QString& api_k
base.chop(1);
return base + "/api/tags";
}
+ // minimax: no public /v1/models endpoint — fallback models used instead
return {};
}
diff --git a/fincept-qt/src/ai_chat/LlmService.h b/fincept-qt/src/ai_chat/LlmService.h
index 71d118952..85b326a02 100644
--- a/fincept-qt/src/ai_chat/LlmService.h
+++ b/fincept-qt/src/ai_chat/LlmService.h
@@ -25,8 +25,8 @@ namespace fincept::ai_chat {
inline bool provider_supports_streaming(const QString& provider) {
return provider == "openai" || provider == "anthropic" || provider == "gemini" || provider == "google" ||
- provider == "groq" || provider == "deepseek" || provider == "openrouter" || provider == "ollama" ||
- provider == "fincept";
+ provider == "groq" || provider == "deepseek" || provider == "openrouter" || provider == "minimax" ||
+ provider == "ollama" || provider == "fincept";
}
inline bool provider_requires_api_key(const QString& provider) {
diff --git a/fincept-qt/src/screens/settings/LlmConfigSection.cpp b/fincept-qt/src/screens/settings/LlmConfigSection.cpp
index 19d57d7d9..79c03a30f 100644
--- a/fincept-qt/src/screens/settings/LlmConfigSection.cpp
+++ b/fincept-qt/src/screens/settings/LlmConfigSection.cpp
@@ -26,7 +26,7 @@ namespace fincept::screens {
static constexpr const char* TAG = "LlmConfigSection";
const QStringList LlmConfigSection::KNOWN_PROVIDERS = {"openai", "anthropic", "gemini", "groq",
- "deepseek", "openrouter", "ollama", "fincept"};
+ "deepseek", "openrouter", "minimax", "ollama", "fincept"};
QString LlmConfigSection::default_base_url(const QString& provider) {
const QString p = provider.toLower();
@@ -42,6 +42,8 @@ QString LlmConfigSection::default_base_url(const QString& provider) {
return {};
if (p == "openrouter")
return {};
+ if (p == "minimax")
+ return "https://api.minimax.io/v1";
if (p == "ollama")
return "http://localhost:11434";
if (p == "fincept")
@@ -64,6 +66,8 @@ QStringList LlmConfigSection::fallback_models(const QString& provider) {
return {"deepseek-chat", "deepseek-reasoner"};
if (p == "openrouter")
return {"openai/gpt-4o", "anthropic/claude-sonnet-4-5", "google/gemini-2.5-flash"};
+ if (p == "minimax")
+ return {"MiniMax-M2.7", "MiniMax-M2.7-highspeed", "MiniMax-M2.5", "MiniMax-M2.5-highspeed"};
if (p == "ollama")
return {"llama3:8b", "mistral:7b", "codellama:7b"};
if (p == "fincept")
diff --git a/fincept-qt/tests/test_minimax_integration.py b/fincept-qt/tests/test_minimax_integration.py
new file mode 100644
index 000000000..74053439e
--- /dev/null
+++ b/fincept-qt/tests/test_minimax_integration.py
@@ -0,0 +1,113 @@
+#!/usr/bin/env python3
+"""
+Integration tests for MiniMax LLM provider in Fincept Terminal.
+
+These tests verify the MiniMax API endpoint connectivity and response format
+using the real MiniMax API. Requires MINIMAX_API_KEY environment variable.
+"""
+
+import json
+import os
+import sys
+import unittest
+
+import urllib.request
+import urllib.error
+
+
+MINIMAX_API_KEY = os.environ.get("MINIMAX_API_KEY", "")
+MINIMAX_BASE_URL = "https://api.minimax.io/v1"
+
+
+def skip_without_api_key(func):
+ """Skip test if MINIMAX_API_KEY is not set."""
+ return unittest.skipIf(
+ not MINIMAX_API_KEY,
+ "MINIMAX_API_KEY not set — skipping integration test"
+ )(func)
+
+
+class TestMiniMaxApiConnectivity(unittest.TestCase):
+ """Verify MiniMax API endpoints are reachable and respond correctly."""
+
+ @skip_without_api_key
+ def test_models_endpoint_returns_404(self):
+ """MiniMax does not have a public /v1/models endpoint.
+ The Fincept Terminal uses fallback_models() instead."""
+ req = urllib.request.Request(
+ f"{MINIMAX_BASE_URL}/models",
+ headers={
+ "Authorization": f"Bearer {MINIMAX_API_KEY}",
+ "Content-Type": "application/json",
+ },
+ )
+ with self.assertRaises(urllib.error.HTTPError) as ctx:
+ urllib.request.urlopen(req, timeout=15)
+ self.assertEqual(ctx.exception.code, 404,
+ "MiniMax /v1/models should return 404 — no public endpoint")
+
+ @skip_without_api_key
+ def test_chat_completions_basic(self):
+ """POST /v1/chat/completions with MiniMax-M2.7 should return valid response."""
+ payload = json.dumps({
+ "model": "MiniMax-M2.7",
+ "messages": [
+ {"role": "user", "content": "Say 'hello' and nothing else."}
+ ],
+ "temperature": 0.5,
+ "max_tokens": 32,
+ }).encode()
+
+ req = urllib.request.Request(
+ f"{MINIMAX_BASE_URL}/chat/completions",
+ data=payload,
+ headers={
+ "Authorization": f"Bearer {MINIMAX_API_KEY}",
+ "Content-Type": "application/json",
+ },
+ method="POST",
+ )
+ try:
+ with urllib.request.urlopen(req, timeout=30) as resp:
+ self.assertEqual(resp.status, 200)
+ data = json.loads(resp.read().decode())
+ self.assertIn("choices", data,
+ "Response must contain 'choices' (OpenAI format)")
+ self.assertGreater(len(data["choices"]), 0)
+ content = data["choices"][0]["message"]["content"]
+ self.assertIsInstance(content, str)
+ self.assertGreater(len(content), 0,
+ "Response content should not be empty")
+ except urllib.error.HTTPError as e:
+ self.fail(f"Chat completions returned HTTP {e.code}: {e.read().decode()[:200]}")
+
+ @skip_without_api_key
+ def test_temperature_clamping_boundary(self):
+ """MiniMax API should accept temperature at the boundary value 1.0."""
+ payload = json.dumps({
+ "model": "MiniMax-M2.7",
+ "messages": [
+ {"role": "user", "content": "Hi"}
+ ],
+ "temperature": 1.0,
+ "max_tokens": 8,
+ }).encode()
+
+ req = urllib.request.Request(
+ f"{MINIMAX_BASE_URL}/chat/completions",
+ data=payload,
+ headers={
+ "Authorization": f"Bearer {MINIMAX_API_KEY}",
+ "Content-Type": "application/json",
+ },
+ method="POST",
+ )
+ try:
+ with urllib.request.urlopen(req, timeout=30) as resp:
+ self.assertEqual(resp.status, 200)
+ except urllib.error.HTTPError as e:
+ self.fail(f"Temperature 1.0 should be accepted, got HTTP {e.code}")
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/fincept-qt/tests/test_minimax_provider.py b/fincept-qt/tests/test_minimax_provider.py
new file mode 100644
index 000000000..51de402f5
--- /dev/null
+++ b/fincept-qt/tests/test_minimax_provider.py
@@ -0,0 +1,305 @@
+#!/usr/bin/env python3
+"""
+Unit tests for MiniMax LLM provider integration in Fincept Terminal.
+
+Validates that all MiniMax provider integration points are correctly wired
+in the C++ source code by parsing and inspecting the source files.
+"""
+
+import os
+import re
+import sys
+import unittest
+
+# Paths relative to repository root
+REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+SRC_DIR = os.path.join(REPO_ROOT, "src")
+LLM_CONFIG_SECTION = os.path.join(SRC_DIR, "screens", "settings", "LlmConfigSection.cpp")
+LLM_SERVICE_H = os.path.join(SRC_DIR, "ai_chat", "LlmService.h")
+LLM_SERVICE_CPP = os.path.join(SRC_DIR, "ai_chat", "LlmService.cpp")
+README_PATH = os.path.join(os.path.dirname(REPO_ROOT), "README.md")
+
+
+def read_file(path: str) -> str:
+ with open(path, "r", encoding="utf-8") as f:
+ return f.read()
+
+
+class TestMiniMaxKnownProviders(unittest.TestCase):
+ """Verify MiniMax appears in the KNOWN_PROVIDERS list."""
+
+ def setUp(self):
+ self.source = read_file(LLM_CONFIG_SECTION)
+
+ def test_minimax_in_known_providers(self):
+ match = re.search(
+ r'KNOWN_PROVIDERS\s*=\s*\{([^}]+)\}', self.source
+ )
+ self.assertIsNotNone(match, "KNOWN_PROVIDERS definition not found")
+ providers_str = match.group(1)
+ self.assertIn('"minimax"', providers_str,
+ "minimax must be in KNOWN_PROVIDERS list")
+
+ def test_known_providers_order(self):
+ """MiniMax should appear between openrouter and ollama."""
+ match = re.search(
+ r'KNOWN_PROVIDERS\s*=\s*\{([^}]+)\}', self.source
+ )
+ self.assertIsNotNone(match)
+ providers = re.findall(r'"(\w+)"', match.group(1))
+ self.assertIn("minimax", providers)
+ minimax_idx = providers.index("minimax")
+ self.assertIn("openrouter", providers)
+ openrouter_idx = providers.index("openrouter")
+ self.assertGreater(minimax_idx, openrouter_idx,
+ "minimax should come after openrouter")
+
+ def test_provider_count(self):
+ """Should have 9 known providers after adding minimax."""
+ match = re.search(
+ r'KNOWN_PROVIDERS\s*=\s*\{([^}]+)\}', self.source
+ )
+ self.assertIsNotNone(match)
+ providers = re.findall(r'"(\w+)"', match.group(1))
+ self.assertEqual(len(providers), 9,
+ f"Expected 9 providers, got {len(providers)}: {providers}")
+
+
+class TestMiniMaxBaseUrl(unittest.TestCase):
+ """Verify default_base_url returns the correct MiniMax URL."""
+
+ def setUp(self):
+ self.source = read_file(LLM_CONFIG_SECTION)
+
+ def test_minimax_base_url_entry(self):
+ self.assertIn('p == "minimax"', self.source,
+ "default_base_url() must handle minimax provider")
+
+ def test_minimax_base_url_value(self):
+ # Find the minimax base URL assignment
+ pattern = r'if\s*\(p\s*==\s*"minimax"\)\s*\n\s*return\s*"([^"]+)"'
+ match = re.search(pattern, self.source)
+ self.assertIsNotNone(match, "MiniMax base URL return not found")
+ self.assertEqual(match.group(1), "https://api.minimax.io/v1",
+ "MiniMax base URL must be https://api.minimax.io/v1")
+
+
+class TestMiniMaxFallbackModels(unittest.TestCase):
+ """Verify fallback_models returns correct MiniMax models."""
+
+ def setUp(self):
+ self.source = read_file(LLM_CONFIG_SECTION)
+
+ def test_minimax_fallback_models_exist(self):
+ # Find the minimax models section
+ pattern = r'if\s*\(p\s*==\s*"minimax"\)\s*\n\s*return\s*\{([^}]+)\}'
+ match = re.search(pattern, self.source)
+ self.assertIsNotNone(match, "MiniMax fallback models not found")
+ models_str = match.group(1)
+
+ expected_models = [
+ "MiniMax-M2.7",
+ "MiniMax-M2.7-highspeed",
+ "MiniMax-M2.5",
+ "MiniMax-M2.5-highspeed",
+ ]
+ for model in expected_models:
+ self.assertIn(f'"{model}"', models_str,
+ f"Model {model} must be in MiniMax fallback models")
+
+ def test_minimax_model_count(self):
+ pattern = r'if\s*\(p\s*==\s*"minimax"\)\s*\n\s*return\s*\{([^}]+)\}'
+ match = re.search(pattern, self.source)
+ self.assertIsNotNone(match)
+ models = re.findall(r'"([^"]+)"', match.group(1))
+ self.assertEqual(len(models), 4,
+ f"Expected 4 MiniMax models, got {len(models)}: {models}")
+
+
+class TestMiniMaxStreamingSupport(unittest.TestCase):
+ """Verify MiniMax is listed as supporting streaming."""
+
+ def setUp(self):
+ self.source = read_file(LLM_SERVICE_H)
+
+ def test_minimax_in_streaming_providers(self):
+ match = re.search(
+ r'provider_supports_streaming\([^)]+\)\s*\{[^}]+\}',
+ self.source, re.DOTALL
+ )
+ self.assertIsNotNone(match,
+ "provider_supports_streaming() not found")
+ self.assertIn('"minimax"', match.group(0),
+ "minimax must be in provider_supports_streaming()")
+
+
+class TestMiniMaxEndpointUrl(unittest.TestCase):
+ """Verify get_endpoint_url handles MiniMax correctly."""
+
+ def setUp(self):
+ self.source = read_file(LLM_SERVICE_CPP)
+
+ def test_minimax_endpoint_url(self):
+ pattern = r'if\s*\(p\s*==\s*"minimax"\)\s*\n\s*return\s*"([^"]+)"'
+ # Look in the get_endpoint_url section
+ endpoint_section = self.source[
+ self.source.index("get_endpoint_url"):
+ self.source.index("get_headers")
+ ]
+ match = re.search(pattern, endpoint_section)
+ self.assertIsNotNone(match, "MiniMax endpoint URL not found in get_endpoint_url()")
+ self.assertEqual(match.group(1),
+ "https://api.minimax.io/v1/chat/completions",
+ "MiniMax endpoint must be https://api.minimax.io/v1/chat/completions")
+
+
+class TestMiniMaxModelsUrl(unittest.TestCase):
+ """Verify get_models_url does NOT return a URL for MiniMax
+ (no public /v1/models endpoint — fallback models are used)."""
+
+ def setUp(self):
+ self.source = read_file(LLM_SERVICE_CPP)
+
+ def test_minimax_no_models_url(self):
+ """MiniMax should not have a models URL in get_models_url()
+ because the API has no public /v1/models endpoint."""
+ models_section = self.source[
+ self.source.index("get_models_url"):
+ self.source.index("get_models_headers")
+ ]
+ # Should NOT have a minimax-specific models URL
+ self.assertNotIn('p == "minimax"', models_section,
+ "MiniMax should not have a models URL entry — "
+ "no public /v1/models endpoint")
+
+ def test_minimax_comment_in_get_models_url(self):
+ """A comment should explain why minimax has no models URL."""
+ models_section = self.source[
+ self.source.index("get_models_url"):
+ self.source.index("get_models_headers")
+ ]
+ self.assertIn("minimax", models_section.lower(),
+ "Comment about minimax should exist in get_models_url()")
+
+
+class TestMiniMaxTemperatureClamping(unittest.TestCase):
+ """Verify MiniMax temperature is clamped to (0.0, 1.0]."""
+
+ def setUp(self):
+ self.source = read_file(LLM_SERVICE_CPP)
+
+ def test_temperature_clamping_exists(self):
+ # Check that there's a minimax-specific temperature clamp in build_openai_request
+ self.assertIn('provider_ == "minimax"', self.source,
+ "Temperature clamping for minimax must exist")
+
+ def test_temperature_clamp_range(self):
+ # Verify the clamp range: std::max(0.01, std::min(temperature_, 1.0))
+ clamp_section = self.source[
+ self.source.index("build_openai_request"):
+ self.source.index("build_anthropic_request")
+ ]
+ self.assertIn("0.01", clamp_section,
+ "Lower bound of temperature clamp should be 0.01")
+ self.assertIn("1.0", clamp_section,
+ "Upper bound of temperature clamp should be 1.0")
+
+
+class TestMiniMaxAuthHeaders(unittest.TestCase):
+ """Verify MiniMax uses OpenAI-compatible Bearer auth headers."""
+
+ def setUp(self):
+ self.source = read_file(LLM_SERVICE_CPP)
+
+ def test_minimax_uses_bearer_auth(self):
+ """MiniMax should fall through to OpenAI-compatible Bearer auth
+ (no special handling needed — it uses the else branch)."""
+ headers_section = self.source[
+ self.source.index("get_headers"):
+ self.source.index("Request builders")
+ ]
+ # MiniMax should NOT have its own special header handling
+ self.assertNotIn('p == "minimax"', headers_section,
+ "MiniMax should use default OpenAI-compatible Bearer auth, "
+ "not have its own header block")
+
+
+class TestMiniMaxApiKeyRequired(unittest.TestCase):
+ """Verify MiniMax requires an API key."""
+
+ def setUp(self):
+ self.source = read_file(LLM_SERVICE_H)
+
+ def test_minimax_requires_api_key(self):
+ """provider_requires_api_key should return true for minimax
+ (it only excludes ollama and fincept)."""
+ match = re.search(
+ r'provider_requires_api_key\([^)]+\)\s*\{[^}]+\}',
+ self.source, re.DOTALL
+ )
+ self.assertIsNotNone(match)
+ func_body = match.group(0)
+ # minimax should NOT be excluded
+ self.assertNotIn('"minimax"', func_body,
+ "MiniMax should require API key (not excluded)")
+
+
+class TestMiniMaxOpenAICompatible(unittest.TestCase):
+ """Verify MiniMax uses the OpenAI-compatible request path in do_request."""
+
+ def setUp(self):
+ self.source = read_file(LLM_SERVICE_CPP)
+
+ def test_minimax_not_special_cased_in_do_request(self):
+ """MiniMax should fall through to the OpenAI-compatible else branch
+ in do_request() — no special provider_ == 'minimax' check needed."""
+ do_request_section = self.source[
+ self.source.index("LlmResponse LlmService::do_request"):
+ self.source.index("Tool-call follow-up loop")
+ ]
+ # MiniMax should NOT have its own special response parsing
+ self.assertNotIn('provider_ == "minimax"', do_request_section,
+ "MiniMax should use OpenAI-compatible response parsing, "
+ "not have its own block in do_request()")
+
+
+class TestMiniMaxReadme(unittest.TestCase):
+ """Verify MiniMax is mentioned in the README."""
+
+ def setUp(self):
+ self.source = read_file(README_PATH)
+
+ def test_minimax_in_readme(self):
+ self.assertIn("MiniMax", self.source,
+ "MiniMax must be mentioned in README.md")
+
+ def test_minimax_in_provider_list(self):
+ """MiniMax should appear in the AI Agents feature row."""
+ # Find the line that contains AI Agents
+ lines = self.source.split("\n")
+ ai_agents_line = None
+ for line in lines:
+ if "AI Agents" in line and "multi-provider" in line:
+ ai_agents_line = line
+ break
+ self.assertIsNotNone(ai_agents_line,
+ "AI Agents row with multi-provider must exist")
+ self.assertIn("MiniMax", ai_agents_line,
+ "MiniMax must be listed in AI Agents feature row")
+
+
+class TestMiniMaxTextToolCallSupport(unittest.TestCase):
+ """Verify MiniMax is acknowledged in text-based tool call detection."""
+
+ def setUp(self):
+ self.source = read_file(LLM_SERVICE_CPP)
+
+ def test_minimax_mentioned_in_text_tool_calls(self):
+ """The try_extract_and_execute_text_tool_calls comment mentions minimax
+ as a model that uses text-based tool calls."""
+ self.assertIn("minimax", self.source.lower(),
+ "minimax should be mentioned in text tool call comments")
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)