Back to blog

Building with the Claude API: From One Request to Agentic Workflows

2,080 words11 min read

A practical learning guide from Anthropic's Building with the Claude API course, rewritten into an application operating model for server-side calls, message state, streaming, structured output, evals, tools, RAG, MCP, and workflow design.

Building with the Claude API: From One Request to Agentic Workflows

I studied Anthropic's Building with the Claude API course after spending a lot of time with Claude Code.

That order matters.

Claude Code teaches the workflow from the outside: give an agent a repo, a task, tool access, and feedback. The Claude API teaches the same pattern from the inside: how the application actually wraps a model call with context, state, validation, tools, retrieval, and evaluation.

My main takeaway:

The API call is the easy part. The product loop around the API call is the real system.

This post is not a transcript of the course. It is my public learning guide: the mental model I want to keep, the parts I would turn into demos, and the checklist I would use before building with Claude in a real product.

1. Models Are Product Trade-Offs

The first decision is not "which model is best?"

The better question is:

What does this feature need from the model?

For one feature, you may care about raw reasoning quality. For another, latency. For another, long context. For another, cost, vision support, tool use, or extended thinking.

That means model choice is product design. A support bot, a code reviewer, a research assistant, and a document parser may all deserve different trade-offs.

My rule after the course:

Choose the model for the job, not for the leaderboard screenshot.

For a first demo, this can stay simple: pick a current Claude model, make one request, and record why that model fits the job. The useful habit is not memorizing model names. The useful habit is matching capability, cost, and latency to a product task.

References

2. The First Real API Rule: Keep The Key Server-Side

The beginner move is to paste an API key into a frontend app.

The production move is boring and correct:

  1. The browser sends user input to your server.

  2. Your server reads the API key from a secret environment variable.

  3. Your server calls the Claude API.

  4. Your server returns only the result the client needs.

This is not glamorous. It is also the difference between "toy demo" and "I will not accidentally leak my credentials to the internet before lunch."

The minimal app shape is:

browser
-> your server endpoint
-> Anthropic Messages API
-> validated response
-> browser

This server boundary becomes more important later. Once the app has tools, retrieval, citations, logs, and permissions, your server is the policy layer. Claude can reason about what should happen, but your application controls what is allowed to happen.

References

3. The Messages API Is Stateless

This is one of the most important ideas.

The Claude API does not secretly remember your previous turns. If you want a multi-turn conversation, your application must send the relevant message history again.

That changes how I think about "memory."

Memory is not magic. Memory is data design.

For a simple chat app, memory can be an array of messages. For a serious product, memory may involve summarization, retrieval, user profile state, permissions, project context, and a decision about what not to send.

The application owns the conversation state:

user message
-> append to conversation state
-> send selected state to Claude
-> receive assistant response
-> validate
-> append final response

The important word is selected. You do not always send everything. You send what the next turn needs.

References

4. System Prompts Are Behavior Contracts

A system prompt is not a decorative persona.

It is the behavior contract for the model inside your application. It can define the role, boundaries, output style, escalation rules, tool-use policy, and refusal behavior.

Bad system prompt:

You are a helpful assistant.

Better system prompt:

You are a support triage assistant.
Classify the issue, ask one clarifying question if needed,
and never promise refunds or policy exceptions.
Return JSON matching the provided schema.

The system prompt should not hide product requirements in a poetic fog. It should make the operating conditions explicit.

This is also where parameters matter. Temperature, max tokens, stop sequences, and output patterns are not random knobs. They shape how much variation you accept and how predictable the application needs to be.

References

5. Streaming And Structured Output Make AI Feel Like Software

A single blocking response can be fine for a script.

In a product, streaming often feels better. The user sees progress, the interface feels alive, and long responses do not feel like the app froze.

But streaming has a catch: you still need a final state. The UI can render partial text, but the app should store or act on the validated final result.

Structured output is the other half. If the output is meant for software, do not just ask nicely. Give the model a clear shape, parse the result, and handle failure.

For example:

Claude generates draft JSON
-> parse JSON
-> validate fields
-> reject or repair if invalid
-> store only validated data

The lesson here is simple:

Text can be fuzzy. Product state cannot.

References

6. Evals Are Where Prompting Grows Up

Before this course, it is easy to treat prompt work as a taste test.

Try a prompt. Read one answer. If it feels good, ship it.

That is fine for exploration. It is not enough for a product.

The better loop is:

  1. Write a small test dataset.

  2. Define what good output means.

  3. Run the prompt across the dataset.

  4. Grade with code, a human, or another model.

  5. Change one thing.

  6. Run it again.

This is the line between demo and production. A prompt without evals is a vibe. A prompt with evals becomes an engineering surface.

My favorite small version is a five-case eval:

  • one easy case

  • one edge case

  • one ambiguous case

  • one adversarial case

  • one realistic messy case

If the prompt cannot survive five examples, it probably should not run inside a product yet.

References

7. Tool Use Turns Text Into Controlled Action

Tool use is the bridge from "Claude answers" to "Claude helps operate a system."

The model can decide that a tool is needed. Your app still defines the available tools, their schemas, the permissions, the execution, and the returned tool results.

That separation matters.

Claude should not "just do anything." Claude should choose from a small set of explicitly defined actions:

search_docs(query)
get_customer_order(order_id)
calculate_refund(policy, order)
create_support_draft(summary)

The model plans. The application executes.

That is the safety boundary. It is also the product boundary. A tool that is too vague becomes dangerous. A tool that is too narrow becomes useless. The design work is choosing the smallest useful action surface.

References

8. RAG Is Retrieval Design, Not Magic Memory

RAG sounds simple:

retrieve relevant documents
-> put them in context
-> ask Claude to answer

The hard part is the word relevant.

A useful RAG system has many design choices:

  • how to chunk documents

  • whether to use embeddings, keyword search, or both

  • how to rerank results

  • how much context to include

  • how to cite sources

  • what to do when retrieval is weak

For my own AI_Brain work, this connects directly to personal knowledge management. Dumping files into a vault is not the same as building useful context. The system needs source notes, maps, concepts, methods, judgments, and output packages so retrieval has structure to work with.

The product question is:

What evidence should Claude see before answering?

References

9. Advanced Features Are Capability Layers

The course also points toward several advanced features:

  • vision

  • PDF handling

  • citations

  • prompt caching

  • extended thinking

  • code execution

  • Files API

  • Model Context Protocol

My temptation is always to learn every feature at once. This is how knowledge systems become beautifully unusable.

So my rule is:

Add a capability only when the workflow creates pressure for it.

If the same large context appears in every request, prompt caching may be worth learning. If the app needs evidence-backed answers, citations matter. If the app needs external systems, MCP matters. If the task is purely text classification, none of those features should be dragged in just to look advanced.

Delete before automate. Simplify before integrate. Contract before tools.

References

10. Workflows First, Agents When Needed

The most useful distinction near the end of the course is workflows versus agents.

A workflow is better when the path is known:

classify ticket
-> retrieve policy
-> draft response
-> run checks
-> send to human review

An agent becomes useful when the path is not fully known and the system must decide which steps to take.

But "agent" should not be the default. A deterministic workflow is easier to test, easier to debug, and easier to explain. Agents are powerful when uncertainty is real. They are expensive confusion machines when the process could have been a checklist.

My current build rule:

Start with a workflow. Promote to an agent only when the unknowns justify autonomy.

This is especially important for solo builders. You do not need the fanciest architecture. You need a system you can understand, test, and improve.

References

The Operating Model I Want To Keep

Here is the course compressed into one build loop:

product task
-> choose model
-> server-side API call
-> explicit message state
-> system prompt and parameters
-> streaming or structured output
-> validation
-> eval dataset
-> tools / RAG / MCP only when needed
-> workflow or agent decision
-> feedback back into the system

This is the part I want to carry into future projects.

Claude API development is not just calling a model. It is designing the operating conditions around a model so the output can become software, knowledge, or action.

That is also how I want my AI_Brain system to work:

raw learning
-> source note
-> concept / method / judgment
-> artifact package
-> blog / video / project
-> feedback
-> better judgment

The API course gave me a cleaner way to think about that loop.

Knowledge Map

Claude API product loop knowledge map

References

Loading comments...