Setup guide - Documented by LM Studio
Use LM Studio in Claude Code
LM Studio documents a Claude Code integration through its Anthropic-compatible POST /v1/messages endpoint. You set ANTHROPIC_BASE_URL to the local LM Studio server, then run claude with a local model id.
Last verified 4 steps3 official sources
Steps
- Step 1.
Start LM Studio's local server (default port 1234), from the app or from the terminal with lms.
Terminallms server start --port 1234 - Step 2.
Set these environment variables so the claude CLI points to your local LM Studio.
Terminalexport ANTHROPIC_BASE_URL=http://localhost:1234 export ANTHROPIC_AUTH_TOKEN=lmstudio export CLAUDE_CODE_ATTRIBUTION_HEADER=0 - Step 3.
Run Claude Code against a local model.
Terminalclaude --model openai/gpt-oss-20b - Step 4.
If Require Authentication is enabled in LM Studio, create an API token and set it as the auth token. LM Studio accepts both x-api-key and Authorization: Bearer <token>.
Terminalexport LM_API_TOKEN=<LMSTUDIO_TOKEN> export ANTHROPIC_AUTH_TOKEN=$LM_API_TOKEN
Caveats
- Only LM Studio documents this setup. Claude Code's own docs were not checked for an LM Studio mention, so officialBy is provider.
- LM Studio advises: 'Use a model (and server/model settings) with more than ~25k context length. Tools like Claude Code can consume a lot of context.'
- ibm/granite-4-micro is the model used in LM Studio's /v1/messages cURL examples, not on the Claude Code page itself.
- The model must be downloaded in LM Studio. Model ids are whatever identifiers your LM Studio server exposes.
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.
- Claude Code Idle Compaction: What It Does and How to Turn It OffClaude Code 2.1.299 compacts sessions over 200K tokens after about 54 idle minutes. How the cache math works, the setting to turn it off, and when to keep it.
- Claude Code Desktop SneakPeek Flaw: Fixed Version and What To DoSneakPeek (CVSS 8.7) let a poisoned HTML file read SSH keys and cloud credentials via the Claude Code Desktop preview pane. Fixed in Claude Desktop 1.30096.1.
- Reverse Engineer Anything (REA): What the MCP Server Does and Where the Line IsREA (Reverse Engineer Anything) is an MIT-licensed MCP server that lets Claude Code, Codex or Cursor inspect binaries, Electron apps and APKs. How to try it.
- Claude Code Projects: Coordinator, Threads, and LimitsClaude Code Projects is open to waitlisted Pro and Max users. How the coordinator and cloud threads work, what they cost in plan limits and where it breaks.
FAQ
How do I use LM Studio in Claude Code?
LM Studio documents a Claude Code integration through its Anthropic-compatible POST /v1/messages endpoint. You set ANTHROPIC_BASE_URL to the local LM Studio server, then run claude with a local model id.
Which LM Studio model ids work in Claude Code?
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 Claude Code setup?
LM Studio 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.