0PricingLogin
AI Agents · Lesson

Calling Anthropic API: messages

Use the Anthropic messages API: differences from OpenAI, system prompt placement, and Claude-specific best practices.

Why Anthropic?

Claude models often have stronger instruction-following, better tool use, and longer context windows than equivalent OpenAI models — and are sometimes cheaper.

Most production agents support both providers as a fallback.

Install the SDK

# pip install anthropic
import anthropic
client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY from env

All lessons in this course

  1. Calling OpenAI API: chat.completions
  2. Calling Anthropic API: messages
  3. Streaming Responses (SSE)
  4. Cost Awareness: Token Counting and Budgets
← Back to AI Agents