Open vs Closed Models
The open vs closed decision affects cost, privacy, customization, performance, and operational burden. Understanding trade-offs helps you architect systems that balance control, quality, and economics.
Closed models are like SaaS — convenient, maintained by experts, but you're locked in and data leaves your building. Open models are like self-hosted software — more control and privacy, but you manage the infrastructure.
Visual Workflows
Start here — study each diagram, then use + / − to zoom if needed.
Scroll inside the frame · use + / − to zoom
Key Takeaways
- 1.Open models have publicly available weights (Llama, Mistral) while closed models are API-only (GPT-4, Claude) — each approach has distinct trade-offs for AI engineering. Closed (API): GPT-4o, Claude, Gemini.
- 2.Pros: best performance, no infra management, regular updates, safety built-in. Cons: data sent to third party, vendor lock-in, per-token cost, no weight customization.
- 3.Open weights: Llama 3, Mistral, Qwen. Pros: self-host (data privacy), fine-tune freely, no per-token cost at scale, no vendor dependency.
- 4.Cons: need GPU infra, operational burden, typically lower performance, safety alignment varies. Hybrid: use closed for complex tasks, open for high-volume simple tasks or sensitive data.
Real Example
Scenario
A hospital uses self-hosted Llama for patient data processing (privacy requirement) but calls GPT-4 API for general medical literature summarization (no patient data, needs highest accuracy).
What you would do
In Generative AI Foundations, apply Open vs Closed Models to this scenario: A hospital uses self-hosted Llama for patient data processing (privacy requirement) but calls GPT-4 API for general medical literature summarization (no patient data, needs highest accuracy). Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.
Practice Task
Open the Code Walkthrough below and run it locally. Change one parameter related to Open vs Closed Models (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.
Code Walkthrough
Highlighted lines show where Open vs Closed Models happens in the code.
1# Closed model (API)2from openai import OpenAI # import dependencies3client = OpenAI() # create API client4response = client.chat.completions.create(model="gpt-4o-mini", messages=[...]) # call the API5
6# Open model (self-hosted with Ollama)7import httpx # import dependencies8response = httpx.post("http://localhost:11434/api/chat", json={9 "model": "llama3",10 "messages": [{"role": "user", "content": "Hello"}],11 "stream": False,12})13
14# Hybrid routing15def get_model(sensitive: bool, complex_task: bool) -> str: # define a reusable function16 if sensitive:17 return "llama3-local" # return the result18 return "gpt-4o" if complex_task else "gpt-4o-mini" # return the resultCheat Sheet
Quick recap
quick ref- •Closed: GPT-4, Claude (API)
- •Open: Llama, Mistral (self-host)
- •Ollama for local serving
- •Privacy → open model
- •Quality → closed API
- •Hybrid routing common
Common Mistakes
- ✕Self-hosting to save money without calculating true infra costs
- ✕Sending sensitive data to closed APIs without privacy review
- ✕Assuming open models match closed model quality on all tasks
- ✕Not having a hybrid strategy — all-in on one approach