Skip to lesson

AnthropicClaude Certified Architect – Professional2026-100 Prerequisites

Make Messages an explicit service contract

Completed by the knowledge check

Learning objective

Read Messages API requests and responses: system prompts, roles, content blocks, stop reasons, and usage fields.

Core idea

The Messages API exchanges typed content and requires the application to supply conversational history on each stateless call. At Professional level, the decision is who owns the request and response contract so that a model response cannot silently become a completed business operation.

Your service needs distinct owners for context assembly, response interpretation, and business acceptance. A display adapter that extracts text cannot take over the other two responsibilities merely because the API returned successfully.

How it works

Read a Messages exchange as a set of responsibilities. The following fields identify the relevant boundaries:

BoundaryFields to inspectArchitectural responsibility
Request assemblymodel, max_tokens, top-level system, messagesSelect the model, set instructions, and assemble the intended history and evidence.
Conversation structurerole, content, block typePreserve speaker identity and typed content separately from display text.
Response interpretationid, model, content, stop_reasonIdentify the generated message and decide what processing remains.
Resource accountingusage.input_tokens, usage.output_tokens, cache fieldsRecord consumed tokens independently of visible answer length.

The conversation record preserves message role and content-block type; rendered text is a view of that record. Assign the instruction contract to the prompt owner (see 2.2.1), the tool protocol to its executor (see 0.4), and the separation of inference from execution to the service architecture (see 1.2.2).

Interpret stop_reason before accepting a result. end_turn means generation ended naturally, not that a business rule passed. tool_use means tool processing remains; max_tokens means the output reached its generation limit. For a truncated response, raise the allowance or use the documented continuation approach rather than accepting a partial answer. The other stop reasons distinguish interruption paths your adapter must handle:

Stop reasonCauseResponse action
stop_sequenceClaude generated one of your stop_sequences.Read stop_sequence to identify which sequence fired.
pause_turnA server-tool loop reached its iteration limit.Send the assistant content back to continue.
refusalClaude declined to respond.Read stop_details and retry on a fallback model.
model_context_window_exceededThe response filled the model’s context window.Treat the response as truncated.

See 1.2.3 for result validation and 4.6.1 for recording stop reasons.

For accounting, total input is input_tokens + cache_creation_input_tokens + cache_read_input_tokens. The cached portions still occupy context. API token accounting does not map one-to-one to visible text; preserve usage rather than estimating consumption from rendered characters. See 4.5.1 for cost baselines and 2.4.3 for long-history management.

Key distinctions and trade-offs

Keeping structured content lets the executor interpret blocks and the interface render text from the same record. Flattening early simplifies display but loses information those consumers need. Likewise, an HTTP success establishes successful API processing, while stop_reason and semantic validation answer different completion questions.

Architecture / decision scenario

A healthcare provider pilots a policy-answering assistant with a three-second response target. Clinical reviewers approve explanations before staff act on them; the assistant has no authority to change patient records.

You assign the integration team the initial system, role-preserving history, and full content record. The adapter routes blocks by type, checks stop_reason, and sends naturally completed explanations to the review queue. A max_tokens response remains incomplete and uses the documented recovery path. A refusal enters the approved fallback path after the adapter inspects stop_details; any resulting explanation still needs clinical review. The cost dashboard includes cache token fields, so the team can compare reuse savings without claiming that cached policies disappear from context.

Common exam traps

Watch for these contract errors:

  • Treating pause_turn as a failed request instead of a continuation point.
  • Reading end_turn as proof of business acceptance.
  • Counting only usage.input_tokens when cached input is present.

What to remember

Assign owners to assembly, interpretation, and acceptance. Preserve typed content, check why generation stopped, and retain complete usage accounting before a response becomes a business outcome.

Knowledge check

References