Important Technical Concepts
Independent educational resource, not an official Anthropic course. Facts about the API, prices and limits were checked against Anthropic's documentation on 15 November 2026 and the code was run against a local mock of the API, not the live service. Check the linked official pages before relying on a number, and test with your own key.
This lesson is the whole course on one revision sheet. For every area it gives you the ideas you should be able to explain without notes, and the trap that catches people. Nothing here is new. Each point comes from a lesson in Modules 1 to 8, with a link, and where a fact depends on current Anthropic documentation we say so, since models, limits and prices change. If a point doesn't make sense, that's your cue to reopen the lesson.
What you'll learn
- The core facts of each area, in a form you can recall under time pressure.
- The traps: the misconception behind each classic wrong answer.
- Where to go when a point is shaky.
Before you start
How to use this sheet
Read one section, close the page and say the points out loud, or write them. If you can't, you don't know them yet. Facts that depend on a particular model or a limit that changes often are marked check the docs: on an exam, and in real work, the principle matters and you look the number up.
1. The Messages API
- Three required fields:
model, max_tokens, messages. system is a separate top-level field (2.3).
- The API is stateless: your application stores and resends the conversation.
stop_reason tells you why it stopped: end_turn, max_tokens, stop_sequence, tool_use, pause_turn, refusal, model_context_window_exceeded (8.5).
- A refusal is HTTP 200, not an error.
max_tokens means possibly incomplete.
- Trap: using a parameter that older models accepted. Some current models reject prefilled assistant messages and extended-thinking settings with a 400 (check the docs for your model).
2. Tokens, context and models
- Tokens aren't words. You pay for input and output tokens, and counts vary by model (1.4).
- The context window is working memory. More context isn't automatically better: Anthropic describes accuracy and recall degrading as token count grows, which it calls context rot (1.5).
- Model choice trades capability, speed and price. Use small models for easy steps and larger ones for hard ones, and settle it with an evaluation (1.8). Check the docs for the current lineup and prices.
- Trap: asking for a word count. Ask for sentences or paragraphs.
3. Prompts
- A system prompt sets role and rules. The user turn carries the task and data (1.6).
- Separate instructions from data, with labels or XML tags (3.5).
- Few-shot examples teach format and behaviour. Make them varied (3.4).
- A prompt is a request, not a guarantee. What must always hold is enforced in code.
4. Structured output and validation
- Request a JSON schema with
output_config.format. Unsupported schema features return a 400; check stop_reason first (8.5).
- A schema checks shape, not truth. Add business rules and grounding checks, repair once, then hand to a person.
5. Errors, retries and reliability
- Retry timeouts, 429 rate limits, 500 and 529. Don't retry 400, 401, 403 or 404 (8.8).
- Three kinds of 429: ordinary rate limit (use
retry-after), ramp limit (ramp_limit_exceeded) and tier spend cap (enforced_spend_limit_reached, no retry-after, don't retry).
- The SDK retries twice by default, honouring
retry-after. Keep one retry layer.
- Backoff with jitter, a fallback model, a circuit breaker. Idempotent side effects.
- Request ID:
request-id header, request_id in error bodies, _request_id in the Python SDK.
6. Cost and performance
- Total input =
cache_read_input_tokens + cache_creation_input_tokens + input_tokens (8.10).
- Prompt caching: tools, then system, then messages; exact match; up to four breakpoints; default five-minute lifetime; writes cost more than base input, reads much less (standard 1.25x or 2x, and 0.1x; check the docs for per-model exceptions). Zero in both cache usage fields means nothing was cached.
- Cache reads don't count toward the input-tokens-per-minute limit.
- Batches: 50 percent of standard prices, up to 100,000 requests or 256 MB, finish within 24 hours or expire, results kept 29 days, match on
custom_id.
- Streaming improves time to first token, not total time (8.9).
- Trap: assuming caching always saves money. A write costs more than a normal read.
7. Tool use
- The loop: model returns
tool_use, you run it, you reply with tool_result blocks in one user message, each with the matching tool_use_id, until a different stop reason (4.2).
- Errors go back as results with
is_error, with messages the model can act on. Cap iterations.
- Some models reject forced
tool_choice (any or tool); use auto plus strict tool use or structured outputs (check the docs).
- Identity comes from your trusted context, never from a model-supplied argument (4.8).
8. Agents and workflows
- Workflow: your code decides the steps. Agent: the model decides dynamically (6.1).
- Five workflow patterns: prompt chaining, routing, parallelization (sectioning and voting), orchestrator-workers and evaluator-optimizer (6.3).
- Bound the loop: iterations, tokens, time, tool calls. Return a status, not an exception (6.4).
- Validate plans as untrusted input; re-plan only the remaining work (6.5).
- Write tools that are few, clear and permissioned; read versus write; approvals outside the conversation (6.9).
- Multi-agent costs far more (Anthropic reported about 4x for agents and 15x for multi-agent systems on its research workload); use it for high-value, parallel work with detailed briefs.
9. MCP
- Host, client (one per server), server. Tools (model), resources (application), prompts (user) (7.2).
- Transports: stdio (local, never write to stdout) and Streamable HTTP (remote). The current protocol is stateless, with per-request metadata.
- Tool failures:
isError results the model can act on, versus protocol errors. Annotations are untrusted hints.
- Messages API connector: beta, tools only, remote HTTP servers only. Claude Code scopes: local, project (
.mcp.json), user.
- Security: no token passthrough, SSRF protection, least privilege, treat results as data (7.9).
10. Claude Code
CLAUDE.md is context, not enforcement; keep it short. Skills load their body only when used (5.4, 5.6).
- Permissions (allow, ask, deny) and hooks enforce. A PreToolUse hook exiting with 2 blocks the call (5.7).
- Subagents start with a fresh context (5.8). Manage context with
/context, /compact, /clear.
11. Security
- Two kinds of injection: direct (user is the attacker) and indirect (content the model reads).
- Defences stack: label and JSON-encode untrusted text, state the policy, least privilege, screen with a small model (a refusal is a positive verdict), validate output, put a person in front of consequences, red-team (8.3).
- Keys live on the server, in the environment. Authenticate your own API.
12. Evaluation and operations
- Specific, measurable success criteria. Many automatically graded, tagged cases. Different model for the judge. Errors count as failures. Gate releases on a baseline (8.6).
- Logs without customer text; metrics: error rate, p95, cost, cache hit rate, "needs a person" rate (8.7).
- Liveness doesn't call the model; readiness does reflect it. Kill switch. Shadow, assisted, canary, full (8.11).
Real-world use case (illustrative scenario)
This scenario is an invented example to show how the ideas fit together. It is not a case study and its details are not measured results.
A developer prints this sheet and turns each bullet into a question for a friend: "what are the three kinds of 429?", "where does a tool result go?", "what's wrong with a mock that's always cached?". The bullets they can't answer in ten seconds go on a separate list, and the next day's reading is exactly that list.
Mistakes to avoid
- Memorising numbers without the reason they exist. Know the principle and check the figure.
- Treating "check the docs" items as stable facts.
- Reading the sheet as a substitute for the lessons.
- Skipping the traps, which are where the wrong options come from.
Security notes
If a revision point is about security, such as keys, injection or approvals, answer it from the viewpoint of "what's the worst thing that could happen, and what's the cheapest control against it?". That framing resolves a surprising number of questions.
Cost and speed
This sheet takes twenty minutes to read and is meant to be reread several times. Several short passes beat one long one.
Key takeaways
- Know the loop, the limits and the reasons: stop reasons, retry rules, cache rules and the tool loop.
- For everything model-specific, know that it changes and where to check.
- Enforcement beats instruction: code, permissions and hooks, not hopes in a prompt.
- Defences stack, and a person guards consequences.
Lesson recap: know the loop, enforce rather than ask, and stack defences with a person at the end.
Quick quiz
- Which three request fields are required by the Messages API?
- What are the three kinds of 429 and which should not be retried?
- In MCP, which primitive does the model control?
- Why is CLAUDE.md the wrong place for a rule that must never be broken?
- Give two things a JSON schema cannot check.
Answers and explanations
model, max_tokens and messages.
- An ordinary rate limit (retry after the delay), a ramp limit (hold traffic steady and ramp up gradually) and the tier spend cap (do not retry; it has no
retry-after).
- Tools. Resources are application-controlled and prompts are user-controlled.
- It's delivered as context, not enforced. A hook or a permission deny rule enforces.
- For example, whether an order exists, or whether a promise breaks a business rule. A schema checks shape, not truth or policy.
Official references and further reading
Related tutorials