Claude API Essentials
Learn the Anthropic API from first principles. Covers the Messages API, tool use, streaming, structured outputs, extended thinking, and cost optimization.
Steps
- Introduction to the Anthropic Platform
anthropic-platform
beginner
Overview of the Anthropic API platform, Claude models, and what you can build.
This page orients you to the Anthropic platform and its key concepts. Skim it to understand the product landscape — the important technical details come in subsequent steps.
- Get Started
anthropic-platform
beginner
API key setup, first API call, and quickstart for the Anthropic platform.
Get your API key and make your first request. Pay attention to the SDK installation and how the Messages API is structured — this request format is what you will use for everything that follows.
- Overview
anthropic-platform
beginner
Understanding the model lineup (Haiku, Sonnet, Opus) and their cost/capability tradeoffs is essential for production decisions. Choosing the wrong model tier is the most common source of unnecessary API spend.
- Build with Claude — Overview
anthropic-platform
beginner
Central hub for understanding how to build applications with the Claude API.
This page covers the conceptual foundations of building with Claude, including how the API processes requests. Read it to understand the mental model before diving into specific features like tool use and streaming.
- Working With Messages
anthropic-platform
beginner
The Messages API is the core primitive — understand message roles, content blocks, and conversation structure.
The Messages API is the only API you need — Anthropic has a single endpoint for all interactions. Focus on how the messages array works and how system prompts differ from user/assistant turns, as this structure underpins every other feature.
- Streaming
anthropic-platform
intermediate
Server-sent events (SSE) streaming for real-time token delivery and responsive UIs.
Streaming uses server-sent events to deliver tokens in real time. Understanding the event types (content_block_start, content_block_delta, message_stop) is essential for building responsive UIs — and for handling tool use during streaming.
- Tool Use — Overview
anthropic-platform
beginner
How Claude calls external tools and functions — the foundation for building agentic systems.
Tool use is how you let Claude call your functions. Anthropic calls it 'tool use' while OpenAI calls it 'function calling' — the concepts are equivalent but the request/response format differs, particularly in how results flow back.
- Implement Tool Use
anthropic-platform
intermediate
Step-by-step guide to implementing the tool use loop: define tools, handle tool_use responses, send tool_result.
This is the hands-on implementation guide. Pay close attention to the tool result message format — you must send results back as a user message with tool_result content blocks, which is different from OpenAI's dedicated tool role.
- Structured Outputs
anthropic-platform
intermediate
Get reliable JSON outputs from Claude using tool_use or constrained decoding.
Anthropic achieves structured output by combining tool use with a single-tool-choice constraint. This is architecturally different from OpenAI's native JSON Schema enforcement — understand the tradeoff between flexibility and strictness.
- Extended Thinking
anthropic-platform
intermediate
Enable Claude's chain-of-thought reasoning for complex problems that benefit from step-by-step analysis.
Extended thinking lets Claude show its reasoning chain before answering. This is Anthropic's alternative to OpenAI's o-series reasoning models — it gives you visibility into the reasoning process and dramatically improves complex problem solving.
- Vision
anthropic-platform
intermediate
Send images to Claude for analysis, OCR, diagram interpretation, and multimodal reasoning.
Claude can analyze images passed as base64 or URLs in the messages array. Token costs scale with image size — use the detail parameter to control resolution and cost, especially when processing many images in batch.
- Prompt Caching
anthropic-platform
intermediate
Cache system prompts and repeated context to reduce latency and costs by up to 90%.
Prompt caching gives you 90% cost reduction on cached prefixes. Unlike OpenAI's automatic caching, Anthropic requires explicit cache_control markers — place them strategically on your system prompt and few-shot examples for maximum savings.