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
- Step 1.
Start LM Studio's local server (default port 1234).
Terminallms server start --port 1234 - 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.
Terminalcodex --oss - Step 3.
Use any other model you have available in LM Studio.
Terminalcodex --oss -m ibm/granite-4-micro - 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/...
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.
- Droid vs Codex (2026): Factory vs OpenAI for Terminal Coding AgentsFactory Droid vs OpenAI Codex compared on models, pricing, headless CI, multi-agent work, extensibility and openness, with a clear recommendation for each kind of developer.
- Codex CLI 0.171: codex exec --remote, Workspace On by DefaultCodex CLI 0.171.0 adds codex exec --remote to run headless sessions on an existing app server, turns on the TUI workspace by default and picks GPT-6.2 Sol.
- GPT-6.2 Astra and Sol: Pricing, Benchmarks and What to SwitchGPT-6.2 Astra costs $8/$40 per MTok (20% under GPT-6 Astra), Sol stays $2/$10. Vendor-reported benchmarks, cache rates, Codex setup and who should switch.
- Codex CLI 0.169: codex exec Trust, Side Chats and Model ProvidersCodex CLI 0.169.0 keeps project config and MCP servers off in untrusted directories under codex exec, adds --trust, side-chat tabs and a model provider picker.
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 November 8, 2026.
Sources
Last verified against 4 official pages.
- lmstudio.aihttps://lmstudio.ai/docs/integrations/codex
- lmstudio.aihttps://lmstudio.ai/docs/developer/openai-compat
- learn.chatgpt.comhttps://learn.chatgpt.com/docs/config-file/config-advanced
- learn.chatgpt.comhttps://learn.chatgpt.com/docs/config-file/config-reference
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.