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 Training Setting Re-Enabled? Two Switches to CheckDevelopers report Codex model training turning itself back on. What OpenAI documents, the second "Include environments" switch most people miss, and a five-minute check.
- OpenAI Pando: The Git Backend Built for Codex-Scale PushesOpenAI built Pando, a Git-compatible backend, after Codex flooded its monorepo with pushes. What it changed, the trade-offs, and what it means for your agent fleet.
- 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.
- Android Studio Now Runs Claude and Codex: ACP Setup GuideAndroid Studio Rabbit 2 hosts 40+ ACP coding agents, Claude and Codex included, and Android CLI ships as a Claude Code and Codex plugin. Setup and caveats.
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.