Single logo
  • Courses
  • Blog
  • About
Join free on SkoolJoin free on Skool

In this topic

AI Engineering
  • The AI Stack in One Picture: Six Layers Every AI Product Is Built From
  • Tokenization: What an LLM Actually Sees When You Type
  • LLM Tokens, Context Windows and Cost: What One Question Really Costs
  • What an LLM Can and Cannot Do: One Prediction Loop, Its Strengths and Its Gaps
  • Structured LLM Output with Pydantic: Describe the Shape Once, Check Every Reply
  • Temperature, Top-p and Sampling: Why the Same Prompt Gives a Different Answer
  • Open vs Closed LLMs: Cost, Control, Privacy and Capability, Decided per Workload
  • Streaming and Error Handling for LLM Calls: Show the First Word Early, Retry Politely, Fail Calmly
  • Practice: Build a CLI Chat Tool with Memory, Commands, Error Handling and a History Cap
  • Explicit Criteria vs Vague Prompts: Turn Every Adjective Into a Check a Script Can Run
  • Few-Shot Prompting Done Right: How Many Examples, How Different, What Order, and the Leak That Lies
  • Prompt Caching: Keep the Start of Every Request Identical and Pay for the Long Part Once
  • Prompt Versioning and Testing in a Repo: Prompt Files, a Registry, a Hash per Answer and Tests That Gate
  • Context Engineering: What Belongs in the Context Window, Turn by Turn
  • Context Engineering for a Long-Running Agent: Clear, Compact, Take Notes, Prove It
  • What an Embedding Actually Is: Meaning as Numbers, Search by Closeness, and Where Hand-Made Numbers Break
  • The RAG Pipeline Explained: 7 Stages From Documents to a Cited Answer
  • Similarity Search: Finding the Closest Vectors with NumPy and NearestNeighbors
  • Why RAG Exists: The Problem It Solves, Compared With Pasting Everything and Fine-Tuning
  • Real Embedding Models: an Open Model or a Provider API, Then Search, Duplicates and Recommendations
  • Chunking Strategies for RAG: Fixed Size, Sentences or Headings, Measured on One Handbook
  • Vector Databases Hands-On: The Same Search in Chroma and pgvector
  • RAG Prompt Assembly and Citations: Number the Blocks, Fit a Token Budget, Check Every Claim
  • Hybrid Search: BM25 Plus Dense Embeddings, Merged With Reciprocal Rank Fusion
  • Reranking With a Cross-Encoder: When the Second Pass Helps, and When It Doesn't
  • Retrieval Evals: Score the Retriever With Recall@K, MRR and nDCG Before Blaming the Model
  • Choosing a Vector Index: Flat, HNSW or IVF-PQ, a Memory Estimate, and Filters That Starve Small Customers
  • Citations and Abstention in RAG: What a Citation Proves, and When the Right Answer Is "It's Not in the Documents"
  • Embedding Migration With Zero Downtime: Two Indexes, a Dual-Write Backfill, a Shadow Check and a Flag
  • Cosine, Dot Product or Euclidean Distance: Why Three Measures Pick Three Winners, and the One Fix
  • Choosing an Embedding Model: Dimension, Context Length, Domain and Cost, Tested on Your Own Questions
  • Loading and Parsing Real Documents for RAG: PDF Headers, Wrapped Lines, Tables and HTML Chrome, Scored
  • Where Naive RAG Fails: Five Ways the Simplest Retriever Hands the Model the Wrong Pages
  • RAG Generation Metrics: Faithfulness, Groundedness and Relevance, One Claim at a Time
  • Context Engineering for a Long-Running Agent: Clear, Compact, Take Notes, Prove It
  • What LangChain Is For, and When to Skip It: Five Standard Parts, One Pipe, and a Decision Table
  • Why Chains Break: No Branch, No Retry, No Pause, and the Same Refund Assistant as a LangGraph Graph
  • LangGraph Nodes, Edges and State: Build Your First Graph, Route With a Conditional Edge, and Read the Run Three Ways
  • Human-in-the-Loop and Checkpointing in LangGraph: interrupt, a SQLite Save Slot and Command(resume=...)
  • Multi-Agent Patterns: Hub and Spoke in LangGraph, With Short Briefs, Owned Tools and a Retry the Hub Decides
  • A Research Agent in LangGraph: Plan, Search, Read, Write, and a Check Node That Rejects Citations Nobody Read
  • Workflow or Agent: Decide Who Picks the Next Step, Then Let the Constraints Choose the Design
  • Custom Agent Loops and Harnesses: A Dispatch Table, an Approval Hold, Error Results and a Turn Budget
  • Building an MCP Server: Tools, Resources and Prompts in Python and TypeScript
  • MCP Transports: stdio or Streamable HTTP, and Who Starts the Server
  • Deploying and Authenticating an MCP Server: Environment Keys for stdio, Bearer Tokens and Scopes for HTTP
  • From ML Metrics to LLM Evals: Same Ruler, New Targets
  • Why You Cannot Ship an LLM Feature Without an Eval: Five Parts, Three Graders, One Tiny Eval
  • Building a Golden Dataset for LLM Evals: Cases, a Schema, a Coverage Table and a Seeded Split
  • Retrieval Evals: Score the Retriever With Recall@K, MRR and nDCG Before Blaming the Model
  • Regression Testing an LLM Bot in CI: A Golden Set, Two pytest Gates and GitHub Actions
  • Testing a RAG Bot Before It Ships: Slices, a Release Gate per Slice, and the Week After
  • RAG Generation Metrics: Faithfulness, Groundedness and Relevance, One Claim at a Time
  • LLM-as-Judge: Write a Rubric, Check Every Verdict, and Trust the Grader Only After Kappa Says So
  • RAGAS and Custom Evals: Framework Faithfulness Plus Your Own Citation and Required-Fact Checks, Behind One Gate
  • Which Test Layer Owns the Failure? Unit, Functional, Integration and End-to-End Tests for a Claude App
  • Six Ways a 200 Can Still Be Wrong: Hallucination, Refusal, Under-Acting, Context Loss, Format Drift and Inconsistency
  • Proving a Model Upgrade Is Ready: A Frozen Golden Set, a Calibrated Judge, the Right Layer and a Release Gate
  • Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed
  • Back Pressure for LLM Traffic: Bound the Queue, Give Chat Its Own Lane, Count Tokens, Cancel When the Caller Leaves
  • Load Balancing LLM Traffic: Count the Work, Weigh the Prefix Cache, Check Real Health, Drain Before Deploys
  • A Message Queue for Document Ingestion: At Least Once, Leases, an Idempotent Consumer and a Dead Letter Queue
  • Caching for AI Apps: Four Layers, What Goes in Each Key, and How a Delete Travels
  • Semantic Caching: Why a Similarity Threshold Can't Stop Confident Wrong Answers
  • LLM Model Routing: Rules, a Classifier or a Cascade, Judged on Cost per Win and Every Topic
  • Cutting p95 and Cost in Half for an LLM App: Read the Bill, Match the Lever, Guard Success
  • Observability and Tracing for LLM Apps: A Span per Stage, Redaction First, Bad Traces Become Tests
  • Guardrails for an LLM Agent: Check What Comes In, What It Wants to Do, and What Goes Out
  • Embedding Migration With Zero Downtime: Two Indexes, a Dual-Write Backfill, a Shadow Check and a Flag
  • Design a Multi-Tenant RAG Assistant, Part 1: Requirements, Rough Numbers and a Contract
  • Design a Multi-Tenant RAG Assistant, Part 2: Tenant Isolation, a Scoped Cache and Walking an Outage
  • A 500 MB PDF Takes 50 s to Answer, Get It to 2 s: Measure First, Then Promise Per Path
  • A 500 MB PDF From 50 s to 2 s, the Fast Path: Queue, Status, Streaming and an Acceptance Test That Fails
  • Guardrails for an LLM Agent: Check What Comes In, What It Wants to Do, and What Goes Out
  • Prompt Injection, Jailbreaks and Untrusted Input: Label What Comes In, Gate What Goes Out
  • Injection Exposure Review for an Agent: Map Inputs, Data and Effects, Layer Every Path, Retest the Job
  • Data Leakage and PII in LLM Apps: Redact, Minimize, Log Safely and Count Every Place
  • Hooks That Block Destructive Actions: a PreToolUse Gate That Allows, Asks or Denies
  • Claude API Keys: Keep the Key on a Server Proxy, One Key per Environment, Rotate and Scope It
  1. Blog
  2. /
  3. AI Engineering
  4. /
  5. LLM Fundamentals

Open vs Closed LLMs: Cost, Control, Privacy and Capability, Decided per Workload

Open or closed is not a team you join. Compare a rented API and open weights you run yourself on cost, control, privacy and capability, then decide per workload: an agent, nightly tagging and hospital notes get three different answers.

Chaand Sheikh

·27 November 2026LLM Fundamentals

What you will learn

  • Explain the difference between a closed model and an open-weight model, and why open weights is not always open source
  • Compare the two on cost, control, privacy and capability
  • Read the shape of per-token cost against your own GPUs and find where your traffic sits
  • Pick closed, open or hybrid per workload and keep the model swappable behind one function

Before you start

  • LLM Tokens, Context Windows and Cost

Open models or closed models? People argue about it a lot online, as if you had to pick a side. Here's the spoiler: it is not a team you join. It is a choice you make for each workload, and you make it on four things: cost, control, privacy and capability.

Ride-hailing or your own car?

Think about getting to the office every day. You can book a ride, or you can drive your own car. Both get you there, but they cost, and behave, very differently.

  • Ride-hailing: you pay per trip and nothing up front. No maintenance, and you usually get a fairly new car. But the company sees every route you take, and the car is whatever they send.
  • Your own car: you pay up front, then fuel and repairs. When it breaks, you fix it. But your trips stay private, and you can modify it however you like.

This is exactly the trade-off with language models. A closed model is the ride. An open-weight model is the car you own.

What the two words actually mean

The words get used loosely, so let's pin them down. The weights are the billions of learned numbers that make up the model.

  • Closed model: the weights stay with the provider. You send text to an API, text comes back, and you pay per token. Claude, GPT and Gemini work like this.
  • Open-weight model: you can download the weights. You run them on your own GPUs, or on a host you pick, and you pay for the hardware. Llama, Mistral, Qwen, Gemma and DeepSeek are well-known families.

Open weights is not always open source. Some licences limit commercial use, or the size of the company that can use them. Read the licence before you ship anything.

Whether an open model even fits on your hardware is a separate question, covered in Model Size and Memory.

The four trade-offs

AxisClosed APIOpen weights
CostPay per token; zero when idlePay for GPUs and people, busy or idle
ControlProvider updates and retires models; rate limitsPin the exact weights forever; fine-tune freely
PrivacyData leaves your network; check retention termsData can stay inside your network
CapabilityUsually strongest on the hardest tasksOften good enough for narrow, well-defined tasks
  • Cost. With a closed API, when nobody uses it, you pay nothing. With open weights you pay for the GPUs and for the people who run them, whether the GPUs are busy or idle.
  • Control. A closed provider can update a model or retire it, and you work within its rate limits. With open weights you can pin the exact weights forever.
  • Privacy. With a closed API your data leaves your network, so check the provider's data retention terms. With open weights the data can stay inside.
  • Capability. The closed frontier models are usually the strongest on the hardest tasks, like long reasoning and agents. Open models are often good enough for narrow tasks. But "usually" is not a decision. Your own eval is.

Cost has a shape

Most of the confusion is about cost. The question is not "which one is cheaper?" It is "cheaper at what volume?"

Per-token cost against your own GPUs (example shape, no real prices) requests per month monthly cost per token own GPUs same busy or idle +1 machine low volume: per token is hard to beat crossover: depends on you
An example shape only, with no real prices. Per-token cost grows in a straight line with use; your own GPUs cost the same busy or idle, then jump each time you add a machine.

Per-token pricing grows in a straight line with use, and at low volume it is really hard to beat. Your own GPUs cost the same whether they are busy or idle, and the cost jumps every time you add another machine. Where the two lines cross depends completely on your traffic.

So do the maths with your own numbers: the provider's pricing page and your real request volume. The per-call side of that maths is in LLM Tokens, Context Windows and Cost. Your own GPUs cost the same busy or idle; Serving Open Models shows how batching and cold starts play out when you serve an open model.

Decide per workload

Here's how it plays out inside one company, with three different answers.

WorkloadWhat mattersPick
Customer-facing agentMulti-step reasoning, tools, a brand on the line, moderate volumeClosed frontier API
Nightly ticket taggingMillions of short texts, one narrow label each, no rushSmall model: open or closed, let the eval decide
Hospital notes summaryPatient data that may not leave the buildingOpen weights, on-premises

The agent needs capability. The tagging job is narrow and huge, so a small model fits, and the eval decides which one. For hospital notes, privacy wins over everything else.

Most teams end up hybrid

A router in front of two models Request "Where is my order?" "Plan my migration" Router simple rules first, a small classifier later Small or open model easy, high-volume Frontier model hard, rare, high-value
Hybrid: a router sends each request to the cheapest model that is good enough.

A request comes in. It might be something simple like where is my order?, or something hard like plan my database migration. A router looks at it first: simple rules to begin with, maybe a small classifier later. Easy, high-volume requests go to a small or open model. The hard, rare, high-value ones go to the frontier model. (How to judge a router on real numbers is in LLM Model Routing.)

The engineering lesson: hide that choice behind one client function. Then swapping a model is a config change, not a rewrite of your app. Your code asks for "an answer"; only that one function knows which model gives it.

Five questions before you choose

  1. What does my eval say, on my own data? Not a leaderboard. My data.
  2. What is the volume, and how spiky is it?
  3. Is this data allowed to leave our network?
  4. Who gets paged at 3 a.m. when it goes down? With an API, that is mostly the provider. With your own GPUs, that is you.
  5. What does the licence allow?

Common mistakes

  • Picking a side for the whole company instead of deciding per workload.
  • Treating "open weights" as "open source" and shipping without reading the licence.
  • Comparing a per-token price with a GPU price without your own volume. Cheaper only means something at a given number of requests.
  • Forgetting the people cost of running your own GPUs, and who is on call.
  • Trusting "usually stronger" over your own eval on your own data.
  • Calling one provider's SDK all over the codebase, so a model swap turns into a rewrite.

Quick recap

Closed modelOpen weights
Yourent it per tokenown the model and the hardware
Wins whenlow volume, the hardest tasksdata must stay in, volume past your crossover, you need to pin or fine-tune
Watch forretention terms, rate limits, model retirementlicence, idle GPUs, who gets paged

Judge both on cost, control, privacy and capability, decide per workload, and keep the model swappable behind one function.

Try it yourself

  1. Write down three AI tasks from your work or your project.
  2. For each one, mark which of the four axes matters most.
  3. Pick closed, open or hybrid, and justify it in one sentence each.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in AI Engineering · 7 of 79

Previous
Temperature, Top-p and Sampling: Why the Same Prompt Gives a Different Answer
Next post
Streaming and Error Handling for LLM Calls: Show the First Word Early, Retry Politely, Fail Calmly

Related course on Udemy

Become an AI Engineer: LLMs, RAG, Agents and MCP

Build real AI systems in Python: LLM APIs, RAG, evals, agents and MCP.View on Udemy ↗: Become an AI Engineer: LLMs, RAG, Agents and MCP (paid course, opens in a new tab)

Related posts

The AI Stack in One Picture: Six Layers Every AI Product Is Built From

Every AI product is built from six layers: data, model, retrieval, orchestration, serving and ops, with evals and security across all of them. A restaurant analogy, one request traced through all six, and what an AI engineer actually builds around the model call.

Tokenization: What an LLM Actually Sees When You Type

A language model never sees letters, only token ids. Use tiktoken to watch strawberry become three ids, see a space or a capital change them, fix the letter-counting problem, and compare English, German and Hindi token counts.

LLM Tokens, Context Windows and Cost: What One Question Really Costs

Follow one four-word help desk question that becomes 911 input tokens. Learn what fills the context window, why chat memory grows every turn, how max_tokens cuts a reply, and how to price a call.

What an LLM Can and Cannot Do: One Prediction Loop, Its Strengths and Its Gaps

A large language model predicts the next token, over and over. That one loop makes it strong at drafting, summarising and classifying, and weak at fresh facts, exact maths, memory and guaranteed truth. See why with a three-line tiktoken script, and learn the fix for each gap.

On this page

  • Ride-hailing or your own car?
  • What the two words actually mean
  • The four trade-offs
  • Cost has a shape
  • Decide per workload
  • Most teams end up hybrid
  • Five questions before you choose
  • Common mistakes
  • Quick recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Become an AI Engineer: LLMs, RAG, Agents and MCP

Build real AI systems in Python: LLM APIs, RAG, evals, agents and MCP.View on Udemy ↗: Become an AI Engineer: LLMs, RAG, Agents and MCP (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact usFAQs
Legal
Terms of ServicePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.