Session 1 of 5 · 60 minutes
How AI Apps Work
See the shape of every AI app: input, a model, and output. Plan an app idea and sketch how it will work.
Goals
By the end of this session you can:
- Describe an AI app as input, model and output
- Explain what an API is and how an app uses one
- Name three things AI models are good at and three things they get wrong
- Write a one-page plan for an AI app idea
Words to know
- AI model
- A program trained on lots of examples that turns an input into an output, such as text, an image or a prediction.
- prompt
- The instructions and information you send to an AI model.
- API
- A way for one program to ask another program to do something, like a restaurant menu and waiter.
- hallucination
- When an AI model gives an answer that sounds confident but is wrong or made up.
- app
- A program that real people use to get something done.
The lesson
Step 1: Every AI app has three parts
Think about a translation app. You type a sentence. Something figures out the meaning and matches it with another language. The new sentence appears on your screen.
Almost every AI app follows the same shape:
- Input: what the user gives the app (text, a photo, a voice recording).
- Model: the AI that turns the input into something useful.
- Output: what the app shows or does with the result.
The model is only one part. The app is everything around it: the screen, the code that connects the parts, and the checks that make the result safe and useful. That is the part you will build.
Step 2: A pretend model
In this workshop we’ll start by writing a pretend model, a simple Python function that stands in for a real one. It lets us build and test the whole app without any special accounts.
def ask_model(prompt):
# A real model would think about the prompt.
# Our pretend model just returns a fixed reply.
return "I am a pretend model. You asked: " + prompt
user_input = "What is photosynthesis?"
answer = ask_model(user_input)
print(answer)I am a pretend model. You asked: What is photosynthesis?Later we will swap ask_model for a real one. Because the rest of the app only calls ask_model(prompt), nothing else has to change. That is good design.
Step 3: What is an API?
How does your app talk to a model that runs on a different computer? Through an API.
Think of a restaurant. You (the app) don’t walk into the kitchen. You tell the waiter (the API) what you want, using the menu. The waiter brings your request to the kitchen (the model) and brings back the food (the answer).
In code, an API request is usually:
- You send a request: a message that says what you want.
- The service sends back a response: the answer, often as structured data.
Here is what a request and response might look like as Python dictionaries:
request = {"prompt": "Explain gravity to a 9-year-old"}
response = {"text": "Gravity is the invisible pull that keeps us on the ground."}
print(response["text"])Gravity is the invisible pull that keeps us on the ground.Step 4: Strengths and limits
Modern language models are good at:
- Explaining things in simple words.
- Rewriting, summarizing and translating text.
- Brainstorming ideas.
They also get things wrong:
- They can hallucinate: state false things with total confidence.
- They can reflect bias from the data they learned from.
- They don’t know about events after their training, and may not know your local context.
So, a good AI app never treats the model’s answer as automatically true. It helps the user check it, and it is honest that an AI made it.
Try it: Ask any AI chat tool a question about something you know very well, such as your school or your own village or neighborhood. Did it get everything right?
Step 5: Plan before you build
Before writing code, write a plan. Answer these questions on one page:
- Who is the app for?
- What problem does it solve?
- Input → Model → Output. What goes in and what comes out?
- What could go wrong? And how will you check?
- What will the screen look like?
Good ideas for a first AI app are small and specific, like “a helper that explains a science word in simple language”, or “a bot that quizzes me on my vocabulary list”.
For the rest of this workshop you will build your app step by step.
Exercise
Spot the three parts
- Pick three apps you use that involve AI: a translator, a photo filter, a voice assistant, a recommendation list.
- For each, write the input (what you give it), the model's job (what it figures out) and the output (what you get back).
- For one of them, write what could go wrong if the model gets it wrong.
Need a hint?
Example: translator. Input: a sentence in Swahili. Model's job: find the matching English. Output: the English text.
Small project
One-page app plan
Design an AI app that solves a real problem for people you know. You will build a version of it over the next four sessions.
- Write one sentence: who is it for and what problem does it solve?
- Fill in the three parts: input, model's job, output.
- List three things that could go wrong and how you'd check the answer is right.
- Sketch the screen on paper: what does the user see and do?
- Pick a name. Share your plan with a partner and ask for one improvement.
Stretch it: Write the app's first function in Python: def ask_model(prompt): that returns a pretend answer.
Quiz
Check your understanding
Pick one answer for each question. Your score appears right in the page; nothing is sent anywhere.
Feedback on this lesson
Teachers and students: tell us what worked and what didn't. We read this to improve the curriculum.
Received
Thank you for the feedback.
The Education team reviews lesson feedback to improve the curriculum.
Preview mode: this form is not connected to a destination yet, so nothing was sent. Set its web address in src/data/config.json.