Self-hosted AI workspace.
Python
feat(providers): add NVIDIA AI provider endpoint support (#3456)
Maruf Hasanda46f1177970
diff --git a/routes/model_routes.py b/routes/model_routes.pyindex 864035884..b88fa3ef1 100644--- a/routes/model_routes.py+++ b/routes/model_routes.py@@ -283,6 +283,7 @@ _HOST_TO_CURATED = (("fireworks.ai", "fireworks"),("googleapis.com", "google"),("x.ai", "xai"),+ ("nvidia.com", "nvidia"),("openrouter.ai", "openrouter"),("ollama.com", "ollama"),)@@ -477,10 +478,17 @@ _NON_CHAT_PREFIXES = ("dall-e", "tts-", "whisper", "text-embedding", "embedding","davinci", "babbage", "moderation", "omni-moderation","sora", "gpt-image", "chatgpt-image",+ # embedding / retrieval / non-chat models (common across providers)+ "snowflake/arctic-embed", "nvidia/nv-embed", "embed",)_NON_CHAT_CONTAINS = ("-realtime", "-transcribe", "-tts", "-codex",- "codex-",+ "codex-", "content-safety", "-safety", "-reward", "nvclip",+ "kosmos", "fuyu", "deplot", "vila", "neva",+ "gliner", "riva", "-parse", "-embedqa", "-nemoretriever",+ "topic-control", "calibration",+ "ai-synthetic-video", "cosmos-reason2",+ "bge", "llama-guard",)_NON_CHAT_EXACT_PREFIXES = ("gpt-audio", # gpt-audio, gpt-audio-mini etc. (not gpt-4o-audio-preview which is chat)@@ -731,7 +739,7 @@ def _probe_endpoint(base_url: str, api_key: str = None, timeout: int = 5) -> Lisfor _e in _PROVIDER_CURATED.get(_ck, []):if _e not in set(models) and not any(m.startswith(_e) for m in models):models.append(_e)- return models+ return [m for m in models if _is_chat_model(m)]except httpx.HTTPStatusError as e:if api_key:status = e.response.status_code if e.response is not None else "unknown"@@ -755,7 +763,7 @@ def _probe_endpoint(base_url: str, api_key: str = None, timeout: int = 5) -> Lisdata = r.json()models = [m.get("name") or m.get("model") for m in (data.get("models") or []) if m.get("name") or m.get("model")]if models:- return models+ return [m for m in models if _is_chat_model(m)]except Exception as e:logger.debug(f"Ollama /api/tags probe failed for {base}: {e}")# Fall back to curated list if the provider has a URL-based match (e.g. z.ai has no /models endpoint)diff --git a/src/llm_core.py b/src/llm_core.pyindex 07b149ebe..b012638fa 100644--- a/src/llm_core.py+++ b/src/llm_core.py@@ -444,6 +444,8 @@ def _detect_provider(url: str) -> str:return "openrouter"if _host_match(url, "groq.com"):return "groq"+ if _host_match(url, "nvidia.com"):+ return "nvidia"from src.chatgpt_subscription import is_chatgpt_subscription_baseif is_chatgpt_subscription_base(url):return "chatgpt-subscription"@@ -489,6 +491,7 @@ def _provider_label(url: str) -> str:if is_copilot_base(url): return "GitHub Copilot"if _host_match(url, "mistral.ai"): return "Mistral"if _host_match(url, "deepseek.com"): return "DeepSeek"+ if _host_match(url, "nvidia.com"): return "NVIDIA"if _host_match(url, "googleapis.com"): return "Google"if _host_match(url, "together.xyz", "together.ai"): return "Together"if _host_match(url, "fireworks.ai"): return "Fireworks"diff --git a/static/index.html b/static/index.htmlindex 4ca33c072..60a2764d9 100644--- a/static/index.html+++ b/static/index.html@@ -2095,6 +2095,7 @@<option value="https://opencode.ai/zen/v1" data-logo="opencode">OpenCode Zen</option><option value="https://opencode.ai/zen/go/v1" data-logo="opencode">OpenCode Go</option><option value="https://api.z.ai/api/coding/paas/v4" data-logo="zhipu">Z.AI Coding Plan</option>+ <option value="https://integrate.api.nvidia.com/v1" data-logo="nvidia">NVIDIA</option></select><!-- API key row stays in DOM, hidden until Key button isclicked. Mirrors the Local section pattern: most usersdiff --git a/static/js/providers.js b/static/js/providers.jsindex 1c9c5080a..f42afcd67 100644--- a/static/js/providers.js+++ b/static/js/providers.js@@ -118,6 +118,7 @@ const _ENDPOINT_LABELS = [[/(^|\.)together\.(ai|xyz)$/i, "Together"],[/(^|\.)fireworks\.ai$/i, "Fireworks"],[/(^|\.)perplexity\.ai$/i, "Perplexity"],+ [/(^|\.)nvidia\.com$/i, "NVIDIA"],[/(^|\.)x\.ai$/i, "xAI"],];diff --git a/static/js/slashCommands.js b/static/js/slashCommands.jsindex 28b1a08e4..6a32cb89e 100644--- a/static/js/slashCommands.js+++ b/static/js/slashCommands.js@@ -43,6 +43,7 @@ const PROVIDER_PATTERNS = [{ re: /^gsk_/, name: 'Groq', url: 'https://api.groq.com/openai/v1' },{ re: /^AIza/, name: 'Gemini', url: 'https://generativelanguage.googleapis.com/v1beta/openai' },{ re: /^xai-/, name: 'xAI', url: 'https://api.x.ai/v1' },+ { re: /^nvapi-/, name: 'NVIDIA', url: 'https://integrate.api.nvidia.com/v1' },];const SETUP_PROVIDER_URLS = {deepseek: { name: 'DeepSeek', url: 'https://api.deepseek.com/v1' },@@ -56,8 +57,9 @@ const SETUP_PROVIDER_URLS = {google: { name: 'Gemini', url: 'https://generativelanguage.googleapis.com/v1beta/openai' },'opencode-zen': { name: 'OpenCode Zen', url: 'https://opencode.ai/zen/v1' },'opencode-go': { name: 'OpenCode Go', url: 'https://opencode.ai/zen/go/v1' },+ nvidia: { name: 'NVIDIA', url: 'https://integrate.api.nvidia.com/v1' },};-const SETUP_PROVIDER_NAMES = ['deepseek', 'openai', 'openrouter', 'ollama', 'xai', 'anthropic', 'groq', 'gemini', 'opencode-zen', 'opencode-go'];+const SETUP_PROVIDER_NAMES = ['deepseek', 'openai', 'openrouter', 'ollama', 'xai', 'anthropic', 'groq', 'gemini', 'opencode-zen', 'opencode-go', 'nvidia'];const SETUP_DEVICE_AUTH_PROVIDERS = [{ key: 'copilot', name: 'GitHub Copilot', aliases: ['github'], command: '/setup copilot' },{ key: 'chatgpt-subscription', name: 'ChatGPT Subscription', aliases: ['chatgptsubscription', 'chatgpt-sub', 'codex'], command: '/setup chatgpt-subscription' },@@ -97,6 +99,7 @@ function _setupProviderFromInput(input) {google: 'gemini',xai: 'xai',grok: 'xai',+ nvidia: 'nvidia',};return SETUP_PROVIDER_URLS[aliases[raw] || raw] || null;}@@ -124,6 +127,7 @@ function _extractSetupProviderCredential(input) {['groq', 'groq'],['google', 'gemini'], ['gemini', 'gemini'],['x ai', 'xai'], ['xai', 'xai'], ['grok', 'xai'],+ ['nvidia', 'nvidia'],];for (const [alias, key] of providerAliases) {const re = new RegExp('(^|\\s|[,;:])(' + alias.replace(/\s+/g, '\\s+') + ')(?=$|\\s|[,;:])', 'i');diff --git a/tests/test_model_routes.py b/tests/test_model_routes.pyindex 02f2ea071..3b23123ef 100644--- a/tests/test_model_routes.py+++ b/tests/test_model_routes.py@@ -347,6 +347,8 @@ class TestIsChatModel:"gpt-4o", "gpt-4o-mini", "claude-sonnet-4", "llama-3.3-70b","deepseek-chat", "gemini-2.0-flash", "o3","llama-4-scout-17b-16e-instruct",+ "gemma-2b-it", "google/gemma-2b-it",+ "bigcode/starcoder2-15b-instruct",])def test_chat_models(self, model_id):assert _is_chat_model(model_id) is Truediff --git a/tests/test_provider_classification.py b/tests/test_provider_classification.pyindex 43fd0a0df..48d413dcb 100644--- a/tests/test_provider_classification.py+++ b/tests/test_provider_classification.py@@ -40,6 +40,7 @@ class TestDetectProvider:("https://anthropic.com/v1", "anthropic"),("https://openrouter.ai/api/v1", "openrouter"),("https://api.groq.com/openai/v1", "groq"),+ ("https://integrate.api.nvidia.com/v1", "nvidia"),("http://localhost:11434/api", "ollama"),("https://ollama.com", "ollama"),# xAI, DeepSeek and Gemini's OpenAI-compatible surface are NOT@@ -84,6 +85,7 @@ class TestProviderLabel:("https://api.openai.com/v1", "OpenAI"),("https://openrouter.ai/api/v1", "OpenRouter"),("https://api.groq.com/openai/v1", "Groq"),+ ("https://integrate.api.nvidia.com/v1", "NVIDIA"),("https://api.mistral.ai/v1", "Mistral"),("https://api.deepseek.com", "DeepSeek"),("https://generativelanguage.googleapis.com/v1beta/openai", "Google"),diff --git a/tests/test_provider_endpoints.py b/tests/test_provider_endpoints.pyindex 6c271557e..d4b56dcb3 100644--- a/tests/test_provider_endpoints.py+++ b/tests/test_provider_endpoints.py@@ -50,6 +50,9 @@ PROVIDER_CASES = [("groq", "https://api.groq.com/openai/v1","https://api.groq.com/openai/v1/chat/completions","https://api.groq.com/openai/v1/models"),+ ("nvidia", "https://integrate.api.nvidia.com/v1",+ "https://integrate.api.nvidia.com/v1/chat/completions",+ "https://integrate.api.nvidia.com/v1/models"),("xai", "https://api.x.ai/v1","https://api.x.ai/v1/chat/completions","https://api.x.ai/v1/models"),@@ -112,6 +115,7 @@ def test_headers_anthropic_without_key_still_sends_version():"https://api.x.ai/v1","https://api.deepseek.com","https://api.groq.com/openai/v1",+ "https://integrate.api.nvidia.com/v1","https://generativelanguage.googleapis.com/v1beta/openai",])def test_headers_openai_style_use_bearer(base):