- The three architectures: app→local, Claude Code→local, and the hybrid.
- Set up a gateway so Claude Code can talk to Ollama or LM Studio.
- Choose wisely: which tasks go to the local model and which to the cloud.
The three ways to connect them
- Your apps use local AI — Claude Code builds the application and the application talks to Ollama. This is what you've done throughout this course (legal chatbot, PDF, voice…). The most useful in practice.
- Claude Code uses a local model as its brain — instead of Anthropic's models, Claude Code sends its requests to your Ollama/LM Studio through a gateway. Maximum privacy, but with important limitations (we'll cover those now).
- Hybrid — each task to its model: the cloud for building and reasoning, local for repetitive, private, and free work. This is what I recommend and what most experienced people use.
Path 1 (review): your app talks to Ollama
You already know this: Ollama exposes a local server at http://localhost:11434 and your applications request responses from it. This is the architecture of all projects in this course. If you came straight to this lesson, start with the local AI chapter.
Path 2: Claude Code with a local brain (gateway)
Step 1: install and configure LiteLLM
pip install 'litellm[proxy]'
Create a config.yaml file in a new folder (for example ~/proyectos-ia/pasarela):
model_list:
- model_name: local
litellm_params:
model: ollama/qwen3:4b
api_base: http://localhost:11434Step 2: start the gateway
litellm --config config.yaml # queda escuchando en http://localhost:4000
Step 3: point Claude Code to your gateway
In another terminal, start Claude Code with these environment variables:
export ANTHROPIC_BASE_URL=http://localhost:4000 export ANTHROPIC_AUTH_TOKEN=local export ANTHROPIC_MODEL=local claude
Path 3: the hybrid (recommended)
The winning setup in 2026 isn't "all local" or "all cloud" — it's splitting tasks:
- Claude Code (cloud) → building apps, refactoring, debugging, agent tasks.
- Ollama/LM Studio (local) → the brain of your applications, private document chat, bulk summarization, everything repetitive you don't want to pay for.
That way every euro of your subscription goes to what actually needs it, and your sensitive data never leaves home. It also eases another common pain point: burning through plan limits — we cover that in the context and costs lesson in the Claude Code course.
If something goes wrong
- "connection refused" on port 4000 — the gateway isn't running, or you started it in another folder without the config.
- The gateway can't find the model — check ollama list: the name in config.yaml must match exactly (ollama/qwen3:4b).
- Slow responses — normal: your machine does all the work. Use a smaller model or the hybrid approach.
Practice challenge
Set up the gateway and ask Claude Code the same question in local mode and cloud mode. Compare quality and speed. That contrast will give you the exact criteria for which tasks deserve each brain.