Integrating LLM APIs · LLM API Foundations
Choosing Models, Effort & Trade-offs
Capability vs latency vs cost; routing by task.
Providers offer tiers: frontier models (best reasoning, highest cost), balanced models, and small/fast models (classification, extraction, routing). Many current models also expose a reasoning effort control — higher effort thinks longer (better on hard problems, more tokens and latency). Start with the most capable model to establish a quality baseline, then measure cheaper models or lower effort on your eval set before downgrading routes. Keep model IDs in configuration, not scattered in code, so upgrades are one change plus an eval run.
Model tiers
| Criterion | Frontier / large | Balanced / mid | Small / fast |
|---|---|---|---|
| Reasoning & coding | Best | Strong | Basic |
| Latency | Highest | Medium | Lowest |
| Cost per token | Highest | Medium | Lowest |
| Typical tasks | Agents, complex analysis, code | High-volume assistants, drafting | Classification, extraction, routing |
| Effort/reasoning control | Tune per route | Tune per route | Usually low |
MODELS = { # one place to upgrade models
"agent": {"model": "claude-opus-5-5", "effort": "high"},
"summarize": {"model": "claude-opus-5-5", "effort": "low"},
"classify": {"model": "claude-haiku-5-5", "effort": "low"},
}
def call(route: str, **kwargs):
cfg = MODELS[route]
return client.messages.create(model=cfg["model"], output_config={"effort": cfg["effort"]}, **kwargs)
const MODELS = {
agent: { model: "claude-opus-5-5", effort: "high" },
classify: { model: "claude-haiku-5-5", effort: "low" },
} as const;
const r = await client.messages.create({
model: MODELS.classify.model, max_tokens: 256,
output_config: { effort: MODELS.classify.effort },
messages: [{ role: "user", content: `Classify sentiment: ${review}` }],
});
Common pitfalls
- Picking the cheapest model before measuring quality.
- Hard-coded model strings across the codebase.
- Comparing cost per request instead of cost per successfully completed task.
Key points
- Baseline with the best model, then measure cheaper options
- Route by task
- Model IDs in config
Further reading: Claude models overview
Practice questions
Why judge models by cost per completed task rather than cost per request?
Answer
A cheaper model that needs more retries, longer outputs or human fixes can cost more overall than a stronger model that succeeds first time.
What does a reasoning 'effort' setting trade off?
Answer
Higher effort lets the model reason more (better on hard tasks) at the cost of more tokens and latency; lower effort is faster and cheaper for simple tasks.
Open in the app to mark lessons complete, take notes and track your progress.