How to Build Your First App with the OpenAI API in Python
Learn the OpenAI API in Python: build a small helper app with the Responses API, function calling, a remote MCP server and the Agents SDK, with a spend limit.
- OpenAI API
- 6 days
- beginner
- 6 lessons
- about 3 hours
Free and self-paced. Every lesson is open to everyone.
Start with lesson 1What you will do
API use is paid and billed apart from any ChatGPT plan, so lesson 1 sets up prepaid credit and a hard spend limit before any code. The example is a made-up swimming pool front desk. You end by logging cost and checking ten answers by hand. You need basic Python and a payment card.
How this course works
The course is free and you go at your own pace. Each lesson is short: a bit of reading and a few small tasks you do in the tool itself, so you learn by using it. Every lesson is open to everyone, no account needed. A free account saves your progress, so you can pick up where you left off on any device. What the account stores and how to get it removed is on the privacy page.
Syllabus
- Day 1, 25 minutes How to set up the OpenAI API with credit and a spend limit Create an OpenAI API project, buy the smallest amount of credit, set a hard monthly spend limit and make a project key that stays out of your code.
- Day 2, 30 minutes How to make your first OpenAI Responses API call in Python Keep your key in a .env file that git ignores, make a first Responses API call, and read its output items, token usage and a follow-up turn.
- Day 3, 30 minutes How to use function calling with the OpenAI API in Python Write three strict function tools, run the calls the model asks for in your own loop, and send the results back until the model gives a final answer.
- Day 4, 25 minutes How to connect a remote MCP server to the OpenAI API with approvals Connect the OpenAI Docs MCP server to a Responses API call, read each approval request, approve or refuse it, and see what was sent.
- Day 5, 30 minutes How to build a small agent with the OpenAI Agents SDK Build two specialist agents with the Agents SDK, run them once with handoffs and once as tools of a manager, and compare who gives the answer.
- Day 6, 30 minutes How to track OpenAI API cost and hand-check ten answers Log the tokens and an estimated cost of every call, compare them with the Usage page, and hand-check ten answers of your desk helper in a CSV file.