# Module 13: The API and Beyond
## Demo Data: API Concepts for Non-Engineers

This module makes the API tangible for a mixed audience. Use these examples to show what the API does without requiring anyone to write code.

---

## What the API Actually Is

**Analogy for the room:**

Claude.ai is like walking into a restaurant, sitting down, and having a conversation with the chef. You tell them what you want, they make it.

The API is like a drive-through window. You send a specific order, you get a specific result. No conversation needed. And you can send a thousand orders at once.

Cowork is like having the chef come to your house, open your fridge, and cook with what you have.

---

## Demo: Anatomy of an API Call

Show this on screen. Walk through each piece.

```json
{
  "model": "claude-sonnet-4-6",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "Summarize this customer feedback in one sentence: 'I've been using the S-300 sensor for six months. The accuracy is excellent but the setup documentation was confusing. Took our team three days to get it calibrated correctly. Once running, though, it's been flawless. Would buy again but please fix the docs.'"
    }
  ]
}
```

**Walk through:**
- `model`: Which version of Claude to use. Like choosing between regular and premium.
- `max_tokens`: How long the response can be. A token is roughly 3/4 of a word.
- `messages`: The conversation. Here it's a single user message.
- `role`: Who's talking. "user" is you. "assistant" is Claude. "system" is the instructions.

**Response (show this):**
```json
{
  "content": [
    {
      "type": "text",
      "text": "Customer is highly satisfied with S-300 sensor accuracy and reliability after six months of use, but reports that poor setup documentation caused a three-day calibration delay."
    }
  ],
  "model": "claude-sonnet-4-6",
  "usage": {
    "input_tokens": 87,
    "output_tokens": 38
  }
}
```

**Walk through:**
- `content`: Claude's response.
- `usage`: How many tokens were used. This is what you pay for.
- Cost at current Sonnet pricing: roughly $0.0005 for this call. Half a cent.

---

## Demo: The System Prompt in API Context

```json
{
  "model": "claude-sonnet-4-6",
  "max_tokens": 512,
  "system": "You are a customer feedback analyst for an industrial sensor company. Categorize each piece of feedback as: Product Quality, Documentation, Support, Pricing, or Feature Request. Rate sentiment as Positive, Neutral, or Negative. Be concise.",
  "messages": [
    {
      "role": "user",
      "content": "Feedback: 'The S-300 is great but $640 is steep compared to the competition. If you could get under $600 I'd order double.'"
    }
  ]
}
```

**Teaching point:** The system prompt is persistent configuration. In the chat interface, you set it once per conversation. In the API, you send it with every call. This is how companies build Claude into their products: the system prompt defines the behavior, and the user message is whatever the end user types.

---

## Demo: Tool Use (Function Calling)

Show this conceptually. No code needed.

**Scenario:** A customer support chatbot that can look up order status.

```
System Prompt: "You are a customer support agent for Greenfield Manufacturing.
You can look up order information using the check_order_status tool.
When a customer asks about an order, use the tool to get real-time data,
then respond naturally."

Tool Definition:
  Name: check_order_status
  Description: Looks up the status of a customer order
  Parameters:
    - order_id (string, required): The order number
    - customer_email (string, optional): Customer's email for verification

User: "Where's my order? It's order number GF-2026-4471."

Claude's action: Calls check_order_status(order_id="GF-2026-4471")

Tool returns: {
  "status": "shipped",
  "carrier": "FedEx",
  "tracking": "7489201847",
  "estimated_delivery": "March 10, 2026"
}

Claude's response: "Your order GF-2026-4471 has shipped via FedEx.
The tracking number is 7489201847 and the estimated delivery date
is March 10th. Would you like me to help with anything else?"
```

**Teaching point:** Claude didn't make up the tracking number. It called a function that looked it up in a real system. This is how companies connect Claude to their databases, CRMs, and internal tools. Claude handles the conversation; the tools handle the data.

---

## Pricing Calculator

Show this table. Make it concrete.

| Model | Input (per 1M tokens) | Output (per 1M tokens) | Typical use case |
|---|---|---|---|
| Haiku 4.5 | $0.80 | $4.00 | High-volume, simple tasks (categorization, extraction) |
| Sonnet 4.6 | $3.00 | $15.00 | General purpose (analysis, writing, reasoning) |
| Opus 4.6 | $15.00 | $75.00 | Complex reasoning, nuanced judgment |

**Real-world example:**
"If you process 1,000 customer support tickets per day using Sonnet, and each ticket averages 200 input tokens and 100 output tokens, your daily API cost is:
- Input: 200,000 tokens x ($3.00 / 1,000,000) = $0.60
- Output: 100,000 tokens x ($15.00 / 1,000,000) = $1.50
- **Daily total: $2.10. Monthly: about $63.**"

Compare that to the cost of a person doing the same work.

---

## Discussion: Build vs. Buy

When should an organization build with the API vs. using Cowork/Claude.ai?

| Build (API) when... | Use existing tools when... |
|---|---|
| You need to process thousands of items automatically | You process dozens of items manually |
| Claude needs to connect to your internal systems | The work happens in documents and files |
| End users shouldn't see Claude's interface | Your team uses Claude directly |
| You need consistent, repeatable formatting | Formatting varies by task |
| Cost predictability matters at scale | Volume is low enough that per-seat pricing works |
