Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
Day 1 you commit to a provider (Anthropic, OpenAI, Google, or local via vLLM). Switching later is real engineering work — prompts behave differently, tool-calling APIs differ, costs differ. The right choice depends on: required model strength, cost sensitivity, latency targets, regulatory / on-prem needs, and whether the workflow benefits from features one provider has (Anthropic Citations, OpenAI Structured Outputs). Don't bikeshed; pick based on the use case.
Defaults in 2026: Anthropic for nuanced agentic + careful instruction-following. OpenAI for breadth of features (Realtime, Assistants, Batch). Google for cost at huge context (Gemini Pro 2M context). Local (vLLM + Llama / Qwen) for on-prem or extreme volume. Most teams start with one and add a second for fallback only when scale demands. Pinning a model version matters at all stages — never use 'latest'.
<100k users.Use these three in order. Each builds on the one before.
How do you pick an LLM provider on Day 1? Name 3 criteria.
Walk me through model version pinning vs latest. What goes wrong with auto-upgrade?
I'm choosing between Anthropic and OpenAI for a customer support agent. Walk me through the trade-offs in 2026.
# Pin your model. No 'latest'.
MODEL = "claude-sonnet-4-6" # specific version
# Wrap your provider so switching is one-file
class LLM:
def __init__(self, provider="anthropic"):
self.provider = provider
if provider == "anthropic":
from anthropic import Anthropic
self.client = Anthropic()
elif provider == "openai":
from openai import OpenAI
self.client = OpenAI()
def chat(self, model, system, messages, tools=None, max_tokens=800):
if self.provider == "anthropic":
r = self.client.messages.create(model=model, system=system, messages=messages, tools=tools or [], max_tokens=max_tokens)
return r.content[0].text, r.usage
if self.provider == "openai":
r = self.client.chat.completions.create(model=model, messages=[{"role": "system", "content": system}] + messages, tools=tools, max_tokens=max_tokens)
return r.choices[0].message.content, r.usage
llm = LLM(provider="anthropic")
# 6 months later when you want to A/B with another provider:
# - your wrapper makes it a config change, not a rewrite
# - your prompts may need tuning (they're not portable)
# - your tool schemas should already work (both Anthropic + OpenAI use JSON Schema)python3 main.py