---
title: "Build An AI Avatar Tutor with GPT-5, Pipecat & Heygen (Full Tutorial)"
source_url: https://www.youtube.com/watch?v=vE5MhfWiIAs
captured_at: 2025-09-15
author: "James Bradford"
contributor: "ชิดชนก"
platform: youtube
---
# Build An AI Avatar Tutor with GPT-5, Pipecat & Heygen (Full Tutorial)

youtube video by **James Bradford**, 19m37s, uploaded 2025-08-09. URL: https://www.youtube.com/watch?v=vE5MhfWiIAs

## Shared in LINE Note+
- 2025-09-15 01:48 by ชิดชนก — nearby chat: บ้านบ้าน

## Description
Build An AI Avatar Tutor with GPT-5, Pipecat & Heygen (Full Tutorial)
In this video, I’ll show you step-by-step how to create a real-time AI tutor that teaches AI/ML to beginners - powered by GPT-5 for brains, Pipecat for conversational logic, and Heygen for a talking avatar.

💻 GitHub Repo (All project code):
🔗 

📄 Pipecat Quickstart Docs:
🔗 

🔑 API Keys You’ll Need
OpenAI API Key – Sign up at  → go to View API Keys → Create new secret key.

Cartesia API Key – Get free at  → Sign up → find your key in the dashboard.

Deepgram API Key – Create a free account at  → check API Keys in dashboard.

Heygen API Key – Sign up at  → Account  → Subscriptions and API → HeyGen API → API Key.

🧰 Additional Resources:
If you need help getting set up with Pipecat + Heygen ​⁠@imkylecampbell made a great video on it, you can watch it here: 

#AIAvatar #Pipecat #Heygen #GPT5 #AITutor #MachineLearning #AIinEducation #ConversationalAI #VirtualAvatar #AIForBeginners #OpenAI #EdTech #AITeacher #AIDevelopment #AIIntegration

If you need help implementing AI avatars for your website or product, feel free to email me at jimmybradford55@yahoo.com

## Transcript (captions:auto:en-orig)
Today, we're building your very own AI tutor. One that actually talks to you, looks at you, and teaches you AI and machine learning from scratch. We're combining three powerful tools. Pipecat for real-time conversation. Hey, Gen for a realistic talking avatar, and the brand new GPT5 as the tutor's brain. By the end of this tutorial, you'll have an AI teacher that you can chat with right in your browser, ready to guide beginners through AI and ML concepts step by step. Let's jump in. &gt;&gt; Hello, I'm excited to help you learn about AI and machine learning. What's your name? My name is Jim. &gt;&gt; Nice to meet you, Jim. Are you new to AI and machine learning? Do you have some experience or are you just looking for a refresher? &gt;&gt; Uh, I'm new to it. &gt;&gt; Everyone starts somewhere. Would you like to begin with one of these topics? Features, FSS, labels, train/est split, or overfitting. Please pick one. &gt;&gt; Yeah, let's go with uh features versus labels. That sounds interesting. What is that? &gt;&gt; Great choice. In machine learning, features are like the ingredients in a recipe. things you use to make a prediction. Labels are like the final dish, the answer you want to get. For example, if you want a computer to predict if a fruit is an apple or an orange, the features might be color, weight, and shape. The question two, what do we call the part of data used to teach a machine learning model? A test set B training set C recipe, please choose A B. To &gt;&gt; train it, I think it's called the training set, right? &gt;&gt; Correct. The training set is used to teach the model. Let's walk through how our AI tutor works step by step. First, you talk into your computer's mic. Your browser sends that to our server using a safe real-time connection called Web RTC. After that, our next stop is Deepgram Graham. Think of deepgram like a super accurate note ticker. It listens and turns your speech into text. Next, we hand that text to OpenAI's GPT5. This is the brain. It reads what you said and decides on the next step, always one step at a time. And in simple English, if you say start quiz, the brain switches to a short five question check to see what you've learned. Once we have the reply, we send it to Cartisia, which turns the text back into a clear, natural voice, like a friendly teacher speaking. Finally, hey Jen gives that voice a face, an on-screen avatar that talks to you in real time. All of this is connected by Pipecat, which keeps the pieces running quickly and smoothly. So the loop is you speak, Deepgram Graham writes it down, GPT5 answers simply, Cartisia speaks it back, and Hen shows the tutor's face. Then we repeat just one easy step at a time. Let's get into the code. The first thing we need to do is set up our Pipecat voice agent. So go to the GitHub repository that I linked in the description for this Pipcat quick start and go over to this green button right here and copy this HTTPS link right here. Once you have this link copied, head back over to your code editor so we can close this locally. Now that I'm in my code editor, I'm going to click on open project and new folder and I'm going to call this pipe caten and click create. Let's open that. First things first, we're going to clone that repository that we just visited with the link we just copied. So, open up a terminal and run the command get clone and paste in that URL and click enter. Now, our repository has been cloned, meaning we have a copy of it locally. So, let's CD into it. Next, we're going to have to install all of our required dependencies. So, let's do that first by creating a Python virtual environment. On Mac, you can do this by running Python 3-m venv. And that'll initialize a virtual environment for us. And to activate that virtual environment, you can run the command source vnv/binactivate. Now we're ready to start installing our dependencies. So as you can see here, there is a requirements.txt file with all the plug-in dependencies that we need. So in order to install all these, we're just going to have to run pip install-r requirements.txt and let those install. Now that that's done, we need to set up our environment file to store our API keys. As you can see here, they already provided us an example environment file. So, what we're just going to do is copy that into a newv file. So, run the command copy env.ample.env. Now, you can see this file has been created for us. If you don't know, your environment file is just a file where you can store your environment variables. In this scenario, this is where we're going to be storing our API keys. So right now to set up the voice agent, we need our Dgram API key which is going to take what we're saying and convert that speech into text for our LLM to understand. And that LLM we're going to be using is open AI. Now we do need an open AI API key. And also we need a Cartisia API key. Now Cartisia is going to be the voice of our AI avatar. So it's going to take this response that our LLM is generating and put a voice on it so that we can hear what our avatar is saying. Now, to get each of these API keys, I included links in the description with basic instructions so that you can get your API key. It's super simple to do. Also, we want to change our LLM model to GBT5. So, in your env file, write open a_model equals GPT- 5 and save that. Then, head over to your bot. File and where we declare our LLM right here at about line 81, include this line as well to specify that we want to use the GPT5 model. Now it's time to run our voice agent. We've got everything set up. Really quick, I'm going to explain how this bot py file actually works, so you're not just running it blindly. At the very top, by loading our file, setting up logging, and loading a voice activity detection model. This helps the bot figure out when you're actually speaking so it doesn't transcribe silence. And then we're also importing our podcast components. So that's our texttospech model with Cartisia, our deepgram speechtoext model, and then our LLM, which is OpenAI. And we are also importing this web RTC transport that handles audio in and out. And if you scroll down to this runbot function, this function is the heart of the whole file. So we're initializing these services with our API keys, speech to text, text to speech, and our LLM. Then we're setting the voice for our assistant down here with this message and message context. We're giving the AI some starting instructions like be friendly and conversational. And we're setting up a message history to maintain context in the conversation. This RTVI is just real-time voice input. And it's the processor that helps the AI figure out when to respond. So without it, you know, the bot wouldn't know when we're done talking. If you scroll down a little more, this is important, our pipeline. This is just the flow of data. What happens is we speak, then that's going to get detected by the voice activity detection model or the RTVI. That speech is going to get transcribed to deepgram, which is then sent to OpenAI for a response. The reply is then voiced by Cartisia and then sent back to our browser. And all of this is happening in real time. But if you scroll down a bit, this pipeline task wraps the pipeline and starts it up when someone connects. It also cleans things up when they disconnect. Scrolling down further, we have these two event handlers right here. On client connected and on client disconnected. These functions handle people joining and leaving. So when someone joins, it tells the bot to say hello and start the conversation. Now, if I scroll a little further, we have the bot function. This sets up the actual web RTC transport. So audio in, audio out, and the voice detection analyzer. And then finally at the bottom we have this main entry point to kick off the whole thing with this main function. So now that we understand what this file is doing under the hood, let's go ahead and run the bot. One more thing we need to change before we run this code is this line right here. So instead of runner arguments handle signal interruption, just …
