Setup guide - Documented by OpenCode
Use LM Studio in OpenCode
OpenCode has built-in local discovery for LM Studio. Its default LM Studio endpoint is http://127.0.0.1:1234/v1, and it discovers language models from /api/v1/models. Override settings.baseURL in opencode.jsonc when LM Studio runs on another host.
Last verified 3 steps2 official sources
Steps
- Step 1.
Make sure the LM Studio server is running (LM Studio docs).
Terminallms server start --port 1234 - Step 2.
OpenCode discovers LM Studio language models from /api/v1/models at the default endpoint
http://127.0.0.1:1234/v1. Run /models to select one of its models.Snippet/models - Step 3.
To use LM Studio on another host, override settings.baseURL in opencode.jsonc (from the OpenCode Runtimes section, trimmed to the lmstudio entry).
JSON{ "$schema": "https://opencode.ai/config.json", "providers": { "lmstudio": { "settings": { "baseURL": "http://gpu-host:1234/v1" }, }, }, }
Caveats
- Step 1 comes from LM Studio's docs (server start), combined with OpenCode's documented LM Studio discovery.
- The OpenCode Runtimes example also includes a vllm entry. It was trimmed here to the lmstudio entry; the remaining keys and values are verbatim.
- The OpenCode providers page names no specific LM Studio model id. Models come from what LM Studio serves.
- The earlier OpenCode LM Studio section (an @ai-sdk/openai-compatible provider with a google/gemma-3n-e4b example) is no longer on the providers page.
More setup guides
Same tool, other providers
Related reading
- LM Studio Bionic: A Local-First AI Agent for Open ModelsLM Studio launches Bionic, a standalone agent harness for open models with local inference, voice input, and zero data retention cloud options.
- Ollama vs LM Studio vs vLLM vs llama.cpp: Picking a Local Runtime for Coding AgentsOllama vs LM Studio vs vLLM vs llama.cpp for coding agents: what each local runtime is for, where they overlap, and which to pick for your setup.
- OpenCode Background Subagents: What v2.3.0 ChangesOpenCode v2.3.0 makes every subagent run in the background and defaults transcripts to low verbosity. What changed, what to set, and where it bites.
- OpenCode Cache Warming: What v2.2.7 Changed and When to Turn It OnOpenCode v2.2.7 makes cache warming time its pings from the model cache TTL. The config, the cost of idle pings, and when warming is a bad trade.
- T3 Code: Open-Source GUI for Claude Code and CodexT3 Code is a free, MIT-licensed desktop, web and mobile app that drives Claude Code, Codex, Cursor, OpenCode and more. What it is, how remote access works, and what to check first.
- OpenCode Hacked: What the Console Breach Means for Your API KeysOpenCode disclosed a breach of its Console that may have exposed provider keys. Who is affected, what to rotate today, and why hosted key gateways are the real risk.
FAQ
How do I use LM Studio in OpenCode?
OpenCode has built-in local discovery for LM Studio. Its default LM Studio endpoint is http://127.0.0.1:1234/v1, and it discovers language models from /api/v1/models. Override settings.baseURL in opencode.jsonc when LM Studio runs on another host.
What base URL does OpenCode use for LM Studio?
Point OpenCode at http://127.0.0.1:1234/v1.
Is this an official LM Studio and OpenCode setup?
OpenCode documents this setup in its own docs. It was last checked against 2 official pages on November 8, 2026.
Sources
Last verified against 2 official pages.
- opencode.aihttps://opencode.ai/docs/providers/
- lmstudio.aihttps://lmstudio.ai/docs/integrations/codex
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.