Build your own revision app at uni for free: a flashcard maker with a free AI API key
Get a free Gemini API key, write a Python flashcard maker, add spaced repetition and keep your lecture notes private.
On this page
With the Gemini API free tier you can build a working revision app without paying anything: a short Python script that reads your lecture PDFs and writes flashcards you can import into Anki. This guide shows you how to get a free key, build the flashcard maker, add a simple spaced repetition scheduler and stay within the free limits. You'll need basic Python and about an hour.
What you need: a coding agent and a free Gemini API key
There are two parts to this setup. The first is a free Gemini API key, which lets your own code send a lecture PDF to Google's model and get flashcards back. The second is optional: a coding agent that runs in your terminal and helps you write, run and fix the script. You can type the code below by hand, but an agent saves time when an error message makes no sense.
If you used Gemini CLI for this kind of thing, it has changed. Google announced the change on 19 May 2026: from 18 June 2026, Gemini CLI stopped serving free users and Google AI Pro and Ultra subscribers, who were pointed to Antigravity CLI instead. Antigravity CLI runs with the command agy, and accounts without a paid Google AI plan get a quota that refreshes weekly. Gemini CLI still works with paid API keys.
Keep the two parts separate in your head. The agent runs on its own quota, and your app runs on your API key, so asking the agent for help doesn't use up the limits your flashcard maker needs.
How to get a Gemini API key on the free tier
- Go to Google AI Studio and sign in. A personal Google account is simplest, because university accounts are managed by IT and some have AI Studio switched off.
- Choose "Get API key" and create a key in a new project.
- Open the Projects page in AI Studio and check that the project's tier says Free.
- Open the rate limit page in AI Studio to see your limits for each model.
- Save the key as an environment variable so it never appears in your code.
On macOS or Linux:
export GEMINI_API_KEY="paste-your-key-here"
pip install google-genai pydantic
On Windows, use setx GEMINI_API_KEY "paste-your-key-here" and open a new terminal. Never paste the key into a file you push to GitHub. Anyone who finds it can use your quota.
One rule to know before you start: Google's API terms say you must be 18 or over to use the APIs.
What the Gemini API free tier includes
The free tier costs nothing and needs no billing account. It covers the Flash and Flash-Lite models, and its limits apply to your whole project. Google's rate limits page explains that limits are measured as requests per minute, input tokens per minute and requests per day, but it no longer lists fixed free-tier numbers for most models. Your project's own figures are shown in AI Studio.
| Feature | Free tier | Paid (Tier 1) |
|---|---|---|
| Cost | £0 | Pay per token |
| You need | An active project | A linked billing account |
| Models | Flash and Flash-Lite | Adds Pro models |
| Limits | Per project, shown in AI Studio | Higher, per project |
| UK data use | Paid-service data terms apply | Prompts not used to improve products |
| Minimum age | 18 | 18 |
Source: Gemini API rate limits, Gemini API pricing and Gemini API terms. Last checked: 18 November 2026.
Daily limits reset at midnight Pacific time, which is 8am in the UK for most of the year. On the pricing page on 18 November 2026, gemini-3.8-flash was free on the standard tier, while gemini-3.1-pro-preview had no free tier. Model names change often, so check that page and use whichever Flash model your project lists as free.
Step by step: turn lecture PDFs into Anki flashcards
The script uploads each PDF, asks the model for question-and-answer pairs in a fixed format, then writes them to a CSV file that Anki can read. Asking for a fixed format (a Pydantic class) means you get clean data back, with no tidying up by hand.
- Put your lecture PDFs in one folder, for example
lectures/. - Save the code below as
make_cards.py. - Run
python make_cards.py lectures cards.csv. - Open
cards.csv, read through it and delete any card that doesn't match your slides. - In Anki, choose File, then Import, and pick
cards.csv.
# make_cards.py
import csv, sys, time
from pathlib import Path
from pydantic import BaseModel
from google import genai
MODEL = "gemini-3.8-flash" # use any Flash model your project shows as free
class Card(BaseModel):
front: str
back: str
PROMPT = """You are writing revision flashcards from a university lecture.
Write 15 to 25 cards. Each front is one clear question that tests one idea.
Each back is a short answer of one or two sentences, taken from the lecture only.
Prefer 'why' and 'how' questions over bare definitions.
Do not add facts that are not in the lecture."""
client = genai.Client() # reads GEMINI_API_KEY
def cards_for(pdf):
uploaded = client.files.upload(file=str(pdf))
try:
response = client.models.generate_content(
model=MODEL,
contents=[uploaded, PROMPT],
config={
"response_mime_type": "application/json",
"response_schema": list[Card],
},
)
return response.parsed
finally:
client.files.delete(name=uploaded.name)
def main(folder, out="cards.csv"):
pdfs = sorted(Path(folder).glob("*.pdf"))
with open(out, "w", newline="", encoding="utf-8") as f:
f.write("#separator:Comma\n#html:false\n#tags column:3\n")
writer = csv.writer(f)
for pdf in pdfs:
tag = pdf.stem.replace(" ", "_")
for card in cards_for(pdf):
writer.writerow([card.front, card.back, tag])
print(f"{pdf.name}: done")
time.sleep(10) # a pause between files keeps you under the per-minute limit
if __name__ == "__main__":
main(*sys.argv[1:])
The three lines starting with # are Anki file headers. They tell Anki the file uses commas, holds plain text and has tags in the third column, so each card is tagged with the lecture it came from. When you import, choose the Basic note type and the deck you want.
The prompt matters more than the code. Cards that ask "why" and "how" make you pull the idea out of memory, which does more for you than rereading. Our guide on how to revise your notes explains why that kind of retrieval works.
Google now recommends its newer Interactions API for new projects, but generate_content is still supported, and it's the simpler call to learn first.
How to add spaced repetition with a Leitner box
If you review in Anki, it schedules cards for you. A Leitner box is worth building if you'd rather quiz yourself in the terminal or want to see exactly how the scheduling works. Every card starts in box 1. Get it right and it moves up a box, which means a longer wait before you see it again. Get it wrong and it goes back to box 1.
| Box | Next review | When it moves |
|---|---|---|
| 1 | Tomorrow | Right: box 2 |
| 2 | In 2 days | Right: box 3 |
| 3 | In 4 days | Right: box 4 |
| 4 | In 8 days | Right: box 5 |
| 5 | In 16 days | Stays in box 5 |
A wrong answer sends a card from any box back to box 1. Save this as leitner.py and run python leitner.py cards.csv once a day:
# leitner.py
import csv, json, sys
from datetime import date, timedelta
from pathlib import Path
INTERVALS = {1: 1, 2: 2, 3: 4, 4: 8, 5: 16} # days until the next review
STATE = Path("boxes.json")
def load_cards(csv_path):
with open(csv_path, encoding="utf-8") as f:
lines = [line for line in f if not line.startswith("#")]
return [(row[0], row[1]) for row in csv.reader(lines)]
def main(csv_path):
state = json.loads(STATE.read_text()) if STATE.exists() else {}
today = date.today()
for front, back in load_cards(csv_path):
card = state.setdefault(front, {"box": 1, "due": today.isoformat()})
if date.fromisoformat(card["due"]) > today:
continue
input(f"\nQ: {front}\n(press Enter to see the answer)")
print(f"A: {back}")
right = input("Did you get it? (y/n) ").strip().lower() == "y"
card["box"] = min(card["box"] + 1, 5) if right else 1
card["due"] = (today + timedelta(days=INTERVALS[card["box"]])).isoformat()
STATE.write_text(json.dumps(state, indent=2))
print("\nDone for today.")
if __name__ == "__main__":
main(sys.argv[1])
Reviews never call the API. Once your cards exist, you can quiz yourself as often as you like without touching your free quota.
Staying inside the free limits and keeping your notes private
Most free-tier problems come from sending too much too quickly. Make cards once per lecture, straight after it, rather than for a whole module the night before an exam. Keep the pause between files. If you see a 429 RESOURCE_EXHAUSTED error, you've hit one of your project's limits: wait a minute, or until the daily reset. The script overwrites its output file each time it runs, so move the PDFs it has finished out of the folder, run it again with a new output file, such as python make_cards.py lectures cards2.csv, and import both files into Anki. A very long PDF uses more tokens, so split a 200-page reading pack into chapters.
Making extra API keys won't help. Limits apply per project, so every key in the same project shares one allowance.
On privacy, the UK position is better than many guides suggest. Google's API terms say that for users in the UK, the EEA and Switzerland, the paid-service data rules apply to every service, including the free quota. Under those rules Google doesn't use your prompts or responses to improve its products, though it logs them for a limited time to detect misuse and meet legal requirements. If you study outside those regions, for example on a year abroad, content sent on the free tier can be used to improve Google's products and read by human reviewers.
Uploaded files are kept for 48 hours by default, and the script deletes each one as soon as its cards are made. A few habits are worth keeping wherever you are:
- Upload only your own lecture slides and notes.
- Leave out anything with other people's personal details, such as placement notes or seminar lists.
- Keep decks made from lecture materials to yourself, since your university usually owns the content.
- Check your university's AI guidance, which can differ between revision and assessed work.
Medly: an AI study tool, free to start, that already makes flashcards from your notes
Building the app teaches you a lot, but you don't have to build it to get flashcards from your lectures. Medly is an AI study tool for university students that's free to start, with no card needed, and you can use it instead of your own flashcard maker or alongside it. Upload your lecture notes, slides and essays, and Medly turns them into personalised flashcard decks for each module.
From the same uploads you also get:
- summaries of each lecture, which Medly generates and you can edit
- a large question bank, with questions in the style your exams use
- practice papers built from your own lectures
- personalised marking that shows where you picked up marks and where you missed them
- a chat feature, so you can highlight anything in your slides or ask about a concept
The Gemini API, like other general AI tools and APIs, wasn't built for education. It does exactly what your prompt says, so you write the prompt, check every card against your slides, handle the rate limits and keep the script running. A general chatbot will comment on whatever you paste in, but it isn't working from your mark scheme unless you give it one. Medly was built for studying. It works from your own modules, marks your answers, and guides you with questions so you work things out yourself. It will help you plan an essay from your materials, and it won't write the essay for you. Our Medly vs Knowt comparison shows how Medly differs from a tool built mainly for flashcards.
| Option | Cost | Set-up | What you get |
|---|---|---|---|
| Your Gemini script | £0 on the free tier | Python, an API key, about an hour | Flashcards and a Leitner scheduler you maintain |
| General AI chatbot | Varies by tool | None | Answers to whatever you paste in |
| Medly | Free to start, no card | Upload your notes | Flashcard decks, editable summaries, a question bank, practice papers, marking and chat |
Source: Gemini API pricing and Medly for University. Last checked: 19 November 2026.
Gemini API practice questions with answers
These questions test the app you've just built. The last one extends it so it writes 5 exam-style questions per lecture, which gives you something closer to a real paper than flashcards alone.
Question 1: (2 marks)
A card is in box 2 of the Leitner scheduler above. You answer it correctly on 3 February 2027. Which box does it move to, and when is it next due? On that day you get it wrong. Which box does it go to, and when is it due next?
Answer
- A correct answer moves the card up one box, from box 2 to box 3.
- Box 3 has an interval of 4 days, so it is due on 3 + 4 = 7 February 2027.
- A wrong answer on 7 February sends it back to box 1.
- Box 1 has an interval of 1 day, so it is due on 8 February 2027.
Students often move a wrong card down one box. In this scheduler it always goes back to box 1.
Question 2: (1 mark)
Your script has made cards from four lecture PDFs in a row when it stops with a 429 RESOURCE_EXHAUSTED error. Which is the most likely cause?
A. Your API key has expired
B. You've gone over one of your project's rate limits
C. One of the PDFs is password-protected
D. Anki can't read the CSV file
Answer
B. A 429 error means a rate limit has been reached. Wait, then run the script again on the remaining files with a new output file name, so the cards you already have aren't overwritten, or lengthen the pause between files.
Question 3: (2 marks)
A friend suggests creating a second API key in the same AI Studio project to double your free daily requests. Explain whether this works.
Answer
- It doesn't work, because Gemini API rate limits are applied per project, not per API key (1 mark).
- Both keys draw on the same project allowance, so the total number of requests stays the same (1 mark).
Question 4: (4 marks)
Extend make_cards.py so that, for every lecture, it also writes 5 exam-style questions with a mark scheme to a separate file called exam_questions.csv. Describe the changes and write the new class and prompt.
Answer
- Add a Pydantic class for a question (1 mark):
class ExamQuestion(BaseModel):
question: str
marks: int
mark_scheme: str
- Add a prompt that asks for exactly 5 questions, each with a mark scheme (1 mark):
EXAM_PROMPT = """Write exactly 5 exam-style questions on this lecture, worth 2 to 10 marks each.
Mix recall, explanation and application. For each, give a mark scheme with one point per mark.
Use only content from the lecture."""
- In
cards_for, make a secondgenerate_contentcall withEXAM_PROMPTand"response_schema": list[ExamQuestion], before thefinallyblock deletes the uploaded file, so the same upload is used for both calls (1 mark). - Open
exam_questions.csvalongsidecards.csvand write one row per question: the question, the marks, the mark scheme and the lecture tag (1 mark).
Each lecture now uses two requests, so lengthen the pause between files to stay under your per-minute limit.
Writing questions is half the job. Marking your answers against a mark scheme is where the learning happens, and AI can do that well: in our marking study of more than 30,000 answers, each marked by two qualified examiners, top AI models agreed with examiners more closely than the examiners agreed with each other. If you'd rather spend the hour revising than building, Medly makes flashcards and exam-style questions from your own lectures, marks your answers and shows you how to pick up the next mark.
You can also download the setup checklist to keep next to you while you build.
Frequently asked questions
Is the Gemini API free tier really free?
Yes. You need an active project in Google AI Studio and no billing account. The Flash and Flash-Lite models are free within your project's limits, and newer Pro models are paid only.
Does Google use my lecture notes to improve its models on the free tier?
No, if you're in the UK. Google's terms apply the paid-service data rules to the free quota for users in the UK, the EEA and Switzerland, though prompts are logged for a limited time to detect misuse.
Can I still use Gemini CLI for free?
No. Since 18 June 2026, Gemini CLI no longer serves free users, who were moved to Antigravity CLI. Gemini CLI still works with paid API keys.
How many requests can I make on the free tier?
It depends on the model and your project. Google shows your exact requests per minute, tokens per minute and requests per day in AI Studio, and the daily count resets at midnight Pacific time.
Do I need to be 18 to use the Gemini API?
Yes. Google's API terms say you must be 18 or over to use the APIs, so a first-year who is still 17 should wait until their birthday.
Am I allowed to use AI flashcards at university?
Usually, yes. Flashcards for your own revision aren't submitted work, but check your university's AI guidance and keep decks made from lecture materials to yourself.
Is there a free AI tool that makes flashcards from lecture notes without coding?
Yes. Medly is free to start and turns your uploaded lecture notes, slides and essays into personalised flashcard decks, with editable summaries, practice papers and marking alongside them.