Skip to content

Model providers: local or hosted

Every lab calls the model through one door (../door/), so switching provider is a settings change, never a code change. Ollama on your machine is the default; any provider below works for every topic.

Provider Pick it when Cost Embeddings Guide
Ollama (default) You want free, private, offline; you have 16 GB RAM Free Yes ollama.md
OpenAI You want strong models and simple setup Pay per token, prepaid Yes openai.md
Anthropic (Claude) You want strong tool use and long agent runs Pay per token, prepaid No: keep Ollama's anthropic.md
Google Gemini You want a free tier with no card (20 chat requests a day: embeddings only) Free tier, then pay per token Yes gemini.md
Groq You want very fast open models on a free tier, or your laptop has 8 GB RAM (Low-RAM quick start) Free tier with tight limits No: keep Ollama's groq.md
OpenRouter You want one key for many vendors Pay per token, prepaid No: keep Ollama's openrouter.md

Prices, free tiers and model names change often. Each guide links the provider's own pages; those win over this repo.

Switching in three steps

uv pip install -e '.[hosted]'    # 1. once, from ai-learning: adds LiteLLM (not needed for Ollama)
cp .env.example .env             # 2. once: then set LLM_MODEL and the provider's key in .env
python -c "import door; print(door.describe())"   # 3. check: it prints the models every lab will use
  • One run only: a variable in the shell wins over .env: LLM_MODEL=openai/gpt-5.4-mini python tools.py.
  • Back to local: set LLM_MODEL=ollama/qwen3:8b in .env (or delete the line).
  • Model names are <provider>/<model>, the names LiteLLM uses. A name with no provider (qwen3:8b) means Ollama.

Rules that apply to every provider

Chat and embeddings switch separately. LLM_MODEL is safe to change any time. EMBED_MODEL builds a new vector index (rag/store/ and RnR's Chroma index keep one folder per model, so nothing breaks), and distance thresholds such as RnR's RNR_ASK_MAX_DISTANCE were measured on nomic-embed-text: measure them again. Rule of thumb: switch chat first; keep embeddings on Ollama unless you have a reason.

Photos use VISION_MODEL (whatsapp-agent lab 09), default ollama/qwen3-vl:8b-instruct, because qwen3:8b is text-only. It does every step of a photo turn, so only one model is loaded. Most hosted chat models read images too: set VISION_MODEL to the same name as LLM_MODEL. Customer photos are customer data: the same data rules apply.

A model change is a prompt change. The "Expected output" blocks were recorded on qwen3:8b. A bigger model usually does better, sometimes differently. Where a lab has an eval (RnR 05, RAG 09, WhatsApp 07, multi-agent 06), run it again before you trust the switch. If a lab fails on a hosted model, run it on Ollama to tell a provider gap from a lab bug.

Data. The labs use synthetic data, so any provider is fine for them. Real customer, order or company data goes to an outside provider only with your company's approval and a paid plan whose terms say inputs are not used for training. Treat any free tier as public: free-tier prompts may be used to improve the provider's models.

Keys. In .env (in .gitignore) or your shell, never in code or a commit. One key per person or project, so it can be revoked alone. Set a monthly spend limit in the provider's console before the first run.

Cost. A lab run is usually tens to a few hundred calls of 500 to 2,000 tokens: cents on a small model. RnR evals with --n 500 and 00_generate_data.py --llm make thousands. Start with the small model in each guide and --n 20. RnR's Ops page prices every call it makes.

Supply chain. LiteLLM is pinned to one exact version (pyproject.toml): in March 2026 two LiteLLM releases on PyPI carried credential-stealing code. Upgrade only after reading the release notes.

What the door maps for you

Feature Ollama Hosted (through LiteLLM)
Tool calls arguments as a dict, results by tool name arguments as a JSON string, results by call id
Structured output (schema=) format with the JSON schema response_format json_schema
think=True Ollama's think flag reasoning_effort="medium", temperature left to the provider
Errors ConnectionError, ResponseError (status) connection and timeout become ConnectionError / TimeoutError; others keep status_code (401, 429, ...)

Troubleshooting (any provider)

Symptom Fix
Hosted models need LiteLLM uv pip install -e '.[hosted]' from the ai-learning folder
AuthenticationError (401) The key variable for that provider is missing, mistyped or revoked
RateLimitError (429) Free-tier or account limits. The door waits the delay the provider asks for, up to DOOR_MAX_WAIT_S (default 120 s, 0 = raise at once); still failing: use --n 20, or add billing
CERTIFICATE_VERIFY_FAILED / self-signed certificate A company proxy inspects HTTPS: set SSL_CERT_FILE (see INSTALL.md)
NotFoundError (404) / unknown model The model name changed: copy a current one from the provider's model list
describe() still shows Ollama .env is not in the ai-learning folder, or the shell has an older LLM_MODEL (unset LLM_MODEL)
A schema or tool error only on one provider That model's support differs; try the provider's bigger model, or Ollama, to compare