Skip to content

feat: add LM Studio provider (closes #57) - #89

Open
neerajdad123-byte wants to merge 5 commits into
cosmicstack-labs:mainfrom
neerajdad123-byte:main
Open

feat: add LM Studio provider (closes #57)#89
neerajdad123-byte wants to merge 5 commits into
cosmicstack-labs:mainfrom
neerajdad123-byte:main

Conversation

@neerajdad123-byte

Copy link
Copy Markdown

Adds LM Studio as a local LLM provider. LM Studio runs models locally on desktop and exposes an OpenAI-compatible API
at http://127.0.0.1:1234/v1. No API key required — just install LM Studio, load a model, and Mercury can use it.

What's included

  • Provider config: lmStudio added to type system, config interface, defaults, and isProviderConfigured (checks baseUrl
  • model, no API key needed)
  • Provider routing: Wired through existing OpenAICompatProvider — same pattern as ollamaCloud and ollamaLocal
  • Model catalog: Fetches available models from LM Studio's /v1/models endpoint, with empty preferred models list
    (models vary per user install)
  • Setup wizard: New promptLmStudioModelSelection function that auto-discovers models from a running LM Studio
    instance, with manual model name fallback
  • CLI integration: Appears in provider options list during setup, selectable as default provider
  • Tests: 2 tests for LM Studio model catalog behavior
  • Env vars: LM_STUDIO_BASE_URL, LM_STUDIO_MODEL, LM_STUDIO_ENABLED in .env.example

How to test

  1. Install LM Studio (https://lmstudio.ai/) and download a model
  2. Start the local server in LM Studio (Developer tab → Start Server)
  3. Run mercury doctor and select LM Studio as a provider
  4. Mercury will auto-discover available models

Verification

  • Typecheck: PASS (0 errors)
  • Tests: PASS (12/12 provider-models tests, 2 new)

Neeraj added 5 commits July 6, 2026 12:05
Adds lmStudio to ProviderName union type, MercuryConfig providers interface, default config with baseUrl http://127.0.0.1:1234/v1, and isProviderConfigured (no API key required — checks baseUrl + model like ollamaLocal).
LM Studio exposes an OpenAI-compatible API at localhost:1234/v1. Route it through the existing OpenAICompatProvider with useChatApi: true, same as ollamaCloud and ollamaLocal.
Adds LM_STUDIO_PREFERRED_MODELS empty list (LM Studio models vary by user install), fetchLmStudioModels function targeting /v1/models endpoint, routing in fetchProviderModelCatalog, and 2 tests for lmStudio model catalog.
Adds lmStudio to PROVIDER_OPTIONS list, validates no API key needed (returns null), adds promptLmStudioModelSelection function (cloned from ollamaLocal pattern), and wires it into the setup wizard flow.
Adds LM_STUDIO_BASE_URL (default http://127.0.0.1:1234/v1), LM_STUDIO_MODEL, and LM_STUDIO_ENABLED env vars.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant