Mater Dei AI Club

This page is for people who want to build their own apps, tools, or automations that use Claude's intelligence behind the scenes. Maybe you want to add a smart chatbot to your website, automatically categorize customer emails, or build a tool that analyzes data for your business.

What this means for you

Even if you're not a developer, understanding the API helps you communicate with developers, evaluate what's possible, and plan features for your products. If you are a developer, scroll down for the technical reference.

What Is an API? (The Non-Technical Version)

An API is like a menu at a restaurant. You don't need to know how the kitchen works — you just tell the waiter what you want, and the kitchen makes it. The Claude API lets your app “order” intelligence from Claude: send a question, get an answer.

What Can You Build?

What You Want How the API Helps Example
Smart chatbot on your website Your site sends customer questions to Claude, gets answers back Support bot that answers product questions 24/7
Email sorting Send incoming emails to Claude, it categorizes them Auto-tag support emails as “billing,” “technical,” or “general”
Content generation Send a topic, get blog posts or social media content back Weekly newsletter drafted automatically
Data analysis Send spreadsheet data, get insights and summaries Monthly sales report generated from raw numbers
Document processing Send contracts or invoices, get structured data back Extract key terms from legal documents

How Much Does It Cost?

You pay based on how much text you send and receive, measured in “tokens.” A million tokens is roughly 555,000 words — about six novels.

Model Cost to Send Cost to Receive Best For
Fable 5.1 (deepest reasoning) $10 / M tokens $50 / M tokens Hard-to-reverse decisions, long-horizon work
Opus 5 (the workhorse) $5 / M tokens $25 / M tokens Complex analysis, real coding
Sonnet 5 (balanced) $2 / M tokens $10 / M tokens Most everyday tasks
Haiku 4.5 (fastest) $1 / M tokens $5 / M tokens Simple tasks, high volume

In practical terms: Analyzing a 1-page document with Sonnet costs about $0.005 (half a cent). Even for a busy small business, API costs are typically $10-100/month.

Good to know

If you use Claude Code with a Max subscription ($100/month or $200/month), your interactive sessions are included. The API is only needed when you're building apps for other people to use.

Developer Quick Start

The sections below are technical reference for developers building with the Claude API.

Python

pip install anthropic

import anthropic client = anthropic.Anthropic() # Uses ANTHROPIC_API_KEY env var message = client.messages.create( model="claude-opus-5", max_tokens=1024, messages=[{"role": "user", "content": "Hello, Claude"}] ) print(message.content[0].text)

TypeScript

npm install @anthropic-ai/sdk

import Anthropic from "@anthropic-ai/sdk"; const client = new Anthropic(); // Uses ANTHROPIC_API_KEY env var const message = await client.messages.create({ model: "claude-opus-5", max_tokens: 1024, messages: [{ role: "user", content: "Hello, Claude" }] }); console.log(message.content[0].text);

Key API Features

Conversations (Multi-Turn)

Build chatbots that maintain context across messages:

message = client.messages.create( model="claude-opus-5", max_tokens=1024, system="You are a helpful customer support agent for a bakery.", messages=[ {"role": "user", "content": "Do you have gluten-free options?"}, {"role": "assistant", "content": "Yes! We offer gluten-free bread, muffins, and cookies."}, {"role": "user", "content": "What about the cookies -- are they nut-free too?"}, ], )

Tool Use (Let Claude Take Actions)

Give Claude the ability to call functions in your app — like looking up a customer, checking inventory, or placing an order:

tools = [ { "name": "lookup_customer", "description": "Look up a customer by email address.", "input_schema": { "type": "object", "properties": { "email": { "type": "string", "description": "The customer's email address" } }, "required": ["email"] } } ] response = client.messages.create( model="claude-opus-5", max_tokens=1024, tools=tools, messages=[{"role": "user", "content": "Look up the customer [email protected]"}] )

Streaming (Real-Time Responses)

Show responses as they're generated, like a typing effect:

with client.messages.stream( model="claude-opus-5", max_tokens=1024, messages=[{"role": "user", "content": "Write a product description for our new sourdough"}], ) as stream: for text in stream.text_stream: print(text, end="", flush=True)

Vision (Image Analysis)

Send images for Claude to analyze — receipts, product photos, charts, documents:

message = client.messages.create( model="claude-opus-5", max_tokens=1024, messages=[{ "role": "user", "content": [ {"type": "image", "source": {"type": "url", "url": "https://example.com/receipt.jpg"}}, {"type": "text", "text": "Extract the total, date, and vendor from this receipt."} ] }] )

Thinking Harder (Deep Analysis)

For complex problems that need careful reasoning, turn up the effort. Claude decides how much to think; you just tell it how hard to try.

response = client.messages.create( model="claude-opus-5", max_tokens=16000, effort="high", # low | medium | high | xhigh | max messages=[{"role": "user", "content": "Analyze our Q3 sales data and identify trends..."}] )

Older tutorials show thinking={"type": "enabled", "budget_tokens": 10000} instead. That way of asking was retired: it is rejected by every current model, so copying it from an old blog post will return an error. Use effort.

Batch Processing (Bulk Work at 50% Off)

Process hundreds of items at half the cost. Results are delivered asynchronously (not instant, but much cheaper):

batch = client.messages.batches.create( requests=[ { "custom_id": f"email-{i}", "params": { "model": "claude-haiku-4-5", "max_tokens": 256, "messages": [{"role": "user", "content": f"Categorize this email: {email}"}], }, } for i, email in enumerate(customer_emails) ] )

Agent SDK (Building Autonomous Assistants)

The Agent SDK lets you build AI assistants that can work independently — reading files, running commands, and completing multi-step tasks on their own.

from claude_agent_sdk import query, ClaudeAgentOptions async for message in query( prompt="Organize the invoices in the uploads folder by client name", options=ClaudeAgentOptions(allowed_tools=["Read", "Edit", "Bash"]), ): if hasattr(message, "result"): print(message.result)

Error Handling

import anthropic try: message = client.messages.create(...) except anthropic.RateLimitError: print("Too many requests -- slow down") except anthropic.AuthenticationError: print("Invalid API key") except anthropic.APIConnectionError as e: print(f"Connection failed: {e.__cause__}")

Prompt Caching (Save Money on Repeated Work)

If you send the same instructions with every request (like a system prompt), caching saves 90% on those repeated parts:

response = client.messages.create( model="claude-opus-5", max_tokens=1024, cache_control={"type": "ephemeral"}, system="Your large system prompt here...", messages=[{"role": "user", "content": "Question"}] )

What this means for you

If you're building a chatbot that always starts with the same instructions (like “You are a support agent for Acme Corp”), caching means you only pay full price for those instructions once. After that, it's 90% cheaper.

Choosing the Right Model

Model Speed Intelligence Cost Use When
Opus Slowest Highest Most expensive Complex reasoning, critical analysis, high-stakes decisions
Sonnet Medium High Moderate Most tasks — good balance of quality and speed
Haiku Fastest Good Cheapest Simple classification, high-volume processing, quick responses

**Rule of thumb:**Start with Sonnet. Move to Haiku if you need speed/savings. Move to Opus if quality isn't good enough.

Source: ClaudeCodeMastery beginner docs (localhost:3055/docs/api-and-sdk), fetched 2026-09-04