Build a Personal AI Tutor with Python
Build a terminal AI tutor that quizzes you on any topic using Gemini.
Introduction
30 Second Summary
Think about the best tutor you have ever had. They asked questions, listened to your answers, and figured out exactly where you were stuck.
In this project, you will build a personal AI tutor powered by Google's Gemini API. You will pick any topic, get quizzed on it, and watch the tutor adapt its questions based on your answers.
What You'll Build
Picture opening your terminal, typing a topic like "Python programming", and immediately getting quizzed by an AI tutor that remembers every answer you give and builds on them across the whole conversation.
By the end of this project, you'll have:
- A terminal-based AI tutor that quizzes you on any topic you choose and gives personalized feedback on every answer.
- A tutor personality shaped by system instructions you write yourself, turning a generic AI model into a focused, encouraging quiz partner.
- Real multi-turn conversations where the tutor remembers your previous answers and adjusts its questions accordingly.
- Secret Mission: A topic selection menu and a score tracker that counts your correct and incorrect answers.
Are there any prerequisites?
You will need a Google account to get a free API key for the Gemini API. If you do not have one yet, we will help you create one in Step 1.
Before We Start
Before we dive in, let's lock in what you're about to build and why it matters.
Set Up Your Python Environment
Your AI tutor is a Python script that talks to the Gemini API. Before you can write any tutor code, you need three things in place: Python itself, a dedicated space for your project's packages, and a key that lets your code authenticate with Gemini.
This step gets all three set up. By the end, you will have a working environment confirmed with a single test command.
In this step, get ready to:
- Check that Python is installed and create a project folder.
- Create a virtual environment and install the Gemini SDK.
- Get a Gemini API key from Google AI Studio.
Check that Python is installed
The google-genai SDK requires Python 3.10 or higher. Let's confirm you have a compatible version.
- In VS Code, open the built-in terminal by pressing Ctrl+` (macOS and Windows).
- Check your Python version by running this command:
python3 --version
✔️ I see version 3.10 or higher
Your Python version is compatible. You are ready to continue.
ⓧ I see an older version
You have Python installed, but the google-genai SDK needs 3.10 or higher. You need to install a newer version.
- Open your browser and go to python.org/downloads.
- Download the latest Python 3 installer for your operating system.
- Run the installer. On Windows, check the box labelled Add Python to PATH before clicking Install Now.
- Close and reopen VS Code, then open a new terminal and run the version check again.
macOS still showing the old version?
macOS may still resolve python3 to an older version even after installing a new one. Try running the full path (e.g. /usr/local/bin/python3) or use a version manager like pyenv to manage your Python versions.
ⓧ Command not found
Python is not installed yet. Let's get it set up.
- Open your browser and go to python.org/downloads.
- Download the latest Python 3 installer for your operating system.
- Run the installer. On Windows, check the box labelled Add Python to PATH before clicking Install Now.
- Close and reopen VS Code, then open a new terminal.
- Run python3 --version again to confirm the install succeeded.
Windows uses a different command
On Windows, the command is typically python instead of python3. If python3 is not recognized, try python --version instead. Use whichever command works for the rest of this project.
Now let's create a folder for your project.
- Move to your Desktop by running this command:
cd ~/Desktop
- Create your project folder and move into it by running these commands:
mkdir ai-tutor
cd ai-tutor
- In VS Code, click File in the top menu bar.
- Click Open Folder.
- Navigate to your Desktop, select the ai-tutor folder, and click Open.
VS Code reloads with ai-tutor as your workspace. The Explorer sidebar on the left should show the empty folder.
- Open the terminal again by pressing Ctrl+`.
The terminal prompt should show that you are inside the ai-tutor folder.
Create and activate a virtual environment
A virtual environment is an isolated Python setup for your project. It keeps the packages you install here separate from other Python projects on your computer.
- Create a virtual environment by running this command:
python3 -m venv venv
- Confirm the virtual environment folder was created by running:
ls
You should see a venv folder listed in the output.
- Activate the virtual environment by running this command:
macOS
source venv/bin/activate
Windows
venv\Scripts\activate
Your terminal prompt should now start with (venv). This confirms the virtual environment is active.
Don't see (venv) in your prompt?
Make sure you ran the activation command for your operating system. macOS uses source venv/bin/activate and Windows uses venv\Scripts\activate.
On Windows, if you see an error about execution policies, run Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned first, then try the activate command again.
help me activate my Python virtual environment
- Install the google-genai SDK by running this command:
pip install google-genai
What does this install?
The google-genai package is Google's official Python SDK for talking to the Gemini API. It handles sending requests and receiving responses so you can focus on building your tutor's logic.
You should see output ending with Successfully installed followed by a list of packages.
Seeing a permission error or install failure?
Check that (venv) appears at the start of your terminal prompt. If it does not, your virtual environment is not active. Run the activation command from the previous step before trying pip install again.
help me fix my pip install error for google-genai
Get your Gemini API key
An API key is a unique string that identifies your app to the Gemini API. Google uses it to authenticate your requests and track usage.
- Open your browser and go to aistudio.google.com.
- Sign in with your Google account.
Don't have a Google account?
Go to accounts.google.com and create a free account first. Then come back to Google AI Studio and sign in.
- Once signed in, click Get API key in the left sidebar.
- Click Create API key.
- When your key appears, click the copy icon to copy it to your clipboard.
Keep your API key secret
Treat your API key like a password. Do not share it publicly, paste it into code you push to GitHub, or include it in screenshots. You will store it in an environment variable in the next step so it stays out of your code.
Now set the key as an environment variable so your Python script can access it without hardcoding it.
- Switch back to your VS Code terminal and set the environment variable by running this command (replacing your-api-key-here with the key you just copied):
macOS
export GEMINI_API_KEY="your-api-key-here"
Windows
$env:GEMINI_API_KEY = "your-api-key-here"
Why use an environment variable?
Storing your key in an environment variable keeps it out of your source code. Your script reads it at runtime using os.environ, so you never risk accidentally sharing it.
This variable only lasts for the current terminal session. If you close the terminal or restart VS Code, you will need to set it again.
Is the Gemini API free?
Yes. The Gemini API has a free tier that gives you free input and output tokens. This project uses very few tokens, so you will stay well within the free tier.
The free tier is not available in all regions. If you see an access error, check that your region is supported in the Gemini API troubleshooting docs.
Before running the next command, do you think Python will be able to find the google-genai SDK and connect to your API key? What needs to be in place for this to work?
- Confirm everything is connected by running this command:
python3 -c "from google import genai; print('SDK ready!')"
You should see SDK ready! printed in your terminal. This proves Python can find the SDK and you are ready to start building.
Seeing ModuleNotFoundError?
Check that (venv) still appears in your terminal prompt. If it does not, your virtual environment was deactivated. Run the activation command again, then retry.
If (venv) is showing but you still get the error, try running pip install google-genai again and check the output for errors.
help me fix the ModuleNotFoundError for google-genai
Your environment is locked in. Python, the SDK, and your API key are all ready to go. Next up, you will write a few lines of code and watch Gemini answer its first question.
Ask Your First Question
Your Python environment is ready, your SDK is installed, and your API key is loaded.
Before building a full tutor, you need to confirm the Gemini API connection actually works. In this step, you will write a short Python script that sends a single question to Gemini and prints the answer back in your terminal.
In this step, get ready to:
- Create a tutor.py script that sends a question to Gemini.
- Run the script and see the AI's response in your terminal.
Create your first Python script
You need a Python file that imports the SDK, connects to Gemini using your API key, and sends a question. The SDK handles all the networking behind the scenes.
- In VS Code, hover over the file explorer in the left sidebar. Click the New File icon (the page icon with a plus sign).
- Type tutor.py and press Enter to create the file.
- Paste the following code into tutor.py:
# Import the os module to read environment variables
import os
from google import genai
# Create a client using your API key from the environment
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
# Send a question to Gemini and store the response
response = client.models.generate_content(
model="gemini-3.6-flash",
contents="What is photosynthesis?"
)
# Print the AI's answer
print(response.text)
What does this code do?
- os.environ["GEMINI_API_KEY"] reads the API key you saved as an environment variable in the previous step. This keeps your key out of the code itself.
- genai.Client() creates a connection to the Gemini API using that key.
- client.models.generate_content() sends your question to the gemini-3.6-flash model and returns Gemini's answer.
- response.text pulls just the text portion of the response so you can print it.
- Save tutor.py by pressing Cmd+S (macOS) or Ctrl+S (Windows).
✔️ Awesome, I've got everything!
Great. Make sure you have saved tutor.py before moving on.
ⓧ I'd like to double check the full code
Here is the complete tutor.py file so far. Compare it with yours line by line.
import os
from google import genai
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
response = client.models.generate_content(
model="gemini-3.6-flash",
contents="What is photosynthesis?"
)
print(response.text)
Run the script and see Gemini respond
Your script is saved. Before you run it, what do you think Gemini will send back when you ask it about photosynthesis?
- Run your script by entering this command in the VS Code terminal:
python3 tutor.py
You should see a paragraph or two from Gemini explaining what photosynthesis is. The exact wording will differ each time, but you will get a real answer printed in your terminal.
What did you just prove?
This is the baby version of your tutor. It can answer one hardcoded question, but it has no personality and no memory of a conversation. Over the next steps, you will add both.
Not seeing a response?
- If you see an error about GEMINI_API_KEY, your environment variable may not be set in this terminal session. Run the export command from Step 1 again in the same terminal you are using to run the script.
- If you see an error about genai not being found, make sure your virtual environment is still active. You should see (venv) at the start of your terminal prompt.
- If the response mentions an invalid API key, double check that you copied the full key from Google AI Studio with no extra spaces.
Help me debug why my tutor.py script is not getting a response from Gemini.
Your API connection is confirmed and Gemini is talking back. Next up, you will give your tutor a personality using system instructions so it actually quizzes you instead of just answering.
Shape Your Tutor's Personality
In the last step, you got Gemini to answer a question about photosynthesis. The API connection is working. But the response read like a generic encyclopedia entry, not like a tutor.
System instructions let you define rules for how Gemini behaves. In this step, you'll write instructions that turn Gemini from a general assistant into a focused tutor that quizzes you and gives feedback.
In this step, get ready to:
- Write a system instruction that defines your tutor's personality and rules.
- Pass the system instruction to Gemini and see it respond as a quiz-giving tutor.
Write a system instruction for your tutor
A system instruction is a message you give the AI before the conversation starts. It defines the AI's role, personality, and rules for every response it generates.
- In tutor.py, find the line from google import genai and add this new import directly below it:
from google.genai import types
- Below the client = genai.Client(...) line, add this system instruction:
# Define the tutor's personality and behavior rules
SYSTEM_INSTRUCTION = """You are a friendly and encouraging tutor. Your job is to quiz the user on the topic they choose.
Rules:
- Ask one question at a time and wait for the user's answer
- When the user answers, tell them if they are correct or incorrect
- If they are incorrect, explain the right answer clearly
- Then ask a new question, gradually increasing difficulty
- Keep your responses concise (2-3 sentences max before asking the next question)
- Be encouraging and supportive"""
What does this system instruction do?
Each rule shapes a specific tutor behavior. "Ask one question at a time" prevents Gemini from dumping a list of questions all at once. "Explain the right answer" turns wrong answers into teaching moments.
"Gradually increasing difficulty" makes the tutor adapt to the learner's level. "Keep your responses concise" stops Gemini from writing essays when a few sentences will do.
- Save tutor.py.
The system instruction is defined, but it is not connected to the API call yet. You'll wire it up next.
Pass the system instruction to Gemini
The system instruction needs to reach Gemini through a configuration object. You'll also change the user prompt from a factual question to a topic name, so the tutor knows what subject to quiz you on.
- In tutor.py, find the response = client.models.generate_content(...) block at the bottom of your file.
- Find this code:
response = client.models.generate_content(
model="gemini-3.6-flash",
contents="What is photosynthesis?"
)
- Replace the entire block with this updated version, which adds a config parameter and changes the prompt to a topic name:
response = client.models.generate_content(
model="gemini-3.6-flash",
# Pass the system instruction through a config object
config=types.GenerateContentConfig(
system_instruction=SYSTEM_INSTRUCTION,
),
# Use a topic name instead of a factual question
contents="Python programming"
)
What changed in this call?
types.GenerateContentConfig(system_instruction=SYSTEM_INSTRUCTION) wraps your system instruction into a configuration object that Gemini reads before generating a response. Every response Gemini produces will follow the rules you defined.
The prompt changed from "What is photosynthesis?" to "Python programming". Instead of asking a question, you are naming a topic for the tutor to quiz you on.
- Save tutor.py.
Before you run this, think about what you expect the response to look like. Will Gemini answer a question about Python, or will it do something different?
- Run your updated script by running this command:
python3 tutor.py
The response should read like a tutor asking YOU a question about Python programming. Instead of a generic explanation, Gemini now introduces itself and quizzes you.
Not seeing a tutor-style response?
- Check that SYSTEM_INSTRUCTION is spelled exactly the same in both the variable definition and the config=types.GenerateContentConfig(system_instruction=SYSTEM_INSTRUCTION) line. Python variable names are case-sensitive.
- Make sure you imported types with from google.genai import types at the top of the file. Without it, Python does not know what types.GenerateContentConfig is.
- Confirm you saved the file before running the script.
Help me debug my system instruction setup.
✔️ Awesome, I've got everything!
Great. Double check you have saved tutor.py before moving on.
ⓧ I'd like to double check the full code
Here is the full tutor.py file at this point. Compare yours against it line by line.
import os
from google import genai
from google.genai import types
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
SYSTEM_INSTRUCTION = """You are a friendly and encouraging tutor. Your job is to quiz the user on the topic they choose.
Rules:
- Ask one question at a time and wait for the user's answer
- When the user answers, tell them if they are correct or incorrect
- If they are incorrect, explain the right answer clearly
- Then ask a new question, gradually increasing difficulty
- Keep your responses concise (2-3 sentences max before asking the next question)
- Be encouraging and supportive"""
response = client.models.generate_content(
model="gemini-3.6-flash",
config=types.GenerateContentConfig(
system_instruction=SYSTEM_INSTRUCTION,
),
contents="Python programming"
)
print(response.text)
Your tutor has a personality now. It quizzes you instead of just answering questions. Next up, you'll turn this single exchange into a back-and-forth conversation loop.
Build a Conversation Loop (The Broken Version)
Your tutor now has a personality. When you run the script, Gemini quizzes you like a real tutor instead of just answering a plain question.
But the script exits after a single response. A real tutoring session needs back-and-forth conversation. In this step, you'll add a conversation loop so you can keep sending messages to the tutor.
In this step, get ready to:
- Add a while True loop that keeps the conversation going.
- Test a multi-message exchange with the tutor.
Wrap your API call in a conversation loop
Your tutor currently handles one message and exits. To keep the conversation going, you need a loop that waits for your input, sends it to Gemini, and prints the response.
- In tutor.py, find these lines at the bottom of your file:
response = client.models.generate_content(
model="gemini-3.6-flash",
config=types.GenerateContentConfig(
system_instruction=SYSTEM_INSTRUCTION,
),
contents="Python programming"
)
print(response.text)
- Delete all of those lines and replace them with this conversation loop:
# Keep the conversation going until the user quits
while True:
user_input = input("You: ")
if user_input.lower() == "quit":
print("\nGoodbye!")
break
# Send the user's message to Gemini
response = client.models.generate_content(
model="gemini-3.6-flash",
config=types.GenerateContentConfig(
system_instruction=SYSTEM_INSTRUCTION,
),
contents=user_input
)
print(f"\nTutor: {response.text}\n")
What does this code do?
- while True: creates an infinite loop so the conversation keeps going until the user decides to stop.
- input("You: ") pauses the script and waits for you to type a message.
- if user_input.lower() == "quit": checks whether you want to exit. The .lower() call means "Quit", "QUIT", or "quit" all work.
- The generate_content() call is the same one from before, but now contents uses your typed input instead of a hardcoded topic string.
- Save tutor.py.
Seeing a syntax or indentation error?
- Make sure you deleted all 8 lines of the old code (the response = client.models.generate_content(...) block and the print(response.text) line). Leftover lines will cause errors.
- Python is whitespace-sensitive. Check that everything inside the while True: block is indented by exactly 4 spaces.
- help me fix a syntax error in my tutor.py conversation loop
Run the script and test a multi-message exchange
Before you run the script, think about this: when you answer the tutor's first question and then send a follow-up message, do you think the tutor will remember what it just asked you?
- Run the script by entering this command in your terminal:
python3 tutor.py
- Type a topic like Python programming and press Enter. The tutor asks you a question.
- Answer the tutor's question and press Enter.
- Send one more follow-up message and read the tutor's response carefully.
The tutor responds to each message as if it has never spoken to you before. It might re-ask the same question, ask something completely unrelated, or ignore your answer entirely.
Why does the tutor have no memory?
This is not a bug in your code. Each call to generate_content() sends the user's message to Gemini with zero context about what came before. Gemini has no idea what it asked you one second ago.
This is exactly the problem conversation history solves. You will fix this in the next step.
- Type quit and press Enter to exit the script.
Script crashes when you run it?
- If you see KeyError: 'GEMINI_API_KEY', your environment variable is no longer set. Re-run the export command from Step 1 to set it again.
- If you see an indentation error, make sure all lines inside the while True: block are indented consistently with 4 spaces.
- help me debug my tutor.py script that crashes on startup
✔️ Awesome, I've got everything!
Great. Double check you've saved tutor.py and you're ready for the next step.
ⓧ I'd like to double check the full code
Here is the full tutor.py file at the end of this step. Compare it against yours and make sure they match.
import os
from google import genai
from google.genai import types
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
SYSTEM_INSTRUCTION = """You are a friendly and encouraging tutor. Your job is to quiz the user on the topic they choose.
Rules:
- Ask one question at a time and wait for the user's answer
- When the user answers, tell them if they are correct or incorrect
- If they are incorrect, explain the right answer clearly
- Then ask a new question, gradually increasing difficulty
- Keep your responses concise (2-3 sentences max before asking the next question)
- Be encouraging and supportive"""
while True:
user_input = input("You: ")
if user_input.lower() == "quit":
print("\nGoodbye!")
break
response = client.models.generate_content(
model="gemini-3.6-flash",
config=types.GenerateContentConfig(
system_instruction=SYSTEM_INSTRUCTION,
),
contents=user_input
)
print(f"\nTutor: {response.text}\n")
You've proven the loop works, but you've also seen a critical gap. The tutor forgets everything after every message. In the next step, you'll give it a memory so it can actually hold a real conversation.
Give Your Tutor a Memory
In the last step, you saw your tutor fall apart during a real conversation. It repeated itself, ignored your answers, and had no idea what it asked you five seconds ago. That is what happens when every message is sent in isolation.
The fix is surprisingly simple. The google-genai SDK has a built-in chat module that tracks conversation history automatically. One swap and your tutor goes from amnesia to a real, connected tutoring session.
In this step, get ready to:
- Replace the broken generate_content() call with the SDK's chat API that manages history for you.
- Test a full multi-turn tutoring session where the tutor remembers everything you said.
Replace generate_content with the chat API
The method client.chats.create() creates a chat session object. Every time you call chat.send_message(), the SDK appends your message and the model's response to a running history. The next call includes everything said before it.
- In tutor.py, find the while True: line. Add the following code directly above it:
# Create a chat session that automatically tracks conversation history
chat = client.chats.create(
model="gemini-3.6-flash",
config=types.GenerateContentConfig(
system_instruction=SYSTEM_INSTRUCTION,
),
)
# Greet the user before starting the conversation loop
print("Welcome to your AI Tutor! Type a topic to get started.")
print("Type 'quit' to exit.\n")
What does this code do?
client.chats.create() builds a chat session tied to the gemini-3.6-flash model. It takes the same config with your SYSTEM_INSTRUCTION, so the tutor personality carries across every message.
The two print() lines give the user a quick greeting and instructions before the conversation loop begins.
- Save tutor.py and run it to confirm the new welcome messages appear:
python3 tutor.py
You should see "Welcome to your AI Tutor!" and "Type 'quit' to exit." printed before the You: prompt appears. Type quit to exit for now.
Not seeing the welcome messages?
- Make sure the two print() lines are outside the while True: loop, not indented inside it.
- Check that the chat = client.chats.create(...) block is placed above the print() lines and above the while True: loop.
Help me debug my tutor.py file. I added a chat session and welcome messages but they aren't printing.
Now update the loop to actually use the chat session. The old generate_content() call needs to go.
- Inside the while True: loop, find this block of code:
response = client.models.generate_content(
model="gemini-3.6-flash",
config=types.GenerateContentConfig(
system_instruction=SYSTEM_INSTRUCTION,
),
contents=user_input
)
- Replace that entire block with this single line:
response = chat.send_message(user_input)
Why is this one line enough?
The old generate_content() call needed the model name, config, and contents every single time because each call was independent. The chat object already knows the model and system instruction from when you created it. All you need to pass is the new message.
- While you are in the loop, also find the goodbye message:
print("\nGoodbye!")
- Replace it with a friendlier sign-off:
print("\nThanks for studying! Goodbye!")
- Save tutor.py.
✔️ Awesome, I've got everything!
Great. Make sure you have saved tutor.py before moving on to the test.
ⓧ I'd like to double check the full code
Your tutor.py should have the following sections in this order. Scroll through your file and confirm each one is present.
- The three import lines at the top (os, genai, types).
- The client = genai.Client(...) line.
- The SYSTEM_INSTRUCTION multi-line string.
- The new chat = client.chats.create(...) block you just added.
- The two print() welcome messages.
- The while True: loop using chat.send_message(user_input) (not generate_content).
Test the full tutoring experience
This is the moment of truth. Before you run the script, think about what should be different this time. When you answer the tutor's first question and send a follow-up, do you think the tutor will remember what it asked you?
- Run your tutor by entering this command:
python3 tutor.py
- Type a topic like Python programming and press Enter.
- Answer the tutor's question.
- Send a follow-up message and watch whether the tutor references your previous answer.
- Try getting a question wrong on purpose and see if the tutor explains the correct answer before moving on.
- Type quit when you are done.
The tutor should reference your previous answer, build on it, and adjust its next question based on how you are doing. Compare this to the broken version from Step 4. Same loop structure, completely different experience.
What changed under the hood?
Every time you call chat.send_message(), the SDK automatically appends your message and the model's response to the session's internal history. The next call sends the entire conversation so far, giving Gemini full context.
With generate_content(), each call was a blank slate. With send_message(), every call carries the full conversation. That is the only difference, and it changes everything.
Tutor still not remembering?
- Make sure you replaced the entire client.models.generate_content(...) block with chat.send_message(user_input). If both exist, the old call is still running.
- Check that chat = client.chats.create(...) is outside the while True: loop, not inside it. If it is inside the loop, a new chat session is created on every message, which wipes the history each time.
- Confirm your GEMINI_API_KEY environment variable is still set. If you opened a new terminal, you may need to re-export it.
Help me debug why my AI tutor still has no memory across messages.
Secret mission
Add a Score Tracker and Topic Menu
Your tutor can quiz you on any topic, but it has no idea how you are actually doing. In this secret mission, add a topic selection menu at startup and a running score that counts your correct and incorrect answers. When you quit, the tutor prints your final results.
Clean Up Your Resources
Clean Up Your Resources
This project runs entirely on your local machine and uses the free tier of the Gemini API. There are no ongoing costs to worry about.
Decide whether to keep your resources running, pause them to come back later, or delete them entirely.
Resources you used:
- Your project folder containing tutor.py and the venv virtual environment.
- A Gemini API key created in Google AI Studio.
- The GEMINI_API_KEY environment variable set in your terminal session.
Keep everything running
No action needed. Choose this if you are still actively building or want to keep experimenting with your tutor.
- Your project folder stays on your Desktop with all files intact.
- Your Gemini API key stays active in Google AI Studio. The free tier has no charges, so leaving it active costs nothing.
- The GEMINI_API_KEY environment variable only lives in your current terminal session. If you close the terminal and open a new one, you will need to set it again with export before running the script.
Pause - I'll come back to this later
Shut down running processes to free up memory. Your project files stay saved for when you return.
- Close your terminal. This ends the virtual environment session and clears the GEMINI_API_KEY environment variable from memory.
- Your project folder and all files inside it remain on your Desktop.
- When you come back, open your terminal, navigate to your project folder, reactivate the virtual environment with source venv/bin/activate, and set GEMINI_API_KEY again.
Delete - I don't want to use this again
Remove all project resources and start fresh. Follow each step below to clean everything up.
- Deactivate your virtual environment by running:
- If your virtual environment is not currently active, skip this command.
deactivate
- Delete your project folder. Run the command for your operating system:
macOS
cd ~/Desktop
rm -rf ai-tutor
Windows
cd ~\Desktop
rmdir /s /q ai-tutor
Different folder name?
If you named your project folder something other than ai-tutor, replace it with the name you chose in Step 1.
- Delete your Gemini API key from Google Cloud. Open the Google Cloud API Credentials page.
- Find the API key you created for this project and click the Actions icon next to it.
- Select Delete API key.
- In the Delete credential modal, click Delete to confirm.
What about the environment variable?
The GEMINI_API_KEY you set with export only exists in your current terminal session. Closing the terminal removes it automatically. No extra cleanup needed.
Nice Work!
Nice Work!
Nice work! You just built a personal AI tutor powered by Gemini 3.6 Flash that runs entirely in your terminal. Pick any topic, and it quizzes you, gives feedback, and adapts its questions based on how you are doing.
You've learned how to:
- Connected Python to the Gemini API and used system instructions to turn a generic AI model into a focused tutor with its own personality.
- Experienced firsthand why conversation history matters by building a version without it and watching the tutor forget everything. Then fixed it using the SDK's built-in chat API for automatic multi-turn conversations.
- Set up a complete Python project from scratch with a virtual environment and the google-genai SDK, proving you can build AI-powered applications from scratch.
- Secret Mission: Added a topic selection menu and a score tracker that counts correct and incorrect answers across the session.
Ready to quiz yourself?