The open source vs closed source llm decision shapes every downstream choice: infrastructure, latency budgets, data governance, and hiring. Closed models like GPT-4o and Claude 3.5 Sonnet deliver state-of-the-art reasoning out of the box. Open models like Llama 3.1 405B and DeepSeek-V3 give you weight access, deployment flexibility, and zero per-token fees — but demand real engineering to run well. This comparison cuts through the marketing to show where each approach actually wins.
Capabilities and reasoning
Closed models still lead on complex, multi-step reasoning, tool use, and instruction following. GPT-4o and Claude 3.5 Sonnet consistently score higher on benchmarks like GPQA, MATH, and SWE-bench. They also handle long-context retrieval (128k–200k tokens) with fewer degradation artifacts than most open equivalents.
Open models have closed the gap on knowledge-intensive tasks and coding. Llama 3.1 405B matches GPT-4o on MMLU and HumanEval. DeepSeek-V3 (671B MoE, 37B active) reaches comparable scores with far less compute. But the gap reappears on agentic workflows: function calling reliability, structured output adherence, and multi-turn context management. If your product ships an autonomous agent today, closed models reduce prompt-engineering tax.
# Closed model: structured output is a first-class parameter
response = client.beta.chat.completions.parse(
model="gpt-4o-2024-08-06",
messages=[{"role": "user", "content": "Extract the invoice data"}],
response_format=InvoiceSchema,
)
# Open model (vLLM/TGI): you enforce schema via guided decoding
from vllm import SamplingParams
from vllm.lora.request import LoRARequest
sampling_params = SamplingParams(
temperature=0,
max_tokens=2048,
guided_json=InvoiceSchema.model_json_schema(),
)
outputs = llm.generate(prompts, sampling_params)
Price and cost model
Closed models charge per million tokens. Current street prices (input/output): GPT-4o ~$2.50/$10, Claude 3.5 Sonnet ~$3/$15, GPT-4o-mini ~$0.15/$0.60. You pay for convenience, SLA, and the model itself. No GPU capital expenditure, no ops team. Cost scales linearly with usage — predictable at low volume, painful at high volume.
Open models shift cost to infrastructure. Running Llama 3.1 405B (BF16) needs 8×H100 80GB (~$30/hr on-demand, ~$2/hr reserved). DeepSeek-V3 fits on 4×H100 with FP8 quantization. At sustained throughput, self-hosted 405B lands around $0.40–$0.80 per million tokens all-in (compute + amortized hardware). The crossover where self-hosting beats API pricing typically sits at 50–100M tokens/month, depending on utilization.
# Rough monthly cost comparison at 50M tokens/month (mixed 3:1 input:output)
# Closed (GPT-4o): ~$400–$600
# Self-hosted 405B (reserved): ~$1,500–$2,500 (includes multi-AZ redundancy)
# Self-hosted 70B (reserved): ~$300–$500
# DeepSeek-V3 (reserved): ~$400–$700
Hidden costs: observability, eval pipelines, capacity planning, kernel tuning. Closed models absorb these. Open models make them your problem.
Latency and throughput
Closed APIs add network hop variance (50–200ms p99) and queueing under load. Throughput is throttled by tier limits (e.g., 10k–500k TPM). You cannot guarantee p99 latency without provisioned throughput — which costs 3–5× on-demand.
Self-hosted models eliminate network variance. With vLLM or TensorRT-LLM on H100s, Llama 3.1 70B achieves ~3,000 tok/s per GPU (batch 32, ISL 1k, OSL 512). 405B needs 8 GPUs for similar per-request latency. You control batching, KV cache quantization, and speculative decoding. p99 latency becomes an SLO you engineer, not a vendor SLA you hope for.
# vLLM config for latency-optimized 70B serving
model: meta-llama/Llama-3.1-70B-Instruct
tensor_parallel_size: 4
gpu_memory_utilization: 0.9
max_num_batched_tokens: 8192
max_num_seqs: 256
enable_prefix_caching: true
enforce_eager: false # use CUDA graphs
speculative_model: meta-llama/Llama-3.1-8B-Instruct
speculative_draft_tensor_parallel_size: 1
num_speculative_tokens: 5
Throughput scales linearly with GPUs until interconnect saturates. Closed APIs scale by asking for quota increases.
Ergonomics and developer experience
Closed models win on ergonomics. One endpoint, OpenAI-compatible SDKs in every language, automatic retries, streaming, logprobs, function calling, vision, audio — all work without configuration. You integrate in minutes.
Open models require infrastructure decisions before first token: serving engine (vLLM, TGI, TensorRT-LLM, SGLang), quantization (AWQ, GPTQ, FP8, GGUF), orchestration (K8s, Ray, bare metal), auth, rate limiting, metrics. The ecosystem has matured — vLLM’s OpenAI-compatible server covers 90% of the surface area — but you still own the stack.
# OpenAI SDK works against local vLLM with zero code changes
from openai import OpenAI
client = OpenAI(
base_url="http://llm-gateway.internal/v1",
api_key="not-needed",
)
stream = client.chat.completions.create(
model="meta-llama/Llama-3.1-70B-Instruct",
messages=[{"role": "user", "content": "Hello"}],
stream=True,
)
The ergonomics gap narrows if you run a gateway that normalizes providers. n4n.ai exposes 240+ models — open and closed — behind one OpenAI-compatible endpoint, forwards provider cache-control hints, and handles automatic fallback when a provider degrades. You write the integration once; the gateway handles routing directives and per-token metering.
Ecosystem and tooling
Closed models anchor the tooling ecosystem. LangChain, LlamaIndex, AutoGen, CrewAI, and every eval framework prioritize OpenAI/Anthropic compatibility. New features (computer use, voice, native RAG) land there first. Documentation, StackOverflow answers, and hiring pool all favor closed APIs.
Open models have a different ecosystem: Hugging Face Hub (model discovery, leaderboards, spaces), vLLM/TGI/SGLang (serving), llama.cpp/MLX (edge), Unsloth/Axolotl (fine-tuning), OpenLLM/MLC (deployment). Fine-tuning is a first-class workflow — LoRA/QLoRA on 7B–70B models runs on 1–4 GPUs in hours. Closed models offer fine-tuning APIs (GPT-4o-mini, Claude 3 Haiku) but with less control, higher cost, and data egress concerns.
If your differentiation requires domain adaptation (legal, medical, code generation for a proprietary framework), open weights are the only path to full control. You can also distill closed-model outputs into smaller open models — a common pattern for latency-critical paths.
Operational limits and governance
Closed models impose hard limits: context window, rate limits, data retention policies, regional availability, model deprecation schedules. GPT-4o drops knowledge cutoff; you cannot extend it. You cannot audit weights. You cannot run in air-gapped environments. Vendor lock-in is real — migrating prompts across providers is non-trivial due to tokenizer and instruction-format differences.
Open models remove these constraints. You choose context length (up to 128k for Llama 3.1, 256k for some DeepSeek variants via RoPE scaling). You choose quantization. You choose data residency. You choose when to upgrade. The tradeoff: you own availability, security patching, and compliance evidence.
# Example: Llama 3.1 70B with 128k context via YaRN scaling
model: meta-llama/Llama-3.1-70B-Instruct
rope_scaling:
type: yarn
factor: 4.0
original_max_position_embeddings: 32768
max_model_len: 131072
Regulated industries (finance, healthcare, defense) often mandate open weights or on-prem deployment. Closed APIs can satisfy compliance with zero-retention agreements and VPC endpoints, but the audit burden is higher.
Comparison table
| Dimension | Closed (GPT-4o, Claude 3.5 Sonnet) | Open (Llama 3.1 405B, DeepSeek-V3, 70B) |
|---|---|---|
| Reasoning quality | Best-in-class on agentic, multi-step, tool use | Near-parity on knowledge/coding; weaker on agentic |
| Cost at 10M tok/mo | ~$80–$150 | ~$200–$500 (reserved GPU amortized) |
| Cost at 100M tok/mo | ~$800–$1,500 | ~$400–$800 |
| p99 latency (self-hosted) | N/A (network-bound, 200–500ms) | 150–300ms (batched, H100, 70B) |
| Throughput control | Tier-limited, quota requests | Linear with GPU count |
| Fine-tuning | API-only, limited control, higher cost | Full LoRA/QLoRA/RLHF, your data never leaves |
| Context window | 128k–200k (fixed) | 32k–256k (configurable via RoPE scaling) |
| Deployment targets | Cloud API only | Cloud, on-prem, edge, air-gapped |
| Time to first token | Minutes (API key) | Hours–days (infra + tuning) |
| Ops burden | Zero | Significant (capacity, kernels, upgrades) |
| Vendor lock-in | High (prompts, formats, features) | Low (weights portable, OpenAI-compat servers) |
Which to choose
Start with closed models if:
- You are pre-PMF and need to ship a working LLM feature this sprint.
- Volume is under 50M tokens/month and per-token economics don’t dominate.
- Your workflow needs reliable function calling, structured output, or vision/audio today.
- You lack GPU ops expertise and don’t want to hire for it.
- You need compliance artifacts (SOC2, HIPAA BAA) from the vendor.
Move to open models when:
- Token volume crosses the infrastructure crossover (typically 50–100M/month sustained).
- You need data residency, air-gapped deployment, or zero-retention guarantees the vendor won’t sign.
- Your differentiation requires fine-tuning on proprietary data — legal contracts, medical records, internal codebases.
- You need latency SLOs the public API cannot guarantee (sub-200ms p99 at scale).
- You want to distill a large closed model into a smaller, faster open model for a hot path.
Hybrid pattern (common at scale):
Route by task. Use closed models for planning, tool orchestration, and low-volume high-reasoning steps. Route high-volume, latency-sensitive, or data-sensitive completions to self-hosted 70B or 8B models. A gateway that supports per-request routing directives makes this practical without littering your application code with provider logic.
# Routing directive example (pseudo-code)
def route_request(messages, metadata):
if metadata.get("pii") or metadata.get("latency_critical"):
return "self-hosted-70b"
if requires_complex_reasoning(messages):
return "gpt-4o"
return "deepseek-v3"
The open source vs closed source llm choice is not binary. Most production systems end up hybrid within 12 months. Start with the closed API to validate product-market fit. Invest in self-hosted infrastructure when the economics, latency, or governance requirements force your hand — not before.