LM Studio serves an Anthropic-compatible Messages API alongside its OpenAI-compatible endpoints, which means tools written for Claude can run against your local model with a base-URL change. Claude Code is the headline case: point it at LM Studio and it codes against a model on your own machine.
Set the base URL and start Claude Code
Start the LM Studio server, then set the environment variables before launching Claude Code: ANTHROPIC_BASE_URL=http://localhost:1234 and ANTHROPIC_AUTH_TOKEN=<your-token> — the token is the one from your LM Studio server authentication settings, or any placeholder if authentication is off. Then run claude in the terminal. Claude Code now sends its Messages API calls to LM Studio instead of Anthropic’s servers.
export ANTHROPIC_BASE_URL=http://localhost:1234
export ANTHROPIC_AUTH_TOKEN=<your-token>
claude # now running on your local model
A local model is not Claude: expect weaker tool use and reasoning than the hosted model, and some Claude Code features may behave differently. The LM Studio server also offers the same Messages endpoint to any other Anthropic-compatible client — the base URL is the only change.
Try it: four checks
| Check | What you should see | If you do not see it |
|---|---|---|
| Server running | LM Studio server is up on port 1234 | Start it in the Developer tab or with lms |
| Variables set | ANTHROPIC_BASE_URL points at localhost:1234 | Export them in the same terminal |
| Claude starts | claude opens without a connection error | Check the token if auth is on |
| Local model answers | Replies come from your local model | Ask it something only your model would say |
Expected result. We checked the LM Studio documentation, which describes the Anthropic-compatible Messages API and the ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN setup for Claude Code. We did not run Claude Code on this machine.
Limits
This guide covers pointing Claude Code at LM Studio only. A local model will not match hosted Claude’s tool use or reasoning. We did not test the setup ourselves.
