Ollama
Install Ollama, pull Gemma 4 E2B, and run it locally with the OpenAI-compatible API on port 11434.
Ollama runs large language models on your machine with a small CLI and a local HTTP API. The official docs describe it as cross-platform (macOS, Windows, Linux) with a terminal-first workflow, see Ollama quickstart.
This page focuses on Gemma 4 E2B, Google's edge-oriented variant (the "E" stands for effective parameters in the Gemma 4 family). The Ollama library tag is gemma4:e2b, see gemma4:e2b on ollama.com for size and update notes.
If tags change, trust the library page over this workshop text.
Install Ollama
Download the app for your OS from ollama.com and complete installation (macOS drag-to-Applications, Windows installer, Linux per download instructions).
Confirm the ollama CLI is on your PATH (open a new terminal after install).
Optional Docker path: Ollama Docker documents docker run / docker exec patterns if you prefer containers.
Pull and run Gemma 4 E2B
Download the weights (CLI example from Ollama's API docs for gemma3 pattern; for Gemma 4 use the gemma4:e2b name):
ollama pull gemma4:e2bChat / REPL:
ollama run gemma4:e2bOne-off API call (matches the style shown on the gemma4:e2b library page):
curl http://localhost:11434/api/chat \
-d '{
"model": "gemma4:e2b",
"messages": [{"role": "user", "content": "Hello!"}]
}'Default local API base is http://localhost:11434 with /api/... routes, see API introduction.
OpenAI-compatible endpoint (for gateways and editors)
Ollama exposes an OpenAI-compatible /v1 surface so tools that speak chat/completions can attach without custom drivers, see OpenAI compatibility.
Typical settings:
- Base URL:
http://localhost:11434/v1/ api_key: any placeholder string (oftenollama), required by clients but ignored locally, as shown in the official Python / JavaScript examples on that page.model:gemma4:e2b
Example Python (from Ollama docs):
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:11434/v1/",
api_key="ollama",
)
chat_completion = client.chat.completions.create(
model="gemma4:e2b",
messages=[{"role": "user", "content": "Say this is a test"}],
)
print(chat_completion.choices[0].message.content)Hardware and expectations
- E2B is aimed at constrained machines; see disk size and context on ollama.com/library/gemma4.
- Agentic coding with small models is possible for demos but not a substitute for frontier Claude models on hard refactors, set learner expectations.
Launch Claude Code with Ollama (built-in)
Ollama ships a launch integration so you do not have to hand-wire env vars for the common case, see Claude Code · Ollama and ollama launch in the CLI reference.
Interactive (pick model in the launcher):
ollama launch claudeSpecific model (e.g. workshop Gemma 4 E2B):
ollama launch claude --model gemma4:e2bPrint config only (no app start), useful for scripts or docs:
ollama launch claude --configNon-interactive (CI, Docker): --yes skips prompts and can auto-pull; --model is required; arguments after -- go to claude:
ollama launch claude --model gemma4:e2b --yes -- -p "how does this repository work?"Under the hood this aligns with Ollama's Anthropic-compatible API on http://localhost:11434 (ANTHROPIC_AUTH_TOKEN=ollama, ANTHROPIC_BASE_URL=http://localhost:11434) as in Anthropic compatibility, verify exact env names in that doc if your Ollama version differs.
LM Studio now has its own Anthropic-compatible endpoint and connects directly. Use LiteLLM for multi-provider routing, fallbacks, centralized auth, metering, or backends without a compatible Messages API; see Hijacking Claude Code.