Program 03 · Module 03 of 10
Module 03: Tools, APIs and Function Calling
Connect an agent to real capabilities safely. You learn the tool-calling round trip, design schemas and validate arguments, connect REST APIs, manage credentials with least privilege, and handle failures with retries and idempotency.
- Suggested study time
- 7-9 hours
- Prerequisites
- Modules 1 and 2.; Experience calling an HTTP API from Python.; An API key for one model provider (kept in an environment variable) for the lab.
Sign in to track your progress. Every lesson stays free to read without an account.
Learning outcomes
By the end of this module you will be able to:
- Explain the tool-calling round trip and who executes what.
- Design tool schemas and validate arguments before execution.
- Connect REST APIs and internal services behind narrow tool functions.
- Apply least-privilege credentials and keep secrets out of code and logs.
- Handle errors, timeouts and retries without repeating side effects.
Lessons
- 3.1
How Tool Calling Works
Follow the five-step round trip of tool calling, see why the model only asks while your code runs the function, and learn the safety checks that sit in between.
40 min - 3.2
Designing Tool Schemas and Validating Arguments
Write a clear tool contract and JSON Schema for each tool, then check every argument in your own code and send a helpful error back before the tool runs.
45 min - 3.3
Connecting REST APIs and Internal Services
Learn what an API is in plain words, then wrap a REST API in a narrow tool with a fixed address, a timeout, short output and clear error messages.
45 min - 3.4
Authentication, Secrets and Least-Privilege Access
Learn how an agent's tools prove who they are, where API keys must and must not live, and why each tool should hold the smallest key that does its job.
40 min - 3.5
Tool Errors, Retries, Timeouts and Idempotency
Learn the three kinds of tool failure, how to retry safely with limits, and how an idempotency key stops a retried write from creating a duplicate.
45 min - 3.6
Practical Lab: Build an Agent That Uses Two Tools
Give your agent a read-only lookup tool and a return tool that waits for staff approval, with a safety gate, a timeout, offline tests and a recorded trace.
1 h 30 min
About 5 h 5 min of lessons in total.
Practical assignment
Practical Lab: Build an Agent That Uses Two Tools
Build an agent with two tools against a fictional API: one read-only, one that creates a record and requires approval. Include argument validation, timeouts and error observations.
Deliverables
- Source code and a README with setup steps and a .gitignore that excludes .env.
- Tool contracts in JSON.
- A test file covering valid, invalid and failing tool calls.
- A trace of at least three runs.
Validation checklist
Use this to check your assignment before you move on.
Knowledge check
Show the answer and explanation
Answer: B. The model returns a structured request and your code decides whether to run it. People say the model calls a tool, which is why the first option tempts, but for your own tools it only asks.
Show the answer and explanation
Answer: B. A timeout does not tell you whether the action happened. Idempotency keys and checks before retrying prevent duplicates.
Show the answer and explanation
Answer: B. Environment variables keep the key out of the repository and out of the model's context. Placing it in instructions exposes it to the model and to logs.
PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.