GENERATIVE AI • LESSON 4

What Is a Prompt?

A prompt is the input or instruction you give to an LLM to tell it what you want it to do.

CORE IDEA

A prompt tells the LLM what you want.

Think of a prompt as the way you communicate a task to an AI model.

01

What Is a Prompt?

Suppose you ask an AI:

"Explain Python."

That sentence is a prompt. The LLM receives it and generates a response.

YOU "Explain Python." PROMPT LLM ANSWER

The important idea is simple: your prompt tells the model what task you want it to perform.

02

A Prompt Is More Than Just a Question

A common beginner mistake is thinking:

Prompt = Question

Not exactly. A prompt can contain an instruction, context, examples, rules, or several of these together.

SIMPLE

"Write a Python function."

BETTER

"Write a Python function that calculates the average of a list of numbers."

MORE SPECIFIC

"Write a Python function that calculates the average of a list of numbers. Use Python 3, keep the code simple, and explain it for a beginner."

All three are prompts. The difference is how much direction they give the model.

03

The Four Main Parts of a Good Prompt

A useful mental model is:

Instructions What should the AI do?
Context What information does it need?
Examples What should the expected behavior look like?
Constraints What rules should the output follow?

You do not need all four every time. Use the pieces that are useful for the task.

04

Instructions

An instruction tells the LLM what you want it to do.

"Summarize this article."

The instruction is: Summarize.

EXAMPLE 1

"Translate this sentence into Spanish."

EXAMPLE 2

"Write Python code to calculate factorial."

INSTRUCTION LLM TASK RESULT
05

Context

Context gives the LLM the information it needs to perform the task correctly.

Compare these two prompts:

WITHOUT CONTEXT

"Write a response."

WITH CONTEXT

"The customer has been waiting 10 days for the order. Write a polite response explaining that it will arrive tomorrow."

The second prompt gives the model enough information to produce a more useful response.

CONTEXT + INSTRUCTION LLM BETTER ANSWER
06

Examples

Sometimes the instruction alone is not enough. You can show the model examples of the behavior you want.

Suppose you want to classify customer messages:

Example 1:
"I love this product."
→ Positive

Example 2:
"The product arrived broken."
→ Negative

Example 3:
"The product arrived yesterday."
→ Neutral

Then give the model a new message:

"The product works perfectly."

The expected classification is: Positive.

Few-shot prompting

Providing a small number of examples to guide the model's behavior is commonly called few-shot prompting.

07

Why Are Examples Powerful?

Examples are especially useful when the task has several possible categories or a specific expected format.

For example, imagine these categories:

Complaint Question Refund Request Technical Issue General Feedback
"I want my money back."
→ Refund Request

"My product isn't working."
→ Technical Issue

"How long will shipping take?"
→ Question

"I really like the product."
→ General Feedback

Now the model has concrete examples showing how messages should be classified.

08

Constraints

A constraint tells the LLM what limitations or rules the output should follow.

WORD LIMIT

"Explain Python in 100 words."

NUMBER

"Give exactly 3 examples."

FORMAT

"Return only JSON."

INSTRUCTION + CONSTRAINT LLM CONTROLLED OUTPUT
09

Real-World Example — Product Description

Imagine you are building an AI system that generates product descriptions for an e-commerce website.

Product:
Wireless headphones

Instruction:
Write a product description.

Context:
30-hour battery life,
Bluetooth 5.3,
noise cancellation.

Constraints:
- Maximum 80 words
- Simple English
- Mention battery life
- Don't invent information

The prompt gives the model the task, the product information, and the rules it needs to follow.

INSTRUCTION What to do
CONTEXT Product information
CONSTRAINTS Output rules
LLM Product description
10

Practical Python Example

Now let's send a structured prompt to an LLM from Python.

from openai import OpenAI

client = OpenAI()

prompt = """
Explain Python to a complete beginner.

Requirements:
- Use simple English.
- Keep it under 100 words.
- Give 2 real-world examples.
"""

response = client.responses.create(
    model="gpt-5.6",
    input=prompt
)

print(response.output_text)

The variable prompt contains the instructions and constraints that we want the model to follow.

PYTHON APPLICATION PROMPT LLM API LLM GENERATED ANSWER
11

Practical Example — Customer Support

Imagine an AI customer-support system. The customer asks:

"My package hasn't arrived."

Your application retrieves the customer's order data.

Context:
Order #12345 is delayed.
Expected delivery is August 28.

Instruction:
Write a polite response to the customer.

Constraints:
- Be concise.
- Don't promise an earlier delivery date.
- Don't invent information.

The LLM can now generate something like:

GENERATED RESPONSE

I'm sorry for the delay. Your order #12345 is currently delayed and is expected to arrive by August 28.

The important point is that the application supplied the real order information. The LLM generated the natural-language response.

12

Practical Example — Text Classification

Suppose your application needs to classify customer messages into four categories:

Refund Technical Support Shipping General
Classify the customer's message.

Categories:
- Refund
- Technical Support
- Shipping
- General

Examples:

"I want my money back."
→ Refund

"My application keeps crashing."
→ Technical Support

"When will my package arrive?"
→ Shipping

"Your product is excellent."
→ General

Customer message:
"My order hasn't arrived yet."

The expected output is:

RESULT

Shipping

The examples make the classification behavior much clearer to the model.

13

Prompt vs Context

These two concepts are related, but they are not the same thing.

CONTEXT INSTRUCTION
Information the LLM needs to know. What you want the LLM to do.
"Customer order is delayed." "Write a response to the customer."
CONTEXT + INSTRUCTION LLM ANSWER
14

Don't Make Prompts Unnecessarily Huge

A common beginner mistake is thinking:

"The longer my prompt is, the better the answer."

That's wrong.

A long prompt can be useful for a complex task, but unnecessary instructions add noise and consume tokens.

SIMPLE TASK

"Explain Python simply."

BETTER FOR A COMPLEX TASK

"Explain Python to a beginner in simple English. Explain what Python is, where it is used, and give two real-world examples. Keep it under 200 words."

The goal

Give the model enough information to remove ambiguity — not as much information as possible.

15

The Real-World Prompting Process

In a production GenAI application, prompting is usually part of a larger application flow.

01 User Request
02 Application Gets Context
03 Application Builds Prompt
04 LLM Generates Response
05 Application Returns Answer
16

Connect Tokens, Context & Prompts

These three concepts are connected.

PART 1 Tokens

Pieces of text the LLM processes.

PART 2 Context

Information the LLM can use for the current task.

PART 3 Prompt

Instructions and information given to the LLM.

USER REQUEST CONTEXT + INSTRUCTIONS + EXAMPLES + CONSTRAINTS PROMPT TOKENIZATION LLM OUTPUT TOKENS ANSWER
REMEMBER THIS

A good prompt removes ambiguity.

  • A prompt tells an LLM what you want it to do.
  • Instructions describe the task.
  • Context provides relevant information.
  • Examples demonstrate the expected behavior.
  • Constraints control the output.
  • Good prompts are clear, not unnecessarily long.
QUICK CHECK

Test Your Understanding

What is a prompt?

Answer: The input or instruction given to an LLM to tell it what you want it to do.

What is the difference between context and instruction?

Answer: Context provides information the model needs, while an instruction tells the model what task to perform.

Why would you provide examples?

Answer: Examples show the model the expected behavior, which is especially useful for classification and specific output formats.

Should every prompt be extremely long?

Answer: No. A prompt should contain enough information to remove ambiguity without adding unnecessary instructions.

LESSON 4 • TOPIC COMPLETE

You now understand what a prompt is.

You know how instructions, context, examples, and constraints work together to communicate a task to an LLM.

NEXT TOPIC

Instructions

Next, we will look more closely at instructions and how developers control what an LLM should do.