Skip to main content
Watch: I Built an AI App Without Leaving Databricks

Setup guide - Documented by OpenCode

Use LM Studio in OpenCode

The OpenCode providers docs include an LM Studio section. It registers LM Studio as an @ai-sdk/openai-compatible provider in opencode.json, pointed at http://127.0.0.1:1234/v1.

Last verified 3 steps3 official sources

Steps

  1. Step 1.

    Add the LM Studio provider to the opencode.json file in your project directory (verbatim from the OpenCode LM Studio section).

    JSON
    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "lmstudio": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "LM Studio (local)",
          "options": {
            "baseURL": "http://127.0.0.1:1234/v1"
          },
          "models": {
            "google/gemma-3n-e4b": {
              "name": "Gemma 3n-e4b (local)"
            }
          }
        }
      }
    }
  2. Step 2.

    Make sure the LM Studio server is running (LM Studio docs).

    Terminal
    lms server start --port 1234
  3. Step 3.

    Optional: list the model identifiers LM Studio is serving, so you can use them as keys under models (LM Studio docs).

    Terminal
    curl http://localhost:1234/v1/models

Caveats

  • Steps 2 and 3 come from LM Studio's docs (server start and the /v1/models endpoint), combined with OpenCode's documented config.
  • Each model key must match an identifier LM Studio serves. google/gemma-3n-e4b is OpenCode's example.
  • Indentation in the JSON was normalized. The keys and values are verbatim.

FAQ

How do I use LM Studio in OpenCode?

The OpenCode providers docs include an LM Studio section. It registers LM Studio as an @ai-sdk/openai-compatible provider in opencode.json, pointed at http://127.0.0.1:1234/v1.

Which LM Studio model ids work in OpenCode?

The official docs read for this guide list google/gemma-3n-e4b. Requests go to 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 3 official pages on October 17, 2026.

Sources

Last verified against 3 official pages.

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.