Model Selection and Optimization
16.8% of examUnderstand how LLMs actually work (tokens, context, sampling, non-determinism), how SDKs relate to the underlying REST API, and how to choose among Claude's model tiers and cost/latency levers -- caching and batching -- to run applications economically.
6
task statements
14
concepts
54
practice questions
Domain Mastery
Explain tokens, context windows, and autoregressive generation
Understanding how text is tokenized, how the context window bounds and shares capacity across a request, and how an LLM generates output one token at a time.
Knowledge of
- Tokens as the unit of text (roughly 3-4 characters of English) that limits and billing are measured in, not characters or words
- Autoregressive next-token generation: the model repeatedly predicts the next token given everything so far, appends it, and continues until a stop condition
- The context window as the maximum number of tokens (input + output) the model can consider at once
- The context window as a shared budget across the system prompt, conversation history, tool definitions, tool results, and the response
- The consequence of exceeding the context window: the request fails or content must be truncated/summarized
Skills in
- Estimating token counts for text rather than reasoning in characters or words
- Explaining model output as a sequence of next-token predictions rather than a single lookup
- Reasoning about context-window limits as a shared budget across every component of a request, not a per-component allowance
- Anticipating request failure or the need for truncation/summarization when a request would exceed the context window
Concepts
Tokens & Autoregressive Next-Token Generation
✎CoreA token is roughly 3-4 characters of English; limits and billing are measured in tokens, not characters or words
The Context Window as a Shared Token Budget
✎CoreThe context window is the max tokens (input + output combined) a model can consider in one request
Reason about sampling, non-determinism, thinking modes, and prompting fundamentals
Understanding temperature and sampling-driven non-determinism, the compute/quality tradeoff of extended and adaptive thinking, and the zero-shot/one-shot/few-shot spectrum of example-based prompting.
Knowledge of
- Sampling from a probability distribution as the mechanism of generation, with temperature controlling how focused vs. diverse that sampling is
- That LLMs remain non-deterministic even at temperature 0 -- lower temperature reduces randomness but does not guarantee identical output
- Extended thinking as an explicit reasoning budget spent before answering, and adaptive thinking/effort levels as the model varying reasoning depth by difficulty
- That thinking modes trade billed output tokens and latency for better quality on hard tasks -- they are not free
- Zero-shot, one-shot/single-shot, and multi-shot/few-shot as the fundamental spectrum of example-based prompting, and what adding examples costs
Skills in
- Choosing temperature to reduce output variance while recognizing exact reproducibility is never guaranteed
- Testing LLM-backed systems with evals rather than equality assertions, because of inherent non-determinism
- Deciding when a task's difficulty justifies the added tokens/latency of extended or adaptive thinking
- Selecting zero-shot, one-shot, or few-shot prompting based on how much the task benefits from examples versus the added input-token cost
Concepts
Sampling, Temperature & Non-Determinism
✎CoreGeneration samples from a probability distribution at each token step rather than deterministically selecting one answer
Extended & Adaptive Thinking as a Compute/Quality Lever
✎CoreExtended thinking is an explicit reasoning budget spent before answering; adaptive thinking/effort levels vary reasoning depth by task difficulty automatically
Zero-Shot, One-Shot, and Few-Shot: The Example-Count Spectrum
✎CoreZero-shot = instruction only; one-shot = instruction plus one worked example; multi-shot/few-shot = instruction plus several worked examples
Distinguish SDKs from raw REST and sync/async/streaming transport
Understanding the official SDKs as a convenience layer over the REST API, when to use async clients, and how streaming/websocket transport delivers tokens without changing token cost.
Knowledge of
- The official Python and TypeScript SDKs as a convenience layer over the REST API handling auth, serialization, typed errors, retries, and streaming
- That the SDK can always be bypassed in favor of raw HTTPS + JSON calls to the same underlying API
- Sync vs. async clients, and async as the way to parallelize independent, I/O-bound calls
- Streaming via persistent event streams (server-sent events) as the mechanism for incremental token delivery
- That streaming/websocket transport is a delivery-mechanism concern, not a token-cost concern
Skills in
- Choosing between the SDK and raw REST calls based on whether the convenience layer's handling (retries, typed errors, streaming helpers) is needed
- Using an async client to parallelize independent, I/O-bound requests rather than serializing them
- Recognizing streaming/websocket choices as changing how tokens are delivered, not how many tokens are billed
Concepts
SDKs as a Convenience Layer Over REST
✎CoreThe official SDKs (Python, TypeScript) are a convenience layer over the REST API -- handling auth, serialization, typed errors, retries, and streaming
Streaming & Websocket Transport vs. Token Cost
✎CoreStreaming delivers tokens incrementally via a persistent event stream (typically server-sent events), improving time-to-first-token
Select among Claude model tiers against quality/latency/cost tradeoffs
Choosing between Haiku, Sonnet, and Opus by right-sizing capability to task difficulty, and designing mixed-model workflows and safe model-version upgrades.
Knowledge of
- The three model tiers -- Haiku (fastest/cheapest/lightest), Sonnet (balanced workhorse), Opus (most capable, highest cost/latency) -- and their typical task fit
- Right-sizing: matching model capability to task difficulty and value rather than defaulting to the most capable tier
- The quality vs. latency vs. cost tradeoff triangle as the frame for model choice
- Mixed-model architectures that route cheap steps to Haiku and hard steps to Opus/Sonnet within one workflow
- The risk of breaking behavior changes across model releases, and re-running evals with a pinned version before upgrading
Skills in
- Matching model tier to task difficulty and value instead of defaulting to the most capable model available
- Designing mixed-model workflows that assign each step to the tier fitting its difficulty/cost/latency profile
- Factoring adaptive-thinking support into tier selection when a workflow step needs that capability
- Re-running evaluations against a pinned model version before adopting a new release
Concepts
Haiku, Sonnet, Opus & the Quality/Latency/Cost Triangle
✎CoreHaiku = fastest/cheapest for high-volume simple tasks; Sonnet = balanced workhorse; Opus = most capable for hard reasoning/high-value work
Model-Version Pinning & Eval-Gated Upgrades
✓AdvancedA newer model release can change behavior in ways that break prompts tuned for an older version, even with an unchanged API contract
The Orchestrator-Worker Cost Multiplier: ~15x Tokens for a Real Quality Gain
✎CoreAnthropic's internal multi-agent research found an Opus-lead/Sonnet-subagent orchestrator-worker architecture showed a substantial quality improvement over a single-agent Opus baseline on a research task -- at roughly 15x the tokens of a normal single-agent chat interaction
Model token cost and track usage
Modeling cost as tokens times per-token price across input, output, and cache rates, and instrumenting the usage field to monitor spend.
Knowledge of
- That input and output tokens are priced differently, with output tokens typically more expensive than input tokens
- Separate cache write/read rates as part of the overall per-token pricing structure
- Cost modeling as estimating tokens times per-token price across expected traffic
- The usage field on every response (input/output/cache tokens) as the mechanism for tracking actual cost and detecting bloat
- Capping max_tokens to a realistic output length as a lever to avoid paying for runaway generations
Skills in
- Modeling expected cost by estimating token volume per request type times the applicable per-token rate
- Instrumenting the usage field on responses to monitor real spend and catch unexpectedly large requests
- Setting max_tokens to a realistic ceiling rather than leaving it unbounded
Concepts
Token Pricing, Cost Modeling & the Usage Field
✎CoreInput and output tokens are priced differently; output tokens are typically more expensive than input tokens
The count_tokens Endpoint: Checking Size Before You Spend
✎Corecount_tokens is a dedicated endpoint that accepts the same request body as a real messages call but returns only a token count -- no inference is run
Reduce cost and latency with prompt caching and the Message Batches API
Using prompt caching and cache checkpointing to discount reused stable prefixes, and the Message Batches API to cut per-token cost on latency-tolerant bulk jobs.
Knowledge of
- Prompt caching: caching a stable, reused prefix (system prompt, long documents, tool definitions) with cache_control so it's discounted on reuse
- That cache reads are heavily discounted versus normal input tokens, while a cache write costs slightly more than a normal input token
- Cache checkpointing as caching at multiple points in a growing, incrementally-extended prompt so it stays mostly cached
- The Message Batches API's roughly 50% per-token discount for latency-tolerant bulk jobs processed within 24 hours
- That batching reduces cost, not latency -- it is slower by design, unlike caching or right-sizing the model, which reduce latency
Skills in
- Applying cache_control to a large, stable, reused prefix rather than truncating it to save tokens
- Using cache checkpointing to keep a long, growing prompt mostly cached as it's incrementally extended
- Routing latency-tolerant, high-volume jobs to the Message Batches API for the per-token discount
- Distinguishing cost levers (batching, caching) from latency levers (caching, smaller models, trimmed context) when optimizing a workflow
Concepts
Prompt Caching & Cache Checkpointing
✎CoreA cache_control field of type "ephemeral" on a content block marks a breakpoint; up to 4 breakpoints are allowed per request
Message Batches API: Cost Discount Without Latency Improvement
✎CoreThe Message Batches API gives a roughly 50% per-token discount for asynchronous jobs completed within 24 hours