To Data & Beyond

To Data & Beyond

Hands-On Claude

Run Claude Code Locally on Apple Silicon Using LM Studio and LiteLLM (Zero Cost)

A step-by-step guide to running Claude Code with Qwen3-Coder-30B using MLX models on macOS

Manjunath Janardhan's avatar
Manjunath Janardhan
Mar 10, 2026
∙ Paid

Get 30% Discount on Paid Subscription

Agentic coding tools are powerful, but they usually come with a cost. Until recently, using Claude Code meant routing every request through Anthropic’s API and paying per token.

That is no longer strictly necessary.

Ollama recently introduced support for running Claude Code locally with open-source models. This is a strong option for Windows, Linux, and macOS Intel users. However, on Apple Silicon (M-series Macs), Ollama provides limited benefits because it does not support MLX models. On Apple Silicon, MLX models are significantly faster and more efficient than GGUF models, meaning Ollama cannot fully utilize the hardware capabilities of M1, M2, or M3 chips.

To solve this, we can use LiteLLM with minimal configuration to make Claude Code compatible with LM Studio, enabling us to run high-performance MLX models locally on Apple Silicon.

In this article, I’ll show how to run Claude Code locally on macOS using:

  • LM Studio for local LLM inference

  • Qwen3-Coder-30B, a strong open-source coding model

  • LiteLLM as an Anthropic-to-OpenAI protocol bridge

  • Zero cloud usage and zero API cost

This setup works reliably on macOS Apple Silicon, runs entirely offline, and does not require Docker.

If you are using Windows or Linux, you can run Claude Code locally using Ollama without setting up a LiteLLM proxy. For those platforms, refer to the official documentation.

Get All My 8 Books With 60% Off


Get All My 8 Books, One Button Away With 60% Off

Youssef Hosni
·
June 17, 2025
Get All My 8 Books, One Button Away With 60% Off

I have created a bundle for my books and roadmaps, so you can buy everything with just one button and for 40% less than the original price. The bundle features 8 eBooks, including:

Read full story

What We’re Building?

Get 30% Discount on Paid Subscription

Claude Code expects the Anthropic Messages API, while most local LLM runtimes expose an OpenAI-compatible API.

The key idea is to insert a lightweight translation layer, so Claude Code can work with a local model.

The final architecture looks like this:

Image by Manjunath Janardhan. Generated by Google Nano Banana Pro.

Once this is set up, Claude Code behaves exactly like it does with Anthropic’s cloud — except everything runs on your machine.

Get All My 8 Books With 60% Off

Prerequisites

  • macOS (Apple Silicon works well)

  • Python 3.10+

  • Node.js (for Claude Code)

  • LM Studio installed

  • Sufficient RAM for a 30B model

Step 1: Set Up LM Studio

Get 30% Discount on Paid Subscription

  1. Open LM Studio

  2. Download and load the model:

  3. Model name

qwen/qwen3-coder-30b

4. Enable the Local Server

5. Confirm the server is running at:

http://localhost:1234/v1
Image By Manjunath Janardhan. LM Studio local server running Qwen Coder 30b model.

This endpoint exposes an OpenAI-compatible Chat Completions API, which LiteLLM will use.

Get All My 8 Books With 60% Off

Step 2: Create a Python Virtual Environment

Create a clean environment for LiteLLM:

mkdir ~/litellm
cd ~/litellm
python3 -m venv venv
source venv/bin/activate

Install LiteLLM with proxy support:

pip install “litellm[proxy]”

Step 3: Configure LiteLLM

Get 30% Discount on Paid Subscription

Create a file called config.yaml:

model_list:
  - model_name: qwen3-coder
    litellm_params:
      model: openai/qwen/qwen3-coder-30b
      api_base: http://localhost:1234/v1
      api_key: lmstudio

  # Claude Code starts with this default model internally
  - model_name: claude-haiku-4-5-20251001
    litellm_params:
      model: openai/qwen/qwen3-coder-30b
      api_base: http://localhost:1234/v1
      api_key: lmstudio

litellm_settings:
  drop_params: true

Why this configuration matters

  • Model aliasing: Claude Code does not reliably handle model names with slashes.
    We expose a clean alias (qwen3-coder) while mapping it to the exact LM Studio model ID.

  • Claude's default model mapping: Claude Code internally starts with claude-haiku-4-5-20251001. Mapping it avoids startup errors.

  • drop_params: true. Claude Code sends Anthropic-specific parameters that local models do not support. LiteLLM safely removes them.

Step 4: Start the LiteLLM Proxy

From the same directory:

Get 30% Discount on Paid Subscription

User's avatar

Continue reading this post for free, courtesy of Youssef Hosni.

Or purchase a paid subscription.
Manjunath Janardhan's avatar
A guest post by
Manjunath Janardhan
AI/ML Computational Science Senior Manager at Accenture with 21+ years building enterprise AI, GenAI, and intelligent operations.
Subscribe to Manjunath
© 2026 Youssef Hosni · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture