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.
Claude Code sends requests to http://localhost:8080 (the proxy) instead of api.anthropic.com. The proxy:
- Forces the model — rewrites the
modelfield to your local model ID - Strips incompatible fields — removes
thinking,context_management,output_config,metadata, and the dynamic billing header - Stabilizes the system clock — replaces live timestamps with a fixed date so the prompt hash stays cacheable
- Removes ephemeral cache tags — strips
cache_controlblocks that confuse local engines - Forwards & streams — passes the cleaned request to LM Studio on
localhost:1234and streams the response back
bash setup.sh
source claude-proxy-env/bin/activateThe setup script installs Python 3.13.2 via pyenv, creates a virtual environment (claude-proxy-env), and installs the requests library.
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-8bitThen point Claude Code at the proxy:
ANTHROPIC_BASE_URL=http://localhost:8080 claudeTested 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.
| File | Description |
|---|---|
cache_shield.py |
The proxy server |
setup.sh |
One-shot environment setup |
.python-version |
Pins Python 3.13.2 for pyenv |