Task quality
Does the answer meet the task’s own standard? Measure accuracy, source fidelity, rubric score, or executable tests. Fluent language is not evidence of correctness.
A provider is not a single model. Choose a versioned model family for a specific task, budget, and risk level.
Chat interfaces are only one surface over model APIs, tools, and serving infrastructure.
Product names and aliases move. A deployment must record the exact model ID or pinned snapshot.
All LLMs generate tokens. Reasoning-capable models usually spend more inference-time effort on difficult tasks—trading latency and cost for potential task improvement.
mini · nano · Haiku · Flash-Lite
High-volume routing, tagging, simple extraction, well-defined transforms.
general-purpose GPT · Sonnet · Flash
Document work, structured drafting, ordinary coding, general chat.
Pro · Opus · reasoning / thinking variants
Difficult debugging, planning, constraint-heavy and multi-step tasks.
Use task evidence—not fluent demos or a generic leaderboard—to decide whether escalation is justified.
Record model ID, date, prompt version, tool state, temperature, tokens, latency, cost, and rubric result. A benchmark score is not a workflow evaluation.
Use pinned, currently available model IDs in code. Keep keys in environment variables or a secret manager.
from openai import OpenAI client = OpenAI() r = client.responses.create( model="<MODEL_ID>", input="Extract outcomes as JSON." ) print(r.output_text)
from anthropic import Anthropic
client = Anthropic()
r = client.messages.create(
model="<MODEL_ID>",
max_tokens=1024,
messages=[{"role":"user",
"content":"Extract outcomes as JSON."}]
)
print(r.content[0].text)
from google import genai client = genai.Client() r = client.models.generate_content( model="<MODEL_ID>", contents="Extract outcomes as JSON." ) print(r.text)
Prompt contract, structured-output requirement, validation, retry policy, logging, and evaluation.
The API call is the smallest part of a reliable system.
from huggingface_hub import InferenceClient
client = InferenceClient(api_key="<HF_TOKEN>")
r = client.chat.completions.create(
model="<MODEL_ID>",
messages=[{"role":"user",
"content":"Extract outcomes as JSON."}]
)
ollama run <MODEL_TAG>
curl http://localhost:11434/api/chat \
-d '{"model":"<MODEL_TAG>",
"messages":[{"role":"user",
"content":"Extract outcomes as JSON."}],
"stream":false}'
vllm serve <HUGGING_FACE_MODEL_ID> # client base URL: http://localhost:8000/v1
Licence · model card · exact revision · quantisation · local/cloud data path · authentication · runtime version.
The model, request parameters, tools, and output contract together determine what the system can do.
These settings alter the candidate distribution at each generation step. Tune deliberately; many providers recommend changing one sampling control at a time.
config = {
"max_output_tokens": 800,
"temperature": 0.2,
"seed": 42,
"response_schema": OUTCOME_SCHEMA,
}
Does the answer meet the task’s own standard? Measure accuracy, source fidelity, rubric score, or executable tests. Fluent language is not evidence of correctness.
Does the workflow behave predictably across ordinary and edge cases? Check valid-schema rate, variance across runs, and whether it abstains or routes uncertainty correctly.
Can the system sustain real use? Measure p50/p95 latency, cost per accepted result, and throughput against the application’s budget—not an ideal demo.
Does it stay within the data boundary and resist untrusted instructions? Test injection resilience, auditability, and the application’s controls around consequential actions.
Can intended users understand and use the result? Evaluate language quality, multilingual performance, accessibility, and the human-review burden the system creates.
We now turn a selected model into a production component: APIs, SDKs, prompt assembly, structured validation, retrieval, tools, and fallbacks.
Open Chapter 05 →