Choosing an LLM API
Read a little, play a little. No scary maths, and no rush.
Last reviewed: October 2026 · report an issue
The one-line verdict
For your first app it barely matters: pick whoever has the clearest quickstart and a free tier today — OpenAI, Anthropic, or Gemini. What matters is keeping your code portable so switching costs an afternoon, not a rewrite.
Compare on these axes (check current pages — they move fast)
- Price per 1M input/output tokens — output tokens cost more everywhere.
- Rate limits on the free/tier-1 plan — prototypes die on 429s, not on quality.
- Structured output support — JSON mode keeps apps parseable.
- Context window you actually need — RAG with top-K=4 rarely needs the max.
Stay portable: one wrapper
def chat(messages, model="first-pick"):
# OpenAI-compatible shape; Anthropic/Gemini map onto it
return client.chat.completions.create(
model=model, messages=messages, temperature=0.2,
).choices[0].message.content
Evaluate all three on your own 10-question golden set (see Evals Basics), then commit. Re-run the set whenever you switch — 30 minutes that saves weeks of vibes-based regret.
A worked comparison
A team builds a 10-question golden set from their real use case and runs it through a small, inexpensive model from each of three providers, A, B, and C, using the same wrapper and the same prompt.
For each run they record three things: how many answers were correct and well formatted, the typical latency to the first token, and the estimated cost per 1,000 questions at current prices. Suppose A and B both score 9 out of 10, B is noticeably faster, and A is a little cheaper. The choice now depends on what this product values, and it is a choice made from evidence, in about an hour. Rerun the set every few months; the ranking really does change.
Things that bite later
Price and quality are the obvious axes. These cause trouble later if nobody checks them early:
- Data handling: whether API inputs are retained, for how long, and whether they are ever used for training. Read the current policy rather than assuming.
- Data location: some customers or regulations require data to stay in a particular region.
- Model retirement: providers retire older models on a schedule, so plan for regular migrations, which is one more reason to keep the wrapper and the golden set.
- Reliability: check the provider's status history, and how its rate limits grow as you move up usage tiers.
Open-weight models
Some models can be downloaded and run on your own infrastructure, or through hosting services that run them for you. That gives control over data and costs at high volume, in exchange for operational work and, often, a capability gap at the very top end. The same wrapper and golden set let you compare them fairly against the hosted APIs.
The switching drill (practice it once)
Point your wrapper at provider B, replay the golden set, compare quality, cost, and latency side by side. If B wins, flip the default model string and monitor for a week. Teams that rehearse switching never fear it — and vendors can smell fear in contract season.
Using more than one
Many production systems use several providers on purpose: a cheap model for simple requests, a stronger one for hard cases, and a second provider as a fallback when the first is down. The thin wrapper is what makes this a configuration change rather than a project.
Check your understanding
5 questions · first-try answers earn the most XP
My notes
Saved in this browser. Highlight a line above and save it, or write it in your own words.
Nothing saved yet. Your highlights will live here.
References
Finished reading?
Ticking it here also ticks the chapter in the sidebar, the section count and your streak — it is all one number.
Related chapters
Spotted a mistake or want a topic covered? Report an issue