Skip to content
MLA 014 Deploying ML in 2026: APIs vs Self-Hosting episode artwork

Jan 18, 2021 32 min

MLA 014 Deploying ML in 2026: APIs vs Self-Hosting

from Machine Learning Guide

Hosting and deploying ML in 2026 starts with an API: move to serverless GPUs, rented GPUs or Spot only when volume, compliance, latency or model availability forces it. Also covers cold starts, vLLM vs SGLang vs llama.cpp vs Ollama, quantization, batch and caching discounts, and tracing. Links Notes and resources at ocdevel.com/mlg/mla-14 Join the free MLG group: listen to my other AI shows, ask me questions, and talk with other listeners Should I self-host an LLM or call an API? Call an API until one of four things applies: sustained volume, a compliance rule, a latency floor, or a model that exists only as weights. Then move that one workload. Volume break-even against a per-token host serving the same open model: tokens/sec needed = GPU $ per hour ÷ hosted $ per 1M tokens × 1,000,000 ÷ 3,600 $4.00/h ÷ $0.50 per 1M → ~2,200 output tokens/sec, around the clock Middle path: Bedrock Custom Model Import serves fine-tuned Llama, Mistral, Qwen or gpt-oss weights per Custom Model Unit-minute, billed in 5-minute windows. No batch inference. SOC 2, HIPAA and GDPR Use the cloud you're already certified on: Bedrock (HIPAA-eligible; model providers never see your prompts), Gemini Enterprise Agent Platform (formerly Vertex AI) or Microsoft Foundry. Self-host when a contract rules those out. Cost per 1,000 requests API: tokens × price. 2,000 in + 500 out at $1/$5 per 1M = $4.50; batch halves it. Serverless GPU: GPU-seconds × rate. 4 s on an L4 at $0.000222/s ≈ $0.89, plus cold starts. Dedicated GPU: hourly price ÷ requests served per hour. What is serverless GPU, and who's cheapest? A GPU container per request, billed per second, scaling to zero. H100 list prices, November 2026: Modal: $3.95/h serverless (L4 $0.80/h) RunPod: $5.89/h serverless; pods $2.69/h community, $4.39/h secure Baseten dedicated $6.50/h; Fireworks on-demand $8/h Cloud Run GPU: L4 and RTX PRO 6000, instance-based billing For popular open models, per-token hosts beat rented GPUs until volume flips it. Does AWS have serverless GPU? No: Lambda, Fargate and SageMaker Serverless Inference are CPU-only. Use SageMaker asynchronous inference, AWS Batch, or Bedrock Custom Model Import. Serverless GPU cold starts Container boot (~1 s on Modal, ~5 s on Cloud Run) → weight download → engine startup. A 3B model on vLLM took ~118 s cold and ~12 s from a GPU memory snapshot. Fixes, cheapest first: queue the work → keep weights near → smaller or quantized model → snapshots → one warm container. Serverless vs dedicated GPU break-even utilization = always-on $ per hour ÷ serverless $ per hour Under ~50% busy, serverless; over ~75%, rent. Spot instance interruptions Up to 90% off, with a two-minute notice. Checkpoint to S3 → retry on host termination → many instance pools, price-capacity-optimized. GPU memory: can I run Flux on an L4? weights (GB) ≈ parameters (billions) × bytes per weight (16-bit 2, 8-bit 1, 4-bit 0.5) On a 24 GB L4, FLUX.2 klein (4B, ~13 GB) fits. FLUX.1 dev (12B, 24 GB at 16-bit) needs 8-bit or offloading. Model choice: MLA 25. vLLM vs SGLang vs llama.cpp vs Ollama vLLM: many users on GPUs, OpenAI- and Anthropic-compatible. v0.33 ships CUDA 13 builds only. SGLang: agents and long shared prefixes. llama.cpp: CPUs, Macs and edge devices; v1.0 shipped November 13, 2026. Ollama: a laptop (MLA 22 covers local coding models). When is quantization free? Eight-bit is near lossless; four-bit weights rivaled it in Give Me BF16 or Give Me Death. Test four-bit on your own task and hardware; on some CPUs it runs slower than eight-bit. Batch API and prompt caching discounts Batch costs 50% of standard at OpenAI, Anthropic, Google, Bedrock and Fireworks; OpenAI, Google and Bedrock sell a flex tier at the same price. Cache reads bill at 10% of input, 5% on several current models, and 2.5% on Claude Fable 5.2. LLM tracing tools Langfuse (MIT core, self-hostable), Arize Phoenix (Elastic License), LangSmith, Braintrust, Helicone (gateway). Evaluation methods: MLA 28. The full course on this topic is Gnothi's Learn AI, next to the Agentic AI Course, at ocdevel.com/courses. More in the resources. Next: MLA 28, on how agents are built.

Episode details come from the podcast's RSS feed.

Embed this episode

Ready to play

MLA 014 Deploying ML in 2026: APIs vs Self-Hosting

0:00 32:32

No transcript yet.

Requests help us decide what to transcribe next.

Frequently asked questions

How long is this episode of Machine Learning Guide?

This episode is 32 minutes long.

When was this Machine Learning Guide episode published?

This episode was published on January 18, 2021.

Can I download this Machine Learning Guide episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.