Build AI Apps with Python: Currency Converter with Function Calling | Episode 7
6views
0018:51
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Claude can now DO things! In this episode, we teach Claude to call a Python function — a currency converter
that converts USD to Singapore dollars, euros, yen, and more.
This is the start of Phase 2: Tool Use & Function Calling. You define a function, describe it with a JSON
schema, and Claude decides when to call it. The tool use loop: user asks → Claude calls tool → you execute →
Claude answers naturally.
Student code: https://github.com/GoCelesteAI/build-ai-apps-python/tree/main/episode07
Every keystroke is shown on screen with 3-second pauses so you can follow along at your own pace.
What You'll Learn:
• Defining tools with JSON schema (name, description, input_schema)
• The tools parameter in messages.create()
• Mock exchange rates dictionary
• Building a convert_currency() function
• Checking stop_reason for "tool_use"
• Extracting tool_block with name and arguments
• Executing the function with **tool_block.input
• Sending tool_result back to Claude for a natural answer
• The complete tool use loop
• Running Python scripts with :!python %
Timestamps:
0:00 - Introduction
0:12 - What is Tool Use? (Preview)
0:44 - Creating first_tool.py
1:00 - Imports and setup
2:10 - Mock exchange rates dictionary
3:52 - convert_currency() function
5:22 - Save progress
5:32 - Tool definition — the JSON schema
6:25 - Input schema with properties
7:40 - Save tool definition
8:12 - API call with tools parameter
9:42 - Checking stop_reason == "tool_use"
10:18 - Extracting tool_block
11:05 - Executing the function
11:38 - Sending tool_result back to Claude
13:18 - Tool result block with ID
14:38 - Claude's final answer print
15:48 - Save and run
16:08 - The complete tool use loop in action!
16:25 - Code review
16:45 - Recap: 3 Key Takeaways
17:17 - End Screen
Key Takeaways:
1. Tools are JSON schemas that describe your functions — Claude reads them to decide what to call
2. Check stop_reason for "tool_use" — then execute the function and return the result
3. The full loop: ask → call → execute → answer — that is function calling
Tags
python ai tool useclaude api function callinganthropic sdk toolstool use pythonai function callingclaude api pythoncurrency converter aijson schema toolstool_use stop reasonai tutorial 2026build ai apps pythonneovim tutorialgenerative ai pythonscreenkeycode along