Step two of the path is driving a model from your own code instead of typing into a chat box. This is everything from the reel, plus the parts that would not fit in two minutes.
Part 1 said "get an API key" and never explained the word. Here it is, in plain English, once and for all.
Same AI. No website, no chat box, no login screen. Your code sends a message through the doorway and gets one back. That is the entire idea, and everything else on this page is detail hanging off it.
When you type into Gemini in a browser, the browser is doing this for you. An API just means you get to do it yourself, from your own program, so you can put it inside something you built.
A chat box can only ever be a chat box. The moment the model is reachable from code, it can sit behind a button, run on a schedule, read a file, answer an email, or process a thousand rows while you sleep. Every AI product you have ever used is on the other side of that doorway.
Verified 2026-08-20. Google AI Studio is the only major provider with a free API tier that needs no credit card and does not expire.
Where the key comes from. The free tier is generous enough that most first projects never leave it.
aistudio.google.com/apikey →On the free tier, what you type can be used to improve Google's models. The paid tier and Vertex AI do not do this. It is a fair trade for free access, but it means you do not paste anything private, anything belonging to a client, or anything you would not want read.
the actual terms →This is the mistake that turns a free experiment into a real bill, and almost every beginner makes it once.
Automated bots scan public code around the clock looking for keys, and the window between pushing one and it being found is measured in minutes, not days. The usual way people discover it is a billing spike, because someone else has been running their workload on your key.
GitHub will now try to stop you. Push protection blocks the commit and tells you which line the secret is on. Do not click through it.
The key lives in a separate file that your code reads at runtime, and that file never leaves your machine.
# .env <- this file holds the key
GOOGLE_API_KEY=your-key-here
# .gitignore <- this stops it ever being uploaded
.env
Two files, three lines total. That is the whole fix, and it is the difference between a free experiment and paying for a stranger's traffic.
Revoke it first, then worry about the git history. A key that is still valid is the problem;
a key in an old commit that no longer works is just embarrassing. Revoke, generate a new one,
put it in .env, and move on.
Every AI product you have ever used is this, repeated. Once you see the three parts you stop being confused by any SDK, in any language.
from google import genai
client = genai.Client() # reads GOOGLE_API_KEY from your .env
resp = client.models.generate_content(
model="gemini-2.5-flash", # 1. who
contents="Name three colours." # 2. what you want
)
print(resp.text) # 3. what came back
The single most confusing thing about moving from the chat box to code. Nobody warns you, and then nothing you build makes sense until you know it.
The model does not know what you asked ten seconds ago. It does not know who you are. Each call arrives with no past attached to it. Here is exactly that, run against the real API:
Every chat app you have used quietly sends the entire conversation back to the model on every single turn. What feels like memory is the app re-reading the whole history out loud, every time, before your new message.
Which means memory is not a feature you switch on. It is something you build, and it is much smaller than it sounds: keep the messages in a list, and send the list back.
history = [
{"role": "user", "parts": [{"text": "What's my name?"}]},
{"role": "model", "parts": [{"text": "I don't know your name."}]},
{"role": "user", "parts": [{"text": "My name is Rahman."}]},
{"role": "model", "parts": [{"text": "Nice to meet you, Rahman!"}]},
{"role": "user", "parts": [{"text": "What's my name?"}]},
]
resp = client.models.generate_content(model="gemini-2.5-flash", contents=history)
Why chat apps have a context limit. Why long conversations get expensive, since you are re-sending everything every turn. Why "it forgot what I said" happens. And why every chatbot tutorial has a list in it that you did not understand the point of.
One line, set before anything clever, that changes what the whole thing is.
It sits outside the conversation and applies to all of it. Same code, same question, and a completely different product on the other side. Both of these are real runs:
Most of what people call "building an AI app" is really writing a good system prompt and then wrapping a button around it. Before you reach for anything complicated, change your words and run it again. It is free, it is instant, and it is usually the answer.
Nobody tells you when a step is done, so you keep going long past the point of usefulness. Here is the line for step two.
If you can open your script, edit the system prompt, run it again, and get behaviour you intended, you understand this step. Everything after that is building, not learning.
You do not need to understand tokens, embeddings, fine-tuning, or vector databases to be past this line. Those come later, and most of them never come at all.
Everything here is free and current as of 2026-08-20.
The official first-call guide. Python and JavaScript side by side, so it works whichever language you picked in Part 2.
ai.google.dev/gemini-api/docs/quickstart →Where system instructions and multi-turn conversations are documented properly. Read this once you have your first call working, not before.
ai.google.dev/gemini-api/docs/text-generation →What you actually get before anything costs money. Worth reading once so you know where the ceiling is instead of guessing.
ai.google.dev/gemini-api/docs/rate-limits →The library that reads your .env
file. This is the tool that keeps the key out of your code.
Turn it on for your repos. It blocks a commit that contains a secret before it can ever become public, which is the cheapest insurance available.
docs.github.com → push protectionRight now it can only answer. Next it gets tools, so it can do things: read a file, search the web, call your code. That is where a script stops being a script and starts being an agent.
follow @rahmanbuilds →Free tools, honest feedback on your work, and people who answer. Job hunters, builders and learners.