Let’s start from scratch. First things first, let's understand what AI actually is.
You must have heard words like Artificial Intelligence, Machine Learning, Deep Learning, and Generative AI all thrown together. Think of it like a Russian nesting doll. AI is the biggest umbrella concept started way back in 1950 by Alan Turing (he came up with the famous Turing Test to see if machines can act like humans). Inside AI, we have Machine Learning, inside that is Deep Learning, and right at the cutting edge sits Generative AI.
Unlike old-school software where you manually hardcode rules, Gen AI actually creates new content—like text, emails, images, and even code-by finding patterns in massive amounts of data.
What is a "Pattern"?
When people say AI works on patterns, what does that actually mean?
Imagine you are shown 100 emails, and all of them are spam. If you look closely, you will spot a pattern-words like "Win a free lottery", "Click here urgently", or weird punctuation marks pop up repeatedly.
That is literally all an AI does. It scans massive amounts of text, emails, or code to catch hidden patterns (like which word usually follows another, or how sentences are structured). It doesn’t "think" like a human; it just uses heavy math and statistics to match these patterns.
What are Keywords and Tokens?
Before an AI can process your prompt, it breaks down your sentence. Let’s look at how keywords and tokens work.
Keywords: These are the important words in your prompt that carry the core meaning or intent. For example, in “Write a Python function to sort an array,” words like Python, function, and sort help guide the model’s focus.
Tokens: Large Language Models (LLMs) do not process text exactly as humans read it. They break text into smaller units called tokens. A token can be a complete word, part of a word, or even a punctuation mark. For example, a word like “ChatGPT” might be split into two or more tokens.
The Processing Pipeline: When you type a prompt, your text passes through a series of steps inside the model:
Text → Tokens → IDs (Numbers) → Vectors → Mathematical Processing → Probabilities → Output
Next-Token Prediction: The core job of an LLM is to use the context of the previous tokens to predict a likely next token. It repeats this process step by step to generate a response, one token at a time.
Decoding the Basics - AI, ML, DL, and Gen AI
First things first, let's clear up how all these terms are connected to each other. Think of it like Russian nesting dolls (one inside the other).
AI (Artificial Intelligence): This is the biggest umbrella term. It simply means any machine or software that can do tasks requiring human-like intelligence. It kicked off way back in 1950 with Alan Turing and his famous Turing Test, checking if a machine could fool humans into thinking it's human.
ML (Machine Learning): This sits inside AI. In old-school programming, we used to write hardcoded rules. In ML, instead of writing rules, we feed data to the computer and let it learn the rules automatically!
DL (Deep Learning): This is an advanced level of Machine Learning. It uses artificial neural networks inspired by the human brain to handle heavy, complex data like high-res images and massive text files.
Gen AI (Generative AI): This is the current hero! Unlike older models that only classified or recognized data, Gen AI actually creates brand new content-like emails, code, images, and stories.
Let’s Write Code! Setting Up Your Environment
Enough with the theory, let's get our hands dirty with some actual coding. What do we need to talk to OpenAI or Gemini via Python?
Step 1: Grab Your API Key
Just like you need an ATM card and a PIN to withdraw cash, you need an API Key to talk to AI models. It handles your identification, authorization, and usage tracking. Jump over to the OpenAI dashboard or Google AI Studio and generate your secret key.
Step 2: Install the Required Packages
Open your terminal or command prompt and run these commands:
pip install openai
pip install google-genai
If you ever need to upgrade your package manager or check if things installed properly:
python.exe -m pip install --upgrade pip
pip show openai
Step 3: Run Your First Code!
Now, let's write a quick script to verify everything is working fine.
For OpenAI:
from openai import OpenAI
client = OpenAI(api_key="YOUR_OPENAI_API_KEY")
response = client.responses.create(
model="gpt-5.1",
input="Hello! Give me a cool tech quote."
)
print(response.output_text)
For Google Gemini:
from google import genai
client = genai.Client(api_key="YOUR_GEMINI_API_KEY")
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="Hello! Give me a cool tech quote."
)
print(response.text)
Now that's a proper setup! We have a crystal-clear understanding of AI, ML, DL, patterns, and tokens, plus we've successfully set up our environment and run our first scripts.
In the next blog, we will look at how to secure these API keys using a .env file so you don't accidentally leak them on GitHub. Until then, keep coding and let me know if you run into any setup blocks!







Top comments (0)