The Anthropic Messages API powers Claude integrations across countless applications. Mastering tool use cycles, prompt caching with cache_control, extended thinking, and the streaming event protocol is essential for building efficient, production-grade Claude applications.
0 / 5 completed
1 / 5
When calling the Anthropic Messages API, what is the role of the system parameter?
The system parameter in the Messages API sets the system prompt — a persistent set of instructions that the model follows throughout the conversation. It is processed separately from the messages array and is not attributed to the user or assistant.
2 / 5
You add cache_control: { type: 'ephemeral' } to a content block. What does this do?
cache_control with type: 'ephemeral' enables prompt caching. Anthropic caches the model's internal KV state up to that breakpoint. Subsequent requests that share the same prefix up to the breakpoint are served from cache, reducing input token billing and latency.
3 / 5
In tool use with the Claude SDK, after the model returns a tool_use block, what must you include in the next API call?
After receiving a tool_use block, you execute the tool locally and return the result as a user message containing a tool_result content block that references the tool_use_id. The model then continues its response with that information.
4 / 5
What does extended thinking allow Claude to do that standard inference does not?
Extended thinking lets Claude produce a thinking content block — a scratchpad of reasoning — before the final text response. This improves accuracy on complex problems. Thinking tokens are visible to the caller but are billed at a different rate.
5 / 5
When using the Anthropic SDK's streaming API, which event signals that the model has finished generating the complete response?
Anthropic's streaming protocol sends content_block_stop when each content block finishes, then message_stop after all blocks are complete and the full message is finalised. The message_delta event carries the stop_reason just before message_stop.