Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

feat(providers): add Novita AI as an LLM gateway (#746)

jax-novita160f12ab24ab
diff --git a/deeptutor/services/config/context_window_detection.py b/deeptutor/services/config/context_window_detection.py
index 202521695..4f55d6c85 100644
--- a/deeptutor/services/config/context_window_detection.py
+++ b/deeptutor/services/config/context_window_detection.py
@@ -24,6 +24,7 @@ _CONTEXT_WINDOW_KEYS = (
"context_window",
"context_window_tokens",
"context_length",
+ "context_size",
"max_context_tokens",
"max_input_tokens",
"input_token_limit",
diff --git a/deeptutor/services/provider_registry.py b/deeptutor/services/provider_registry.py
index 9af807957..790738e2a 100644
--- a/deeptutor/services/provider_registry.py
+++ b/deeptutor/services/provider_registry.py
@@ -96,6 +96,7 @@ PROVIDER_ALIASES = {
"atlas_cloud": "atlascloud",
"atlas-cloud": "atlascloud",
"eden_ai": "edenai",
+ "novita_ai": "novita",
}
@@ -184,6 +185,16 @@ PROVIDERS: tuple[ProviderSpec, ...] = (
detect_by_base_keyword="siliconflow",
default_api_base="https://api.siliconflow.cn/v1",
),
+ ProviderSpec(
+ name="novita",
+ keywords=("novita", "novita-ai", "novita ai"),
+ env_key="NOVITA_API_KEY",
+ display_name="Novita AI",
+ backend="openai_compat",
+ is_gateway=True,
+ detect_by_base_keyword="novita",
+ default_api_base="https://api.novita.ai/openai",
+ ),
ProviderSpec(
name="atlascloud",
keywords=("atlascloud", "atlas-cloud", "atlas cloud"),
diff --git a/tests/api/test_settings_router.py b/tests/api/test_settings_router.py
index ad55f5f46..69ebf4eb7 100644
--- a/tests/api/test_settings_router.py
+++ b/tests/api/test_settings_router.py
@@ -482,6 +482,13 @@ def test_llm_provider_choices_include_atlascloud() -> None:
assert llm["atlascloud"]["base_url"] == "https://api.atlascloud.ai/v1"
+def test_llm_provider_choices_include_novita() -> None:
+ llm = {item["value"]: item for item in settings_router._provider_choices()["llm"]}
+
+ assert llm["novita"]["label"] == "Novita AI"
+ assert llm["novita"]["base_url"] == "https://api.novita.ai/openai"
+
+
def test_llm_provider_choices_include_edenai() -> None:
llm = {item["value"]: item for item in settings_router._provider_choices()["llm"]}
diff --git a/tests/core/test_agentic_client_provider_kwargs.py b/tests/core/test_agentic_client_provider_kwargs.py
index b0b11fdc1..cd7d86475 100644
--- a/tests/core/test_agentic_client_provider_kwargs.py
+++ b/tests/core/test_agentic_client_provider_kwargs.py
@@ -210,6 +210,7 @@ def test_registered_cloud_openai_compat_providers_enable_native_tools() -> None:
"aihubmix",
"atlascloud",
"edenai",
+ "novita",
"volcengine_coding_plan",
"byteplus_coding_plan",
):
diff --git a/tests/services/config/test_context_window_detection.py b/tests/services/config/test_context_window_detection.py
index f927af504..2ef9ee9ce 100644
--- a/tests/services/config/test_context_window_detection.py
+++ b/tests/services/config/test_context_window_detection.py
@@ -85,6 +85,20 @@ def test_detect_context_window_uses_known_minimax_m3_window(
assert result.source == "known_model"
+def test_extract_context_window_reads_novita_context_size_key() -> None:
+ """Novita's /openai/models advertises the window as ``context_size``."""
+ payload = {
+ "data": [
+ {"id": "deepseek/deepseek-v3.2", "context_size": 1_000_000},
+ ]
+ }
+
+ assert (
+ detection_module._extract_context_window_from_payload(payload, "deepseek/deepseek-v3.2")
+ == 1_000_000
+ )
+
+
def test_models_endpoint_probe_honors_disable_ssl_verify(monkeypatch) -> None:
captured: dict[str, object] = {}
diff --git a/tests/services/config/test_provider_runtime.py b/tests/services/config/test_provider_runtime.py
index 340318dfc..5ec0f9e1e 100644
--- a/tests/services/config/test_provider_runtime.py
+++ b/tests/services/config/test_provider_runtime.py
@@ -165,6 +165,57 @@ def test_llm_atlascloud_base_url_detection_preserves_openai_binding_compatibilit
assert resolved.effective_url == "https://api.atlascloud.ai/v1"
+def test_llm_novita_binding_uses_default_openai_compatible_endpoint() -> None:
+ catalog = _build_catalog(
+ llm_profile={
+ "id": "llm-p",
+ "name": "Novita AI",
+ "binding": "novita",
+ "base_url": "",
+ "api_key": "novita-key",
+ "api_version": "",
+ "extra_headers": {},
+ "models": [
+ {
+ "id": "llm-m",
+ "name": "DeepSeek V3.2",
+ "model": "deepseek/deepseek-v3.2",
+ }
+ ],
+ }
+ )
+
+ resolved = resolve_llm_runtime_config(catalog=catalog)
+
+ assert resolved.provider_name == "novita"
+ assert resolved.provider_mode == "gateway"
+ assert resolved.binding == "novita"
+ assert resolved.model == "deepseek/deepseek-v3.2"
+ assert resolved.api_key == "novita-key"
+ assert resolved.effective_url == "https://api.novita.ai/openai"
+
+
+def test_llm_novita_base_url_detection_preserves_openai_binding_compatibility() -> None:
+ catalog = _build_catalog(
+ llm_profile={
+ "id": "llm-p",
+ "name": "OpenAI Compatible",
+ "binding": "openai",
+ "base_url": "https://api.novita.ai/openai",
+ "api_key": "novita-key",
+ "api_version": "",
+ "extra_headers": {},
+ "models": [{"id": "llm-m", "name": "DeepSeek", "model": "deepseek/deepseek-v3.2"}],
+ }
+ )
+
+ resolved = resolve_llm_runtime_config(catalog=catalog)
+
+ assert resolved.provider_name == "novita"
+ assert resolved.provider_mode == "gateway"
+ assert resolved.effective_url == "https://api.novita.ai/openai"
+
+
def test_llm_edenai_binding_uses_default_openai_compatible_endpoint() -> None:
catalog = _build_catalog(
llm_profile={
diff --git a/tests/services/test_provider_registry.py b/tests/services/test_provider_registry.py
index b3d886602..8b5339d2c 100644
--- a/tests/services/test_provider_registry.py
+++ b/tests/services/test_provider_registry.py
@@ -39,6 +39,20 @@ def test_edenai_provider_aliases_and_base_detection() -> None:
assert find_gateway(api_base="https://api.edenai.run/v3") == spec
+def test_novita_provider_aliases_and_base_detection() -> None:
+ spec = find_by_name("novita")
+
+ assert spec is not None
+ assert spec.display_name == "Novita AI"
+ assert spec.env_key == "NOVITA_API_KEY"
+ assert spec.backend == "openai_compat"
+ assert spec.mode == "gateway"
+ assert spec.default_api_base == "https://api.novita.ai/openai"
+ assert find_by_name("novita-ai") == spec
+ assert find_by_name("novita_ai") == spec
+ assert find_gateway(api_base="https://api.novita.ai/openai") == spec
+
+
def test_openai_codex_is_not_detected_from_api_base() -> None:
assert find_gateway(api_base="https://codex.example.com/v1") is None