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(lmstudio): use URL as-is instead of appending /v1

LearningCircuitd1154fe23cb4
diff --git a/src/local_deep_research/config/llm_config.py b/src/local_deep_research/config/llm_config.py
index 2d992b401d..c6ec8d200f 100644
--- a/src/local_deep_research/config/llm_config.py
+++ b/src/local_deep_research/config/llm_config.py
@@ -160,12 +160,14 @@ def is_lmstudio_available(settings_snapshot=None):
try:
lmstudio_url = get_setting_from_snapshot(
"llm.lmstudio.url",
- "http://localhost:1234",
+ "http://localhost:1234/v1",
settings_snapshot=settings_snapshot,
)
+ # Use URL as-is (default already includes /v1)
+ base_url = normalize_url(lmstudio_url)
# LM Studio typically uses OpenAI-compatible endpoints
response = safe_get(
- f"{lmstudio_url}/v1/models",
+ f"{base_url}/models",
timeout=1.0,
allow_localhost=True,
allow_private_ips=True,
@@ -834,14 +836,16 @@ def get_llm(
# LM Studio supports OpenAI API format, so we can use ChatOpenAI directly
lmstudio_url = get_setting_from_snapshot(
"llm.lmstudio.url",
- "http://localhost:1234",
+ "http://localhost:1234/v1",
settings_snapshot=settings_snapshot,
)
+ # Use URL as-is (default already includes /v1)
+ base_url = normalize_url(lmstudio_url)
llm = ChatOpenAI(
model=model_name,
api_key="lm-studio", # LM Studio doesn't require a real API key # pragma: allowlist secret
- base_url=f"{lmstudio_url}/v1", # Use the configured URL with /v1 endpoint
+ base_url=base_url,
temperature=temperature,
max_tokens=max_tokens, # Use calculated max_tokens based on context size
)
diff --git a/src/local_deep_research/defaults/default_settings.json b/src/local_deep_research/defaults/default_settings.json
index a0e61ed239..36aae73a8f 100644
--- a/src/local_deep_research/defaults/default_settings.json
+++ b/src/local_deep_research/defaults/default_settings.json
@@ -309,7 +309,7 @@
},
"llm.lmstudio.url": {
"category": null,
- "description": "HTTP endpoint URL where LM Studio is running locally. The '/v1' endpoint is automatically appended for OpenAI-compatible API format.",
+ "description": "HTTP endpoint URL where LM Studio is running locally. Include the full path (e.g., http://localhost:1234/v1 for OpenAI-compatible API format).",
"editable": true,
"max_value": null,
"min_value": null,
@@ -318,7 +318,7 @@
"step": null,
"type": "LLM",
"ui_element": "text",
- "value": "http://localhost:1234",
+ "value": "http://localhost:1234/v1",
"visible": true
},
"llm.max_tokens": {
diff --git a/src/local_deep_research/llm/providers/implementations/lmstudio.py b/src/local_deep_research/llm/providers/implementations/lmstudio.py
index a495353024..0cc94a1a23 100644
--- a/src/local_deep_research/llm/providers/implementations/lmstudio.py
+++ b/src/local_deep_research/llm/providers/implementations/lmstudio.py
@@ -2,6 +2,7 @@
from loguru import logger
+from ....utilities.url_utils import normalize_url
from ...llm_registry import register_llm
from ..openai_base import OpenAICompatibleProvider
@@ -33,15 +34,15 @@ class LMStudioProvider(OpenAICompatibleProvider):
settings_snapshot = kwargs.get("settings_snapshot")
- # Get LM Studio URL from settings
+ # Get LM Studio URL from settings (default includes /v1 for backward compatibility)
lmstudio_url = get_setting_from_snapshot(
"llm.lmstudio.url",
- "http://localhost:1234",
+ cls.default_base_url,
settings_snapshot=settings_snapshot,
)
- # LM Studio uses /v1 endpoint
- kwargs["base_url"] = f"{lmstudio_url}/v1"
+ # Use URL as-is (user should provide complete URL including /v1 if needed)
+ kwargs["base_url"] = normalize_url(lmstudio_url)
# LM Studio doesn't require a real API key, just use a clearly fake placeholder
kwargs["api_key"] = "not-required" # pragma: allowlist secret
@@ -58,12 +59,14 @@ class LMStudioProvider(OpenAICompatibleProvider):
lmstudio_url = get_setting_from_snapshot(
"llm.lmstudio.url",
- "http://localhost:1234",
+ cls.default_base_url,
settings_snapshot=settings_snapshot,
)
+ # Use URL as-is (default already includes /v1)
+ base_url = normalize_url(lmstudio_url)
# LM Studio typically uses OpenAI-compatible endpoints
response = safe_get(
- f"{lmstudio_url}/v1/models",
+ f"{base_url}/models",
timeout=1.0,
allow_localhost=True,
allow_private_ips=True,