Anthropic Claude API Guide: Models, Tools, and Agents

Anthropic positions Claude as a model family built for "long-running agents, complex coding, and enterprise workloads." Following the Claude Opus 5 launch, every current model supports text and image input, multilingual text output, and vision, and is available through the Claude API, Amazon Bedrock, Google Cloud, and Microsoft Foundry.

1. The Claude Model Lineup

Anthropic splits the lineup by workload:

  • Claude Fable 5: The most capable widely released model, built for long-running agent tasks, with a 1M-token context window and 128k max output.
  • Claude Opus 5: The first choice for complex agentic coding and enterprise work, with a better capability-to-cost balance.
  • Claude Sonnet 5: The best combination of speed and intelligence for most online workloads, with introductory pricing at launch.
  • Claude Haiku 4.5: The fastest and cheapest model for high-frequency lightweight tasks, with extended thinking support.

Put side by side, the four tiers are easier to compare (prices per million tokens, input/output):

Model Positioning Context Ref. price (in/out) Typical use
Fable 5 Most capable 1M tokens $10 / $50 Long-running agents, deep reasoning
Opus 5 Capability/cost balance 200k+ $5 / $25 Complex coding, enterprise tasks
Sonnet 5 Speed and intelligence 200k+ $3 / $15 Online services, support, summarization
Haiku 4.5 Fastest, cheapest 200k+ $1 / $5 Classification, extraction, high-frequency

Selection advice: start with Opus 5 when unsure; use Fable 5 for maximum capability; use Sonnet 5 or Haiku 4.5 for cost- and latency-sensitive online services. Every Claude model ID is a pinned snapshot rather than a hot-swapping alias, which makes production locking simpler.

2. Messages API: Getting Started in One Call

The core interface is the Messages API. A request is built from a system prompt plus a messages array (roles user/assistant), and max_tokens is required:

from anthropic import Anthropic
client = Anthropic()
resp = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=1024,
    system="You are a website support assistant.",
    messages=[{"role": "user", "content": "Explain the refund policy"}],
)
print(resp.content[0].text)

The messages array supports multi-turn conversations and multimodal content blocks; images are passed as base64 or URLs.

3. Tool Use and Streaming

  • Tool use: Declare tools in the request; the model returns tool_use content blocks, your code executes and returns tool_result, and the model continues. Anthropic stresses writing clear tool descriptions (when to use, parameter meaning, return format) and keeping the tool count reasonable to reduce confusion.

A minimal example: let the model look up an order status.

tools = [{
    "name": "get_order_status",
    "description": "Look up the shipping status of an order by its ID",
    "input_schema": {
        "type": "object",
        "properties": {"order_id": {"type": "string"}},
        "required": ["order_id"],
    },
}]
resp = client.messages.create(
    model="claude-sonnet-5", max_tokens=1024,
    tools=tools,
    messages=[{"role": "user", "content": "Has order 20260714001 shipped?"}],
)

The model first returns a tool_use block; your code queries the database and passes the result back as tool_result, then Claude composes an answer from real data. This is the standard pattern for "letting the model reach into your systems."

  • Streaming: SSE delivers content chunk by chunk, markedly improving perceived latency for chat interfaces. In the SDK, pass stream=True and process chunks as they arrive:
with client.messages.stream(
    model="claude-sonnet-5", max_tokens=1024,
    messages=[{"role": "user", "content": "Write a 50-word product blurb"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
  • Thinking: Current models enable adaptive thinking by default, with an effort parameter to trade speed against depth; set higher effort explicitly for complex reasoning and long-horizon agents.

4. Claude Code and the Agent SDK

  • Claude Code: An agentic coding assistant in the terminal that reads and writes files, runs commands, uses subagents, and connects to external tools and data through MCP (Model Context Protocol). It turns "AI coding agents" from a concept into an everyday tool.
  • Agent SDK: Anthropic's official TypeScript/Python library for building agents, deeply integrated with the Claude API and supporting tool orchestration, multi-agent collaboration, and production-grade lifecycle management. Before using it, master the fundamentals in AI agent development basics.

5. Pricing and Cost Strategy

Claude bills per input/output token (per million). Current reference pricing: Fable 5 at $10/$50, Opus 5 at $5/$25, Sonnet 5 at $3/$15, and Haiku 4.5 at $1/$5.

A quick estimate: a support bot with 10,000 daily active users and an average of 800 input tokens + 300 output tokens per conversation consumes roughly 8M input and 3M output tokens per day. On Sonnet 5 that is about $24 + $45 = $69/day; routing the same volume to Haiku 4.5 drops it to $8 + $15 = $23/day — a difference that compounds quickly at scale. Money-saving tips:

  1. Batch API: Discounted pricing for non-realtime jobs; ideal for offline processing.
  2. Prompt caching: Cached system prompts and long context cut input costs substantially.
  3. Downgrade on demand: Route expensive tasks to Opus and routine tasks to Sonnet/Haiku, with unified gateway budgets (see the AI gateway spend limits guide).

6. 16IDC Takeaways

Claude's long context and honest-answer behavior make it well suited to knowledge-base Q&A, support bots, and content moderation; see integrating an AI chatbot into a website for integration patterns. The Messages API and tool use are clean to work with, so build a prototype with the official SDK first, then layer RAG (the RAG implementation guide) and caching before launch. Also reserve compute for logs, caching, and vector retrieval in your server selection: conversation state and knowledge-base indexes still run on your side.

7. FAQ

  • Do I have to manage conversation context myself? Yes. The Messages API is stateless: prepend recent turns into the messages array, or keep the last N turns in a session cache so the context does not grow unbounded.
  • What happens when I hit rate limits? The SDK retries automatically; add exponential backoff. For long jobs, switch to the Batch API instead of burning concurrency.
  • Can I deploy in other regions or channels? Yes — the same models run on Bedrock, Vertex AI, and Foundry, which suits data-residency or multi-cloud failover needs.

Source: https://platform.claude.com/docs/en/docs/about-claude/models/overview
Reference: Messages API https://platform.claude.com/docs/en/docs/api/messages
Reference: Tool Use https://platform.claude.com/docs/en/docs/agents-and-tools/tool-use/overview
Reference: Prompt Caching https://platform.claude.com/docs/en/docs/build-with-claude/prompt-caching