// REF. 15 / LANGUAGE MODELS
LLM cheat sheet
Prompting and the API patterns around it, as the model vendors document them in October 2026: what goes in a prompt, the tool-call loop, schema-constrained output, caching, agents, evals, and the knobs that cost money. Field names follow the Messages API; the ideas port to any provider.
Two habits that pay for themselves: put the long document first and the question last, and treat anything that comes back from a tool as data, never as instructions.
↓ Download the printable PDF free · letter size · no email needed
Prompt anatomy
system prompt- role + rules; stable across turns
task- one clear ask; say what, not how
context- the docs and data the model needs
examples- 3-5, each wrapped in example tags
format- state the shape: json, bullets, length
Techniques
be direct- say what to do, not what to avoid
few-shot- worked examples steer format and tone
xml tags- delimit instructions, context, input
role- one sentence in the system prompt
general over steps- 'think thoroughly' beats a step list
chain prompts- split big tasks into sequential calls
prefill- gone on current models; use a schema
Context
context window- input + output must fit; count it
context rot- more tokens, worse recall; curate
long docs first- document on top, question at the end
cache_control- ephemeral breakpoint on a stable prefix
prefix order- tools, system, messages; edits break after
cache_read_input_tokens- zero on repeat? something is volatile
count_tokens- estimate before sending; read usage after
Tools
tool definition- name, description, input_schema
stop_reason: tool_use- run the call, send the result back
tool_result- by tool_use_id; is_error: true on fail
parallel calls- run all; return all results in one turn
strict: true- inputs guaranteed to match the schema
untrusted content- goes inside tool_result, nowhere else
Structured output
output_config.format- type json_schema; valid json back
additionalProperties- must be false on every object
required- required fields come first, in order
enum- compare case-insensitively
check stop_reason- refusal or max_tokens: don't parse
Agents
the loop- plan, act (tool), observe, repeat
stop condition- end_turn, step cap, budget, or a human
stop_reason: max_tokens- truncated; raise the cap or stream
MCP- open protocol for tool servers
least privilege- narrow tools, sandbox, confirm deletes
compaction- summarize old turns to keep going
Evals
golden set- labeled inputs mirroring real traffic
code grading- exact match, regex, tests: cheapest
llm-as-judge- rubric + scale; use a different model
regression- rerun the set on every prompt change
volume over polish- many auto-graded cases beat a few
Cost & limits
max_tokens- hard output cap; too low truncates
effort- low to max: reasoning depth vs spend
stream: true- sse events; required for long outputs
batches- async, half price, done within 24h
429 + retry-after- wait that many seconds; rpm, itpm, otpm
cache reads- about a tenth the price; writes 1.25x
Here be dragons
prompt injection- text that reads like orders; it's data
hallucinated citations- check every url and quote exists
you're absolutely right- sycophancy; ask it to push back
json in a code fence- strip the fence or use a schema
// KEEP IT UNDER YOUR KEYBOARD
LLM Field Manual Desk Mat
from $34 · printed to order in the USA