Build an AI Study Buddy with Gemini

Call a real LLM API to build a quiz chatbot that remembers your answers.

Introduction

30 Second Summary

Ever wished you had a study partner who could quiz you on anything, at any time? That is exactly the kind of tool you are about to build.

In this project, you will create a command-line Study Buddy chatbot powered by Google Gemini. You will type a topic, and the AI will generate quiz questions, check your answers, and explain what you got wrong.

What You'll Build

You will type a topic into your terminal, and your AI study buddy will quiz you back and forth, checking your answers and adapting its questions based on how you are doing.

By the end of this project, you'll have:

  • A working Python script that calls a real LLM to generate quiz questions on any topic you choose.
  • An interactive quiz loop where you type your answers and get real-time feedback from the AI on whether you are correct.
  • Conversation memory that lets the AI remember what you already answered and adjust its questions based on your performance.
  • Secret Mission: an optional challenge to push your skills even further.

Are there any prerequisites?

You need a Google account to get a free Gemini API key. No prior Python or AI experience is required.

Before We Start

Before you start building, take a moment to lock in what you are creating and why it matters for your AI engineering journey.

Set Up Python and the Gemini SDK

Your Mac has Python installed, but it is version 3.9.6. The google-genai SDK requires Python 3.10 or higher, so your current version will not work.

In this step, you will install Python 3.13, grab a free API key from Google, and install the SDK that lets your code talk to the Gemini LLM.

In this step, get ready to:
  • Install Python 3.13 on your Mac.
  • Get a free Gemini API key from Google AI Studio.
  • Install and verify the google-genai SDK.
Install Python 3.13

The google-genai SDK requires Python 3.10 at minimum. Since macOS comes with Python 3.9.6, you need to install a newer version before you can write any AI code.

  • Open Terminal. Press Cmd+Space to open Spotlight, type Terminal, and press Enter.
  • Check your current Python version by running this command:
python3 --version

Look at the version number that appears and pick the tab that matches what you see.

✔️ I see Python 3.13 or higher

You already have the right version of Python.

  • Confirm the python3.13 command is available by running:
python3.13 --version

If you see Python 3.13.x, you are all set. Skip ahead to the next substep.

ⓧ I see an older version

macOS includes an older Python by default. The python.org installer adds Python 3.13 alongside your existing version without replacing it.

  • Open the Python downloads page in your browser:
  • python.org/downloads/macos
  • Find Python 3.13.15 in the Stable Releases list and click Download macOS installer.
  • Open the downloaded .pkg file.
  • Click Continue through each step of the installer, then click Install.
  • Once the installer finishes, close and reopen Terminal so it picks up the new version.
  • Verify the installation by running:
python3.13 --version

You should see Python 3.13.15 (or a similar 3.13.x version).

Why python3.13 instead of python3?

Your Mac still has the old Python at python3. The installer does not replace it. You will use python3.13 for the rest of this project to make sure you are always running the correct version.

ⓧ Command not found

Python is not available on your system yet. You will install it from the official Python website.

  • Open the Python downloads page in your browser:
  • python.org/downloads/macos
  • Find Python 3.13.15 in the Stable Releases list and click Download macOS installer.
  • Open the downloaded .pkg file.
  • Click Continue through each step of the installer, then click Install.
  • Once the installer finishes, close and reopen Terminal so it picks up the new version.
  • Verify the installation by running:
python3.13 --version

You should see Python 3.13.15 (or a similar 3.13.x version).

Still seeing command not found after installing?

  • Make sure you closed and reopened Terminal after the installation finished. The new Python path is only available in a fresh Terminal session.
  • Double-check that the installer completed successfully. Reopen the .pkg file and look for a green checkmark on the final screen.

Help me troubleshoot my Python 3.13 installation on macOS

Get your Gemini API key

To call the Gemini AI from your code, you need an API key. Google provides free API keys through Google AI Studio.

  • Open Google AI Studio in your browser.
  • Sign in with your Google account.
  • Click Get API key on the landing page.

What is an API key?

An API key is a unique string that identifies your application when it makes requests to a service. Google uses it to track your usage and enforce rate limits. On the free tier, your Gemini usage costs nothing.

  • Google AI Studio automatically creates a project and API key for new users. You should see your key on the API keys page.
  • If you do not see a key, click Create API key to generate one.
  • Copy your API key. You will need it in the next command.

Keep your API key secret

Your API key is like a password. Do not share it, commit it to Git, or paste it anywhere public. You will store it in an environment variable so it stays out of your code.

  • Switch back to Terminal and set your API key as an environment variable by running this command (replace your-key-here with the key you just copied):
export GEMINI_API_KEY="your-key-here"

What does this command do?

The export command creates an environment variable in your current Terminal session. Your Python code will read this variable to authenticate with the Gemini API, keeping the actual key out of your source code.

  • Verify the variable is set by running:
echo $GEMINI_API_KEY

You should see your API key printed in the terminal.

Seeing a blank line instead of your key?

  • Make sure you included the quotes around your key in the export command.
  • Check for extra spaces before or after the = sign. The command should have no spaces around =.

Help me set my GEMINI_API_KEY environment variable

This variable is temporary

The export lasts only for your current Terminal session. If you close Terminal and reopen it later, you will need to run the export command again before running your script.

Install the google-genai SDK

The SDK is the Python library that lets your code send prompts to Gemini and receive responses. It handles all the network communication behind the scenes.

  • Install the google-genai package by running this command:
python3.13 -m pip install google-genai

Why python3.13 -m pip instead of just pip?

Running python3.13 -m pip ensures the package is installed for Python 3.13 specifically. If you just ran pip, it might install the package for your old Python 3.9.6 instead.

Before you run the next command, what do you think will happen? Will the import succeed or fail?

  • Verify the SDK is installed correctly by running:
python3.13 -c "from google import genai; print('SDK ready')"

You should see SDK ready printed in your terminal. This confirms Python 3.13, the SDK, and your environment are all working together.

Seeing ModuleNotFoundError?

  • Make sure you used python3.13 -m pip install and not just pip install. The package needs to be installed for the same Python version you are using to run the command.
  • Try running the install command again. Sometimes a network timeout can cause a partial install.

Help me fix my google-genai SDK installation

  • Open VS Code. Press Cmd+Space to open Spotlight, type Visual Studio Code, and press Enter.

Your tools are locked and loaded. Next up, you will write your first lines of Python and watch the Gemini AI respond to your code.

Make Your First LLM Call

Your Python environment and the Gemini SDK are installed and verified. Now comes the exciting part.

Before building anything complex, you need to see an LLM respond to your code. In this step, you'll create a Python script that sends a prompt to Google Gemini and prints the AI's response to your terminal.

In this step, get ready to:
  • Create a study_buddy.py script that connects to the Gemini API.
  • Run the script and see the AI respond with a quiz question.
Create your Study Buddy script

The core AI engineering pattern is simple. Your code reads an API key, opens a connection to the AI, sends a prompt, and prints whatever comes back.

You need a project folder to keep your script in. Let's create one on your Desktop so it's easy to find.

  • Return to VS Code.
  • Open the integrated terminal by pressing Ctrl+` (macOS and Windows).
  • Move to your Desktop and create a project folder by running these commands:
cd ~/Desktop
mkdir study-buddy
cd study-buddy
  • Confirm the folder was created by running:
pwd

You should see /Users/<your-username>/Desktop/study-buddy in the output.

  • Now open this folder as your VS Code workspace. Click File in the top menu bar.
  • Click Open Folder.
  • Navigate to your Desktop, select the study-buddy folder, and click Open.
  • In the Explorer sidebar on the left, hover over the STUDY-BUDDY heading and click the New File icon (a page with a plus sign).
  • Type study_buddy.py and press Enter.

VS Code opens the empty file in the editor. This is where you'll write your first LLM call.

  • Copy the following code into study_buddy.py:
import os
from google import genai

def main():
    # Read the API key from the environment variable
    api_key = os.environ.get("GEMINI_API_KEY")
    if not api_key:
        print("Error: Please set the GEMINI_API_KEY environment variable.")
        print("Run: export GEMINI_API_KEY='your-key-here'")
        return

    # Create a client to connect to the Gemini API
    client = genai.Client(api_key=api_key)

    # Send a prompt to the AI and print the response
    response = client.models.generate_content(
        model="gemini-2.5-flash",
        contents="Give me one quiz question about Python programming"
    )
    print(response.text)

# Run the main function when the script is executed directly
if __name__ == "__main__":
    main()

What does this code do?

  • os.environ.get("GEMINI_API_KEY") reads your API key from the environment variable you set in the previous step. If the key is missing, the script prints a helpful error message and stops.
  • genai.Client(api_key=api_key) creates a connection to the Gemini API. Think of it as opening a phone line to the AI.
  • client.models.generate_content() sends your prompt to the gemini-2.5-flash model and returns the AI's response.
  • response.text extracts the text content from the AI's response so you can print it to the terminal.
  • Save study_buddy.py by pressing Cmd+S (macOS) or Ctrl+S (Windows).

✔️ Awesome, I've got everything!

Great. Make sure the file is saved and let's run it.

ⓧ I'd like to double check the full code

Compare your file against the full code below. Make sure every line matches, especially the indentation inside main().

import os
from google import genai

def main():
    # Read the API key from the environment variable
    api_key = os.environ.get("GEMINI_API_KEY")
    if not api_key:
        print("Error: Please set the GEMINI_API_KEY environment variable.")
        print("Run: export GEMINI_API_KEY='your-key-here'")
        return

    # Create a client to connect to the Gemini API
    client = genai.Client(api_key=api_key)

    # Send a prompt to the AI and print the response
    response = client.models.generate_content(
        model="gemini-2.5-flash",
        contents="Give me one quiz question about Python programming"
    )
    print(response.text)

# Run the main function when the script is executed directly
if __name__ == "__main__":
    main()
Run the script and see the AI respond

Your script is saved. It reads the API key, connects to Gemini, sends a prompt asking for a quiz question, and prints the response. Before you run it, take a second to predict what you think will happen.

Do you think the script will print a quiz question, an error, or something else entirely?

  • Open the integrated terminal in VS Code by pressing Ctrl+`.
  • Run your script by entering this command:
python3.13 study_buddy.py

After a moment, the AI prints a quiz question about Python programming directly in your terminal. The exact question is different every time because the AI generates it on the fly.

That is a real LLM responding to your code. Your prompt went to Google's servers, the AI generated a response, and your script printed it.

Seeing an error instead of a quiz question?

  • If you see Error: Please set the GEMINI_API_KEY environment variable, your API key is not set in this terminal session. Run export GEMINI_API_KEY="your-key-here" in the same terminal (replacing the placeholder with your actual key), then run the script again.
  • If you see ModuleNotFoundError: No module named 'google', the SDK was installed for a different Python version. Reinstall it with python3.13 -m pip install google-genai and try again.
  • If you see an IndentationError, check that every line inside main() is indented with exactly 4 spaces. Use the double-check tab above to compare your code line by line.

Still stuck? Help me debug this error when running study_buddy.py

Try a different topic

Change the contents string in your script to any topic you like, such as "Give me one quiz question about space exploration". Save and run again to see how the AI adapts its response.

Why is the response different every time?

LLMs are probabilistic. Instead of returning a fixed answer, they pick the next word based on a probability distribution. This means even the same prompt can produce a different quiz question each time you run the script.

You just made a real AI respond to your code. Next up, you'll turn this single call into an interactive quiz loop where you can actually answer the questions.

Build the Quiz Loop

Your script can talk to an LLM and print the response. That is a great start, but right now the experience is one-and-done.

A real study buddy asks a question, listens to your answer, and tells you whether you got it right. In this step, you will turn your single API call into an interactive quiz loop where you choose a topic, answer questions, and get feedback from the AI.

In this step, get ready to:
  • Add a topic prompt so the user can choose what to study.
  • Build a question-and-answer loop that keeps the quiz going.
  • Discover a key limitation of standalone API calls.
Replace the hardcoded prompt with a topic input

Right now your script always asks the same hardcoded question about Python programming. A study buddy should let the user pick any topic they want.

  • In study_buddy.py, find these lines below client = genai.Client(api_key=api_key):
    response = client.models.generate_content(
        model="gemini-2.5-flash",
        contents="Give me one quiz question about Python programming"
    )
    print(response.text)
  • Delete those five lines and replace them with this code:
    # Welcome the user
    print("Welcome to Study Buddy!")
    print("Type a topic you want to be quizzed on, or 'quit' to exit.\n")

    # Ask what topic to study
    topic = input("What topic do you want to study? ")
    if topic.lower() == "quit":
        return

What does this code do?

  • The two print() lines display a welcome message and tell the user how to exit.
  • input() pauses the script and waits for the user to type something. Whatever they type comes back as a string stored in topic.
  • topic.lower() == "quit" converts the input to lowercase before comparing, so "Quit", "QUIT", and "quit" all work.
  • Save study_buddy.py.
  • Run the script to confirm the welcome message appears:
python3.13 study_buddy.py

You should see the welcome message and the prompt What topic do you want to study? waiting for your input. Type any topic and press Enter. The script exits because there is nothing after the topic input yet.

Not seeing the welcome message?

  • Make sure you deleted all five lines of the old generate_content call and the print(response.text) line. Leftover code from the previous step can cause errors.
  • Check that the new code is indented with four spaces, at the same level as the client = genai.Client(...) line above it. Python is strict about indentation.
  • help me debug my study_buddy.py welcome message
Add the quiz question and feedback loop

The topic prompt works. Now the script needs to generate a quiz question, collect your answer, and send it back to the Gemini API for feedback. A while True loop keeps the quiz running until the user types quit.

  • In study_buddy.py, add this code directly below the if topic.lower() == "quit": block you just wrote:
    while True:
        # Generate a quiz question about the chosen topic
        response = client.models.generate_content(
            model="gemini-2.5-flash",
            contents=f"Give me one quiz question about {topic}"
        )
        question = response.text
        print(f"\nStudy Buddy: {question}\n")

        # Collect the student's answer
        answer = input("Your answer (or 'quit' to exit): ")
        if answer.lower() == "quit":
            print("Thanks for studying! Goodbye.")
            break

        # Send the answer back to the AI for feedback
        feedback_response = client.models.generate_content(
            model="gemini-2.5-flash",
            contents=f"The question was: {question}. The student answered: {answer}. Was this correct? Explain why."
        )
        print(f"\nStudy Buddy: {feedback_response.text}\n")

What does this code do?

  • while True: creates an infinite loop. The quiz keeps running until the learner types quit, which triggers break to exit the loop.
  • The first generate_content() call asks the AI for a quiz question. The f-string injects the user's chosen topic into the prompt.
  • The second generate_content() call sends both the original question and the user's answer back to the AI. The prompt asks the AI to grade the answer and explain why it is right or wrong.
  • Each API call is completely independent. The AI receives only what you include in that single prompt.
  • Save study_buddy.py.

Seeing an indentation error?

  • The while True: line must be indented with exactly four spaces, at the same level as the topic = input(...) line above it. Everything inside the loop needs eight spaces of indentation.
  • Make sure there is no gap between the return from the quit check and the start of the while True: loop. They should be adjacent lines at the same indentation level.
  • help me fix my indentation in study_buddy.py

✔️ Awesome, I've got everything!

Great. Double check you have saved study_buddy.py before moving on.

ⓧ I'd like to double check the full code

Scroll up and confirm your file contains each of these sections in order:

  • The import os and from google import genai lines at the top.
  • The def main(): function with the API key check and client creation (from Step 2).
  • The welcome messages and topic = input(...) prompt with the quit check (from the first chunk above).
  • The while True: loop with question generation, answer input, and feedback (from the second chunk above).
  • The if __name__ == "__main__": block at the very bottom.

Make sure the old generate_content call from Step 2 is completely gone. It should have been replaced by the welcome messages and topic prompt.

Test the quiz and spot the memory gap

The quiz loop is built. Before you run it, think about what you expect to happen when you answer several questions in a row. Will the AI remember what you got wrong on the first question when it asks the third one?

  • Run the script:
python3.13 study_buddy.py
  • Type a topic you know well, like world capitals or basic math.
  • Answer the first question. You should see the AI tell you whether you were correct, with an explanation.
  • Answer two or three more questions. Pay attention to whether the AI mentions anything about your earlier answers.
  • Deliberately get one wrong, then see if the AI circles back to that topic later.
  • Type quit to exit when you are done testing.

You will notice that each question stands completely alone. The AI does not remember what it asked before, what you got wrong, or what topic you are struggling with. Every question is generated from scratch as if the conversation just started.

Why does the AI forget everything?

Each generate_content() call is a standalone request. The API receives only the text you include in that single contents parameter. It has no access to previous calls.

This is how most LLM APIs work by default. Conversation memory is not automatic. You need to explicitly send the full conversation history with every request, or use a tool that manages it for you.

Getting an API error when you run the script?

  • Check that your GEMINI_API_KEY environment variable is still set. If you opened a new terminal window since Step 1, you need to run the export command again.
  • If you see a rate limit error, wait a minute and try again. The free tier has a limit of approximately 10 requests per minute.
  • help me fix my Study Buddy API errors

Your quiz loop works, but the AI has no memory. It cannot adapt to what you are struggling with because every question starts from zero. In the next step, you will fix this by adding conversation memory so the AI tracks the entire session.

Add Conversation Memory with Chat

Your quiz loop works, but you saw the problem firsthand in the last step. The AI forgets everything after each message. It has no idea what question it just asked you or what you got wrong.

Each generate_content() call is completely independent. The Gemini SDK has a built-in chat feature that fixes this. A chat session automatically tracks the full conversation history so the AI remembers every question and answer. In this step, you will replace those standalone calls with a chat session and give the AI a system instruction that defines its role.

In this step, get ready to:
  • Replace standalone API calls with a chat session that remembers context.
  • Add a system instruction to define the AI's quiz behavior.
  • Test that the AI remembers your answers and adapts its questions.
Create a chat session with a system instruction

Right now, every call to generate_content() is a one-off request. The AI has no way to know what question it just asked or what you answered. The chat API changes this by wrapping every message into a running conversation that the SDK manages for you.

The first change is a new import. You need the types module to configure the chat session with a system instruction.

  • In study_buddy.py, find this line at the top of the file:
from google import genai
  • Add this import directly below it:
from google.genai import types

Now you need to replace the old quiz loop with a chat session. The entire while True: block and everything inside it will be replaced with new code.

  • Scroll down to the while True: line inside your main() function.
  • Find this block of code:
    while True:
        response = client.models.generate_content(
            model="gemini-2.5-flash",
            contents=f"Give me one quiz question about {topic}"
        )
        question = response.text
        print(f"\nStudy Buddy: {question}\n")

        answer = input("Your answer (or 'quit' to exit): ")
        if answer.lower() == "quit":
            print("Thanks for studying! Goodbye.")
            break

        feedback_response = client.models.generate_content(
            model="gemini-2.5-flash",
            contents=f"The question was: {question}. The student answered: {answer}. Was this correct? Explain why."
        )
        print(f"\nStudy Buddy: {feedback_response.text}\n")
  • Delete that entire while True: block. Keep the if __name__ == "__main__": block at the bottom of the file.
  • In the gap where the old loop was, paste this code to create a chat session:
    # Create a chat session with a system instruction
    chat = client.chats.create(
        model="gemini-2.5-flash",
        config=types.GenerateContentConfig(
            # Tell the AI how to behave for the entire conversation
            system_instruction=(
                "You are a study buddy. Ask the student one quiz question "
                "at a time about their chosen topic. After they answer, tell "
                "them if they are right or wrong and explain why. Then ask a "
                "follow-up question. Adjust difficulty based on how they are "
                "doing."
            ),
        ),
    )

What does this code do?

  • client.chats.create() opens a chat session instead of making isolated API calls. The SDK automatically stores every message you send and every response the AI returns.
  • system_instruction gives the AI a permanent set of rules it follows for the entire conversation. It tells the AI to quiz you, give feedback, and adjust difficulty. The AI reads this before every response but the learner never sees it.
  • types.GenerateContentConfig wraps the configuration options (like the system instruction) into a single object the SDK understands.

The chat session is ready, but it has no messages yet. The next chunk sends the first message and builds a simpler loop around it.

Send messages through the chat session

With the old loop gone, the conversation flow becomes much simpler. The first message sends the topic, and every message after that sends the user's answer. The chat session handles memory automatically.

  • Directly below the chat creation code you just pasted, add this code to send messages and run the quiz loop:
    # Send the topic as the first message in the conversation
    response = chat.send_message(f"Quiz me on: {topic}")
    print(f"\nStudy Buddy: {response.text}\n")

    # Keep the conversation going until the user quits
    while True:
        answer = input("Your answer (or 'quit' to exit): ")
        if answer.lower() == "quit":
            print("Thanks for studying! Goodbye.")
            break

        # Send the answer - the chat remembers the full history
        response = chat.send_message(answer)
        print(f"\nStudy Buddy: {response.text}\n")

What changed from the old loop?

  • chat.send_message() replaces both generate_content() calls. Every message you send is automatically appended to the conversation history.
  • You no longer need to manually paste the question and answer into a new prompt. The AI already knows what it asked and what you said.
  • The first send_message() kicks off the quiz by telling the AI the topic. After that, the loop only sends answers.
  • Save study_buddy.py.

Seeing a red underline on types?

  • Make sure the line from google.genai import types is directly below from google import genai at the top of the file.
  • Check for typos in the import line. It must be google.genai (not google.generativeai or google_genai).
  • help me fix a types import error in my study_buddy.py

✔️ Awesome, I've got everything!

Great. Double check you have saved study_buddy.py before moving on.

ⓧ I'd like to double check the full code

The full file is built from the chunks above. Scroll up and confirm each section is present in this order:

  • Imports at the top: os, genai, and types.
  • The main() function with the API key check, client creation, welcome message, and topic input (unchanged from before).
  • The client.chats.create() block with the system instruction (chunk 1).
  • The first chat.send_message() call, followed by the while True: loop (chunk 2).
  • The if __name__ == "__main__": block at the very bottom.
Test conversation memory

This is the moment of truth. In the last step, the AI forgot everything between questions. This time, the chat session should give it full memory of the conversation.

Before you run the script, think about this: what do you expect to be different about the AI's behavior compared to Step 3?

  • Run your updated script by running this command:
python3.13 study_buddy.py
  • Enter a topic when prompted (try something you know well, like "Python programming" or "world geography").
  • Answer the first question correctly.
  • Answer the second question incorrectly on purpose.
  • Watch the AI's third question. It should reference what you got wrong and adjust.

You should see the AI reference your earlier answers in its follow-up questions or feedback. For example, it might say something like "You struggled with X earlier, so let's try another question about that." The AI now remembers the entire conversation.

  • Type quit to exit when you are done testing.

Why does this work now?

In Step 3, each generate_content() call sent a brand-new request with no history. The AI literally could not see what happened before.

With client.chats.create(), the SDK bundles every previous message into each new request behind the scenes. The AI receives the full transcript every time. The more you talk, the more context it has to work with.

AI still not remembering your answers?

  • Make sure the old client.models.generate_content() calls are completely gone. If any remain, those messages bypass the chat session.
  • Check that your while True: loop uses chat.send_message(answer) and not client.models.generate_content().
  • Try answering at least three questions to give the AI enough context to start referencing earlier answers.
  • help me debug why my Study Buddy AI is not remembering conversation history

Secret mission

Add Structured JSON Output

Your Study Buddy works, but the AI returns free-form text that your code cannot reliably parse. What if you want to keep score automatically, or display questions with neat numbered options? In this Secret Mission, you will make the AI return structured JSON data and parse it with a Pydantic model so your code can score answers on its own.

Clean Up Your Resources

Clean Up Your Resources

This project uses the Gemini API free tier, so there are no ongoing costs. Decide whether to keep your resources, pause them to come back later, or delete them entirely.

Resources you used:

  • A Gemini API key linked to your Google account (free tier, no charges).
  • Python 3.13 installed on your Mac alongside your existing Python 3.9.6.
  • The study_buddy.py project file on your Desktop.
  • Python packages (google-genai and pydantic) installed with pip.

Keep everything running

No action needed. Choose this if you plan to keep building on your Study Buddy or want to experiment with the Gemini API.

  • Your Gemini API key stays active on the free tier at no cost.
  • Python 3.13 coexists with your existing Python version and takes up minimal disk space.
  • Your study_buddy.py file stays on your Desktop, ready to run anytime.
  • The GEMINI_API_KEY environment variable only lasts for your current terminal session. Next time you open a terminal, re-export it before running the script.

Pause - I'll come back to this later

There are no running processes or ongoing costs to worry about. Choose this if you want to take a break and return later.

  • Close VS Code and your terminal.
  • Your study_buddy.py file and Python 3.13 installation stay in place on your Mac.
  • When you return, open a new terminal and re-export your API key by running:
export GEMINI_API_KEY="your-key-here"
  • Then run python3.13 study_buddy.py to pick up where you left off.

Delete - I don't want to use this again

Remove all project resources and start fresh. Follow each step below to clean everything up.

Delete your Gemini API key:

  • Open aistudio.google.com/app/apikey in your browser.
  • Find the API key you created for this project.
  • Click the trash icon next to the key to delete it.

Uninstall the Python packages:

  • Run this command in your terminal to remove the SDK and Pydantic:
python3.13 -m pip uninstall google-genai pydantic -y

Delete the project file:

  • Run this command to remove study_buddy.py from your Desktop:
rm ~/Desktop/study_buddy.py

Clear the environment variable from your current session:

  • Run this command to remove the API key from your terminal session:
unset GEMINI_API_KEY

Optionally, uninstall Python 3.13:

  • Python 3.13 is installed separately from your system Python, so removing it will not break anything.
  • Run these commands to remove the Python 3.13 framework and application folder:
sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.13
sudo rm -rf "/Applications/Python 3.13"

Nice Work!

Nice Work!

Nice work! You just built a fully interactive Study Buddy chatbot powered by Google Gemini. From your very first LLM API call to a multi-turn quiz conversation with memory, you created a real AI application from scratch.

You've learned how to:

  • Made your first LLM API call using the Google Gemini SDK and saw the AI respond to your Python code.
  • Built an interactive quiz loop that takes user input, sends answers to an LLM, and delivers real-time feedback.
  • Added conversation memory with the Gemini chat API so the AI remembers previous questions, tracks performance, and adapts follow-up questions.
  • Completed an optional Secret Mission to push your AI engineering skills even further.

Ready to quiz yourself?