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.
- Codex CLI 0.163: Instant Steering Is Now the DefaultCodex CLI 0.163.0 makes mid-response steering the default and adds searchable /config and a leader key. What changed and what to check before upgrading.
- Codex 'gpt-5.5 Model Is Not Supported' Error: The FixCodex says gpt-5.5 is not supported with a ChatGPT account because OpenAI retired it from ChatGPT sign-in on October 14. The fix and what still works.
- Agent Harness Lessons From a 500B-Token Decompile: Give Agents a PASS/FAIL OracleAgent harness lessons from a 500B+ token decompile: a byte-matching PASS/FAIL oracle beat the reviewer agent. How agents cheated it and what to copy.
- Codex CLI Background Daemon: How to Turn It OffCodex CLI starts a persistent, self-updating background daemon since 0.157.0. What it does, why it hit Hacker News and the reported workaround to turn it off.
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.
- 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.