AI Engineer 2026 · Part 3

Your first AI call.
And why it forgets you.

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.

Everything on this page is free to follow. You need a Google account and about fifteen minutes. No credit card, no cloud billing setup, nothing to install beyond one library.
01

What an API actually is

Part 1 said "get an API key" and never explained the word. Here it is, in plain English, once and for all.

A doorway into the model

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.

Why that matters more than it sounds

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.

02

Get a key, free, no card

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.

  1. Open Google AI Studio
    Sign in with a normal Google account. There is no billing account to create and no card to add.
  2. Click Create API key
    It appears immediately. Copy it once and keep it somewhere private. Treat it exactly like a password, because that is what it is.
  3. Install the library
    One line, the same idea as the seventh thing from Part 2: you are borrowing code other people already wrote. You are never writing the model.

Google AI Studio free, no card

Where the key comes from. The free tier is generous enough that most first projects never leave it.

aistudio.google.com/apikey →

The honest catch read this

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 →
03

Where the key must never go

This is the mistake that turns a free experiment into a real bill, and almost every beginner makes it once.

The expensive mistake

Never put the key inside your code

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.

Do this instead

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.

If you already pushed a key

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.

how GitHub secret scanning works →
04

The three parts of every call

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.

PART ONE
Who you're talking to
Which model. A string, nothing more.
PART TWO
What you want
Your message. The thing you would have typed.
PART THREE
What came back
The response. Text you can now do anything with.

All three, in one real call

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
a real run · gemini-2.5-flash · 2026-08-20
$ python call.py Red Green Blue
05

It has no memory

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.

Every call starts from zero

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:

three separate calls, no history sent · real output
> What's my name? As an AI, I don't know your name or any personal information about you unless you choose to tell me. I don't have access to your identity. > My name is Rahman. Nice to meet you, Rahman! How can I assist you today? > What's my name? As an AI, I don't have access to any personal information about you, including your name. I don't remember past conversations or details about individual users unless you tell me within our current chat.
So why does ChatGPT feel like it remembers?

The model isn't remembering. The app is reminding it.

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.

The same conversation, with the list sent 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)
same question, history resent · real output
> What's my name? Your name is Rahman.

What this explains, once you know it

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.

06

The system prompt

One line, set before anything clever, that changes what the whole thing is.

A line telling the model who to be

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:

same code, one line different · real output
system = None > Name three colours. Red, blue, and green. system = "You are a pirate. Answer in one short pirate sentence." > Name three colours. Gold, black, and red, ahoy!

Why this is the highest-leverage line you will write

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.

07

Your finish line

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.

Step two is done when

You can change what it does by changing only your words, not your code.

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.

08

Where to go next, free

Everything here is free and current as of 2026-08-20.

Gemini API quickstart free

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 →

Text generation docs free

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 →

Free tier limits free

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 →

python-dotenv free

The library that reads your .env file. This is the tool that keeps the key out of your code.

pypi.org/project/python-dotenv →

GitHub push protection free

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 protection

Part 4 is giving it hands

Right 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 →

Questions about this? Ask in the Discord.

Free tools, honest feedback on your work, and people who answer. Job hunters, builders and learners.

Join free