<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-build-a-reliable-ai-assistant-with-the-claude-api-k8qjhv7kx" -->

---
title: How to Build a Reliable AI Assistant with the Claude API
description: A hands-on tutorial walks through building ShopHelper, a customer-support assistant powered by the Claude API in Python. It covers setting up the Anthropic SDK...
canonical: https://daily.dev/posts/how-to-build-a-reliable-ai-assistant-with-the-claude-api-k8qjhv7kx
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Build a Reliable AI Assistant with the Claude API | daily.dev
og:description: A hands-on tutorial walks through building ShopHelper, a customer-support assistant powered by the Claude API in Python. It covers setting up the Anthropic SDK...
og:url: https://daily.dev/posts/how-to-build-a-reliable-ai-assistant-with-the-claude-api-k8qjhv7kx
og:image: https://api.daily.dev/og/posts/K8Qjhv7kx.png
og:image:alt: How to Build a Reliable AI Assistant with the Claude API
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Build a Reliable AI Assistant with the Claude API

**[freeCodeCamp](https://daily.dev/sources/freecodecamp)** · 10 min read · 2 upvotes · 0 comments

## Summary

A hands-on tutorial walks through building ShopHelper, a customer-support assistant powered by the Claude API in Python. It covers setting up the Anthropic SDK and securing API keys, sending first requests, managing conversation history (trimming and summarizing), structuring prompts with XML-style tags, using system prompts, defining and validating tools for function calling, safely handling multi-block Claude responses, and distinguishing workflows from agents. It also demonstrates chaining, parallelization, routing, and evaluator-optimizer patterns, plus a simple framework for evaluating prompt quality with test cases and code-based graders.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.freecodecamp.org/news/how-to-build-a-reliable-ai-assistant-with-the-claude-api>

## Questions this post answers

### How do I safely handle Claude API responses that might contain multiple content block types?

Iterate over every block in response.content and check its type attribute rather than assuming response.content[0] is text. Common block types include text (generated text), tool_use (a request to call a function), and thinking (reasoning content). Handle text blocks for display, tool_use blocks for validated execution, skip thinking blocks, and log any unrecognized block type.

_Developers building Claude-based apps can find similar response-handling patterns on daily.dev._

### How should I let Claude call a function to look up data like an order status?

Define a tool with a name, description, and input_schema describing required parameters, then pass it in the tools argument of the messages.create call. Claude returns a tool_use block containing the function name, input arguments, and an id; your application must validate the arguments and user permissions, execute the function itself, and send back a tool_result message referencing the same tool_use_id before Claude continues.

_Anyone wiring up tool calling with an LLM can track these patterns via daily.dev._

### What's the difference between an AI workflow and an AI agent when using an LLM API?

A workflow follows a predefined sequence of steps, like extract details, draft a reply, then review the reply, where the order is fixed in code. An agent is more flexible: the model itself decides whether to call a tool and what to do next based on results, requiring validation and a maximum step count to avoid runaway loops. Use workflows when steps are known and repeatable; use agents when the next action depends on the current result.

_Teams deciding between workflow and agent architectures can follow this design debate on daily.dev._

## Similar posts on daily.dev

- [Using the Claude API in Python – Real Python](https://daily.dev/posts/using-the-claude-api-in-python-real-python-nixep13ls) · Real Python · 1 upvotes · 0 comments
- [I’m Building My Own AI Voice Assistant. Here’s What’s Happened So Far.](https://daily.dev/posts/i-m-building-my-own-ai-voice-assistant-here-s-what-s-happened-so-far--gpkygs5wx) · Medium · 0 upvotes · 0 comments
- [The Claude Code Handbook: A Professional Introduction to Building with AI-Assisted Development](https://daily.dev/posts/the-claude-code-handbook-a-professional-introduction-to-building-with-ai-assisted-development-i0eeizwam) · freeCodeCamp · 11 upvotes · 1 comments

---

Tags: [#python](https://daily.dev/tags/python), [#llm](https://daily.dev/tags/llm), [#ai-agents](https://daily.dev/tags/ai-agents), [#prompt-engineering](https://daily.dev/tags/prompt-engineering)

[View this post on daily.dev](https://daily.dev/posts/how-to-build-a-reliable-ai-assistant-with-the-claude-api-k8qjhv7kx)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to Build a Reliable AI Assistant with the Claude API","url":"https://daily.dev/posts/how-to-build-a-reliable-ai-assistant-with-the-claude-api-k8qjhv7kx","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-build-a-reliable-ai-assistant-with-the-claude-api-k8qjhv7kx"},"datePublished":"2026-09-29T20:53:59.306Z","dateModified":"2026-09-29T20:54:42.170Z","description":"A hands-on tutorial walks through building ShopHelper, a customer-support assistant powered by the Claude API in Python. It covers setting up the Anthropic SDK...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7461f8ecccc12b60a61c76cd7f287d1c?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7461f8ecccc12b60a61c76cd7f287d1c?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"freeCodeCamp","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"freeCodeCamp","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1628412854/logos/freecodecamp","url":"https://daily.dev/sources/freecodecamp"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-build-a-reliable-ai-assistant-with-the-claude-api-k8qjhv7kx","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,llm,ai-agents,prompt-engineering","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"freeCodeCamp","item":"https://daily.dev/sources/freecodecamp"},{"@type":"ListItem","position":3,"name":"How to Build a Reliable AI Assistant with the Claude API"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-build-a-reliable-ai-assistant-with-the-claude-api-k8qjhv7kx#faq","mainEntity":[{"@type":"Question","name":"How do I safely handle Claude API responses that might contain multiple content block types?","acceptedAnswer":{"@type":"Answer","text":"Iterate over every block in response.content and check its type attribute rather than assuming response.content[0] is text. Common block types include text (generated text), tool_use (a request to call a function), and thinking (reasoning content). Handle text blocks for display, tool_use blocks for validated execution, skip thinking blocks, and log any unrecognized block type. Developers building Claude-based apps can find similar response-handling patterns on daily.dev."}},{"@type":"Question","name":"How should I let Claude call a function to look up data like an order status?","acceptedAnswer":{"@type":"Answer","text":"Define a tool with a name, description, and input_schema describing required parameters, then pass it in the tools argument of the messages.create call. Claude returns a tool_use block containing the function name, input arguments, and an id; your application must validate the arguments and user permissions, execute the function itself, and send back a tool_result message referencing the same tool_use_id before Claude continues. Anyone wiring up tool calling with an LLM can track these patterns via daily.dev."}},{"@type":"Question","name":"What's the difference between an AI workflow and an AI agent when using an LLM API?","acceptedAnswer":{"@type":"Answer","text":"A workflow follows a predefined sequence of steps, like extract details, draft a reply, then review the reply, where the order is fixed in code. An agent is more flexible: the model itself decides whether to call a tool and what to do next based on results, requiring validation and a maximum step count to avoid runaway loops. Use workflows when steps are known and repeatable; use agents when the next action depends on the current result. Teams deciding between workflow and agent architectures can follow this design debate on daily.dev."}}]}
```

