Section 03 · Anthropic Academy — Building with the Claude API · Builder

Building with the Claude API

Message API, system vs user roles, tool use, structured output, prompt caching, few-shots as turns.

Learning objectives

  • Place an instruction correctly in the system vs the user role.
  • Format few-shot examples as alternating user / assistant turns.
  • Trace a tool-use loop using stop_reason to know when the model is done.
  • Place cache_control markers to maximise prompt-cache hits.
  • Pick tool-schema vs prompt-only structured output for a given task.