Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(ui): clarify openai_endpoint API key is optional for local servers (#3908)

amlyczz3f57d38abe82
diff --git a/src/local_deep_research/defaults/default_settings.json b/src/local_deep_research/defaults/default_settings.json
index 9d0a5a69f2..201ef261f3 100644
--- a/src/local_deep_research/defaults/default_settings.json
+++ b/src/local_deep_research/defaults/default_settings.json
@@ -643,7 +643,7 @@
"name": "OpenAI Endpoint API Key",
"options": null,
"step": null,
- "type": "SEARCH",
+ "type": "LLM",
"ui_element": "password",
"value": "",
"visible": true
diff --git a/src/local_deep_research/web/templates/pages/research.html b/src/local_deep_research/web/templates/pages/research.html
index 2bb4b2f8bc..1ec1381746 100644
--- a/src/local_deep_research/web/templates/pages/research.html
+++ b/src/local_deep_research/web/templates/pages/research.html
@@ -169,7 +169,7 @@
<div class="ldr-form-group ldr-half" id="openai_endpoint_api_key_container" style="display: none;">
<label for="openai_endpoint_api_key">Endpoint API Key (Optional)</label>
<input type="password" id="openai_endpoint_api_key" name="openai_endpoint_api_key" class="ldr-form-control"
- placeholder="API key (if required)" autocomplete="off">
+ placeholder="Optional, leave empty if not required" autocomplete="off">
<span class="ldr-input-help">Leave blank for local servers (llama.cpp, vLLM, LM Studio). Required only for hosted services (OpenRouter, Groq, Together, etc.).</span>
</div>
diff --git a/tests/settings/golden_master_settings.json b/tests/settings/golden_master_settings.json
index 174edc8b30..13e6e8a1ed 100644
--- a/tests/settings/golden_master_settings.json
+++ b/tests/settings/golden_master_settings.json
@@ -1106,14 +1106,14 @@
},
"llm.openai_endpoint.api_key": {
"category": "llm_general",
- "description": "API key for your custom OpenAI-compatible endpoint. For cloud services (OpenRouter, Groq), use your actual API key. For local servers (llama.cpp, vLLM), use any non-empty value like 'not-needed'.",
+ "description": "API key for your custom OpenAI-compatible endpoint. For cloud services (OpenRouter, Groq), use your actual API key. For local servers (llama.cpp, vLLM), you can leave this blank — LDR will substitute a placeholder automatically.",
"editable": true,
"max_value": null,
"min_value": null,
"name": "OpenAI Endpoint API Key",
"options": null,
"step": null,
- "type": "SEARCH",
+ "type": "LLM",
"ui_element": "password",
"value": "",
"visible": true
diff --git a/tests/test_openai_endpoint_api_key.py b/tests/test_openai_endpoint_api_key.py
new file mode 100644
index 0000000000..8ec64d6841
--- /dev/null
+++ b/tests/test_openai_endpoint_api_key.py
@@ -0,0 +1,121 @@
+"""
+Tests for the openai_endpoint API key UX fix (issue #3875).
+
+Validates that the openai_endpoint API key setting has the correct type
+and a user-friendly description that makes clear it can be optional.
+"""
+
+import json
+import os
+from pathlib import Path
+
+import pytest
+
+from local_deep_research.settings.manager import SettingsManager
+
+DEFAULTS_PATH = (
+ Path(__file__).parent.parent
+ / "src"
+ / "local_deep_research"
+ / "defaults"
+ / "default_settings.json"
+)
+
+
[email protected](autouse=True)
+def clean_env():
+ """Save/clear/restore LDR_* env vars to prevent pollution across tests."""
+ original_env = {k: v for k, v in os.environ.items() if k.startswith("LDR_")}
+ for key in list(os.environ.keys()):
+ if key.startswith("LDR_"):
+ os.environ.pop(key, None)
+ yield
+ for key in list(os.environ.keys()):
+ if key.startswith("LDR_"):
+ os.environ.pop(key, None)
+ for key, value in original_env.items():
+ os.environ[key] = value
+
+
[email protected](scope="module")
+def defaults():
+ """Load all default settings."""
+ manager = SettingsManager(db_session=None)
+ return manager.default_settings
+
+
[email protected](scope="module")
+def raw_json():
+ """Load the raw default_settings.json file."""
+ with open(DEFAULTS_PATH, encoding="utf-8") as f:
+ return json.load(f)
+
+
+class TestOpenAIEndpointApiKeyType:
+ """Test that openai_endpoint API key has correct type 'LLM'."""
+
+ def test_openai_endpoint_api_key_type_is_llm(self, defaults):
+ """The openai_endpoint api_key should have type 'LLM', not 'SEARCH'."""
+ setting = defaults["llm.openai_endpoint.api_key"]
+ assert setting["type"] == "LLM", (
+ f"Expected type 'LLM' but got '{setting['type']}'. "
+ f"API keys for LLM providers should be categorized as 'LLM'."
+ )
+
+
+class TestOpenAIEndpointApiKeyDescription:
+ """Test that the description clarifies the key is optional for local servers."""
+
+ def test_description_mentions_optional(self, defaults):
+ """The description should mention that the key is optional / can be left empty."""
+ setting = defaults["llm.openai_endpoint.api_key"]
+ description = setting["description"].lower()
+ assert (
+ "optional" in description
+ or "leave empty" in description
+ or "leave this blank" in description
+ or "leave blank" in description
+ ), (
+ f"Description should mention 'optional', 'leave empty', or 'leave (this) blank'. "
+ f"Got: {setting['description']!r}"
+ )
+
+ def test_description_no_longer_says_not_needed(self, defaults):
+ """The description should NOT say 'use any non-empty value like not-needed'."""
+ setting = defaults["llm.openai_endpoint.api_key"]
+ description = setting["description"].lower()
+ assert "not-needed" not in description, (
+ f"Description should not suggest using 'not-needed' as a placeholder. "
+ f"Got: {setting['description']!r}"
+ )
+
+
+class TestAllLlmApiKeyTypes:
+ """Test that llm.*.api_key settings used for optional endpoints have type 'LLM'."""
+
+ def test_local_llm_api_keys_have_type_llm(self, defaults):
+ """API keys for local/optional LLM providers must be categorized as 'LLM'.
+
+ Cloud-only providers (google, openrouter, ionos, anthropic, openai,
+ deepseek, xai) legitimately use SEARCH type since a key is always
+ required. But providers that support local servers (openai_endpoint,
+ ollama, llamacpp, lmstudio) should use LLM type.
+ """
+ optional_providers = {
+ "llm.openai_endpoint.api_key",
+ "llm.ollama.api_key",
+ "llm.llamacpp.api_key",
+ "llm.lmstudio.api_key",
+ }
+ errors = []
+ for key, setting in defaults.items():
+ if key in optional_providers:
+ if setting["type"] != "LLM":
+ errors.append(
+ f"{key}: expected type 'LLM', got '{setting['type']}'"
+ )
+
+ assert not errors, (
+ f"{len(errors)} optional-provider api_key setting(s) have wrong type:\n"
+ + "\n".join(f" {e}" for e in errors)
+ )