What Is Context?
Context is the information given to an LLM so it can understand what you are talking about and produce a relevant answer.
Context gives the LLM the information it needs for the current request.
Think of context as the information the model can see while answering your question.
A Simple Example
Imagine you tell an AI:
Then you ask:
The second question makes sense because the previous message provides context. The AI understands that you are asking about learning Python.
The previous information is part of the context.
Context vs Question
These are different things.
What the user asks now
"Where is my order?"
Information needed to answer
Order #10025
Status: Shipped
Delivery: August 27
Real-World Example — E-commerce
Imagine you are building an AI assistant for a Magento store.
A customer asks:
The LLM alone does not know the customer's latest order status. Your application needs to retrieve the real order information first.
Status: Shipped
Delivery: August 27
Your order #10025 has been shipped and is expected to arrive on August 27.
Notice the important architecture:
Where Can Context Come From?
In real GenAI applications, context can come from different sources.
Previous messages in the conversation.
Customer, order, product, or business data.
Company policies, PDFs, manuals, and knowledge bases.
Live information such as weather, prices, or shipping.
Context in a Python AI Application
A developer can combine relevant information with the user's question before sending it to the LLM.
from openai import OpenAI
client = OpenAI()
customer_context = """
Order: #10025
Status: Shipped
Expected delivery: August 27
"""
question = "Where is my order?"
prompt = f"""
Customer information:
{customer_context}
Customer question:
{question}
Answer the customer clearly and simply.
"""
response = client.responses.create(
model="gpt-5.6",
input=prompt
)
print(response.output_text)
The important part is not the Python syntax. The important idea is that the application gives the LLM the relevant information it needs.
Context vs Model Knowledge
Do not confuse what the model learned during training with the information your application provides for the current request.
Information learned during model training.
Information provided for this request.
Generated using both.
For example, your LLM may understand what Magento is, but it does not automatically know that order #10025 was shipped five minutes ago.
Your application must provide that current information as context.
Context is the information the LLM can use for the current request.
- Context helps the LLM understand what the user is talking about.
- Context can come from conversations, databases, documents, APIs, and tools.
- The LLM's learned knowledge is different from the context provided by your application.
- Real AI applications often retrieve relevant data and provide it to the LLM as context.
Test Your Understanding
Answer: Information provided to an LLM so it can understand and answer the current request.
Answer: Conversations, databases, documents, APIs, tools, and other relevant data sources.
Answer: No. The application normally retrieves the current order information and provides it as context.
You now understand what context is.
You know why context matters, how applications provide context to LLMs, and how databases, conversations, documents, and APIs can supply information for an AI response.