How to use LM Studio models in Claude Code

LM Studio 0.4.1 introduces the /v1/messages endpoint, which is compatible with Anthropic. This means you can use your local models with Claude Code!

LM Studio 0.4.1 introduces the /v1/messages endpoint, which is compatible with Anthropic. This means you can use your local models with Claude Code !

 

LM Studio and Claude Code

First, install LM Studio from lmstudio.ai/download and set up a model.

Additionally, if you are running on a virtual machine or a remote server, install llmster:

curl -fsSL https://lmstudio.ai/install.sh | bash

1. Start the local LM Studio server.

Make sure LM Studio is running as the server. You can start it from the application or from the terminal:

lms server start --port 1234

2. Point Claude Code to LM Studio

Set these environment variables so that Claude's CLI can communicate with your local LM Studio server:

export ANTHROPIC_BASE_URL=http://localhost:1234 export ANTHROPIC_AUTH_TOKEN=lmstudio

3. Run Claude Code in the terminal.

From the terminal, use:

claude --model openai/gpt-oss-20b

That's it! Claude Code is now using your local model.

You should start with a context size of at least 25K tokens and gradually increase it for better results, as Claude Code can be quite context-heavy.

Alternatively: Configure Claude Code in VS Code

Open your VS Code settings:

"claudeCode.environmentVariables": [ { "name": "ANTHROPIC_BASE_URL", "value": "http://localhost:1234" }, { "name": "ANTHROPIC_AUTH_TOKEN", "value": "lmstudio" } ]

 

LM Studio 0.4.1 provides the /v1/messages endpoint, which is compatible with Anthropic. This means that any tool built for the Anthropic API can communicate with LM Studio simply by changing the base URL.

What is supported

  • Messaging API: Full support for the /v1/messages endpoint.
  • Stream: SSE events include message_start, content_block_delta, and message_stop.
  • Use the tool: Call the function to activate immediately.

Python example

If you're building your own tool, here's how to use the Anthropic Python SDK with LM Studio:

from anthropic import Anthropic client = Anthropic( base_url="http://localhost:1234", api_key="lmstudio", ) message = client.messages.create( max_tokens=1024, messages=[ { "role": "user", "content": "Hello from LM Studio", } ], model="ibm/granite-4-micro", ) print(message.content)

Troubleshooting

If you encounter any problems:

  1. Check if the server is running: Run `lms status` to verify that the LM Studio server is operational.
  2. Check the port: Ensure ANTHROPIC_BASE_URL is using the correct port (default: 1234)
  3. Check model compatibility: Some models perform better than others for agentic tasks.

You've just finished reading the article "How to use LM Studio models in Claude Code" edited by the TipsMake team. We hope this article has provided you with many useful tech tips and tricks. You can search for similar articles on tips and guides. Thank you for reading and for following us regularly.

Related posts
Other Technology articles
Category

System

Windows XP

Windows Server 2012

Windows 8

Windows 7

Windows 10

Wifi tips

Virus Removal - Spyware

Speed ​​up the computer

Server

Security solution

Mail Server

LAN - WAN

Ghost - Install Win

Fix computer error

Configure Router Switch

Computer wallpaper

Computer security

Mac OS X

Mac OS System software

Mac OS Security

Mac OS Office application

Mac OS Email Management

Mac OS Data - File

Mac hardware

Hardware

USB - Flash Drive

Speaker headset

Printer

PC hardware

Network equipment

Laptop hardware

Computer components

Advice Computer

Game

PC game

Online game

Mobile Game

Pokemon GO

information

Technology story

Technology comments

Quiz technology

New technology

British talent technology

Attack the network

Artificial intelligence

Technology

Smart watches

Raspberry Pi

Linux

Camera

Basic knowledge

Banking services

SEO tips

Science

Strange story

Space Science

Scientific invention

Science Story

Science photo

Science and technology

Medicine

Health Care

Fun science

Environment

Discover science

Discover nature

Archeology

Life

Travel Experience

Tips

Raise up child

Make up

Life skills

Home Care

Entertainment

DIY Handmade

Cuisine

Christmas

Application

Web Email

Website - Blog

Web browser

Support Download - Upload

Software conversion

Social Network

Simulator software

Online payment

Office information

Music Software

Map and Positioning

Installation - Uninstall

Graphic design

Free - Discount

Email reader

Edit video

Edit photo

Compress and Decompress

Chat, Text, Call

Archive - Share

Electric

Water heater

Washing machine

Television

Machine tool

Fridge

Fans

Air conditioning

Program

Unix and Linux

SQL Server

SQL

Python

Programming C

PHP

NodeJS

MongoDB

jQuery

JavaScript

HTTP

HTML

Git

Database

Data structure and algorithm

CSS and CSS3

C ++

C #

AngularJS

Mobile

Wallpapers and Ringtones

Tricks application

Take and process photos

Storage - Sync

Security and Virus Removal

Personalized

Online Social Network

Map

Manage and edit Video

Data

Chat - Call - Text

Browser and Add-on

Basic setup