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.
- How to Build Agents That Run for Hours: Anthropic's Planner, Generator and Evaluator HarnessAnthropic Applied AI's Ash Prabaker and Andrew Wilson trace how Claude went from 20-minute runs to multi-hour builds, and the GAN-style planner, generator and evaluator harness behind their one-shot apps.
- Why One Agent Isn't Enough: Anthropic on Flows, UltraCode and Running 1,000 AgentsCJ Avilla and Harrison Stall of Anthropic on multi-agent topologies: lessons from Unix, OS/360 and Linux, Dynamic Workflows in Managed Agents, and when to use Flows vs UltraCode.
- The Claude Certified Architect Exam as a Field Guide to Agentic EngineeringUC Berkeley's Frank Coyle reads Anthropic's Claude Certified Architect exam as a map of production agent design: five domains, six scenarios and the anti-patterns each one tests.
- Claude Tag Lands 65% of Anthropic's Product PRs: Takeaways From Cat Wu and Thariq ShihiparCat Wu and Thariq Shihipar talk with Simon Willison about Fable, Claude Tag landing 65% of product engineering PRs, why rewrites are good now, and Anthropic's culture.
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 November 8, 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.