Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

claude-proxy

A lightweight proxy that lets Claude Code talk to a local LM Studio model instead of Anthropic's API. It strips Claude-specific metadata that confuses local inference engines, locks the request to a chosen model ID, and streams the response back to Claude Code.

How it works

Claude Code sends requests to http://localhost:8080 (the proxy) instead of api.anthropic.com. The proxy:

  1. Forces the model — rewrites the model field to your local model ID
  2. Strips incompatible fields — removes thinking, context_management, output_config, metadata, and the dynamic billing header
  3. Stabilizes the system clock — replaces live timestamps with a fixed date so the prompt hash stays cacheable
  4. Removes ephemeral cache tags — strips cache_control blocks that confuse local engines
  5. Forwards & streams — passes the cleaned request to LM Studio on localhost:1234 and streams the response back

Requirements

  • pyenv
  • LM Studio running locally with the server enabled on port 1234

Setup

bash setup.sh
source claude-proxy-env/bin/activate

The setup script installs Python 3.13.2 via pyenv, creates a virtual environment (claude-proxy-env), and installs the requests library.

Usage

Start the proxy with your chosen model ID:

python3 cache_shield.py <model-id>

# Examples
python3 cache_shield.py qwen2.5-coder-14b-instruct-mlx
python3 cache_shield.py Qwen2.5-Coder-32B-Instruct-MLX-8bit

Then point Claude Code at the proxy:

ANTHROPIC_BASE_URL=http://localhost:8080 claude

Performance benchmarks

Tested on a MacBook M5 Pro 64 GB. "hi" = first-token latency on a trivial prompt. "complex" = full response to "what does this repo do?".

Model Variant "hi" response Complex response Notes
Qwen2.5-Coder-32B-Instruct MLX 1m 28s —
Qwen2.5-Coder-32B-Instruct LM Studio community (non-MLX) 1m 50s 4m 41s Very hot, slow
Qwen2.5-Coder-32B-Instruct MLX 8-bit — 6m 20s Hot
Qwen2.5-Coder-14B-Instruct MLX 51s 1m 19s Best speed/quality balance
Qwen3.5-27B Claude 4.6 Opus distilled MLX 55s 6m 27s Hot on complex tasks
Qwen3.5-35B-A3B MLX 8-bit — 39s Low thermal

Recommendation: Qwen3.5-35B-A3B (MLX 8-bit) is now the top pick — 39s on complex tasks with low thermals. Qwen2.5-Coder-14B-Instruct (MLX) remains a solid fallback if you need a lighter model.

Files

File Description
cache_shield.py The proxy server
setup.sh One-shot environment setup
.python-version Pins Python 3.13.2 for pyenv

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages