Skip to content

Add support for local LM Studio endpoints in Claude Code#32

Open
lklyne wants to merge 1 commit into
mainfrom
claude/local-lm-studio-setup-WWVKp
Open

Add support for local LM Studio endpoints in Claude Code#32
lklyne wants to merge 1 commit into
mainfrom
claude/local-lm-studio-setup-WWVKp

Conversation

@lklyne
Copy link
Copy Markdown
Owner

@lklyne lklyne commented Apr 24, 2026

Summary

This PR adds support for using Claude Code with local, Anthropic-compatible endpoints (such as LM Studio 0.4.1+) in addition to the existing Anthropic API models (Opus, Sonnet, Haiku).

Key Changes

  • New buildClaudeInvocation function: Extracted and refactored the Claude CLI invocation logic into a testable, reusable function that handles model selection, permissions, and local endpoint configuration
  • Local model support: Added 'local' as a new FixModel option with configurable baseUrl, modelId, and authToken fields
  • Environment variable routing: When using a local model, the function sets ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, and ANTHROPIC_MODEL environment variables to point Claude Code's CLI at the local server
  • UI enhancements: Added input fields in the Fix Settings panel for configuring local endpoint details (base URL, model ID, auth token) with sensible defaults for LM Studio
  • Type safety improvements: Created FixConfigPatch type for partial config updates and updated all related type signatures
  • Comprehensive test coverage: Added 6 new test cases covering Opus defaults, model-specific flags, permissions, local endpoint configuration, LM Studio defaults, and whitespace trimming

Implementation Details

  • Local endpoint defaults to http://localhost:1234 (LM Studio default) with auth token lmstudio
  • Configuration values are trimmed of whitespace before use
  • The modelId parameter is optional; if not provided, the CLI won't receive a --model flag for local endpoints
  • Preferences are persisted with the new local configuration fields
  • All existing Anthropic API model behavior remains unchanged

https://claude.ai/code/session_01FKkE9D6dM7n5bPWaSKAVHr

Adds a 'local' FixModel that points Claude Code's CLI at an
Anthropic-compatible endpoint (LM Studio's /v1/messages) via
ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN / ANTHROPIC_MODEL instead
of the Claude API. Skills, permissions, and stream-json output are
still handled by the CLI on the client side.

https://claude.ai/code/session_01FKkE9D6dM7n5bPWaSKAVHr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants