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

Setup guide - From LM Studio and Codex CLI docs

Use LM Studio in Codex CLI

Codex ships a built-in lmstudio provider for OSS mode and talks to LM Studio through its OpenAI-compatible POST /v1/responses endpoint. Run codex --oss, optionally with -m to choose a model, and set oss_provider = "lmstudio" to make it the default.

Last verified 4 steps4 official sources

Steps

  1. Step 1.

    Start LM Studio's local server (default port 1234).

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

    Run Codex as you normally would, but add the --oss flag to point it at LM Studio. By default Codex downloads and uses openai/gpt-oss-20b.

    Terminal
    codex --oss
  3. Step 3.

    Use any other model you have available in LM Studio.

    Terminal
    codex --oss -m ibm/granite-4-micro
  4. Step 4.

    Codex docs: choose the local provider for a single run with --local-provider, or set oss_provider as the default in config.toml.

    Terminal
    # Default local provider used with `--oss`
    oss_provider = "ollama" # or "lmstudio"

Caveats

  • Codex docs: 'If neither is set, the interactive CLI prompts you to choose; codex exec exits with an error.' Set oss_provider = "lmstudio" or pass --local-provider for non-interactive runs.
  • lmstudio is a reserved built-in provider id, so you cannot redefine it under [model_providers].
  • LM Studio recommends more than ~25k context length for Codex.
  • developers.openai.com/codex/config-advanced and config-reference now redirect to learn.chatgpt.com/docs/config-file/...

FAQ

How do I use LM Studio in Codex CLI?

Codex ships a built-in lmstudio provider for OSS mode and talks to LM Studio through its OpenAI-compatible POST /v1/responses endpoint. Run codex --oss, optionally with -m to choose a model, and set oss_provider = "lmstudio" to make it the default.

Which LM Studio model ids work in Codex CLI?

The official docs read for this guide list openai/gpt-oss-20b and ibm/granite-4-micro. Requests go to http://localhost:1234.

Is this an official LM Studio and Codex CLI setup?

The steps draw on both LM Studio's and Codex CLI's docs. It was last checked against 4 official pages on October 17, 2026.

Sources

Last verified against 4 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.