Every API Call Starts Fresh
The Core Fact: Every API Call Starts From Zero
When you send a request to client.responses.create(), the model that answers you has no idea it has ever spoken to you before. It doesn't remember the question you asked ten seconds ago. It doesn't remember your name, even if you introduced yourself in the previous call. It doesn't even know your last call happened, unless you explicitly tell it what happened by including that information in the current request.
This is one of the most important mental models to build correctly when you start working with the OpenAI API, because it explains almost every "why doesn't the chatbot remember what I said" bug a beginner runs into. The model isn't broken. It isn't being forgetful. It is doing exactly what a stateless API is designed to do: process the one request it was given, in isolation, and return a response.
Let's prove this to ourselves with code before going any further into the theory, because seeing the behavior directly makes the rest of this lesson click much faster.
Setup
You'll need the OpenAI Python SDK and an API key.
Installation
pip install openai python-dotenv
.env
OPENAI_API_KEY=your_api_key_here
Never commit this file or hard-code your key directly into a script. Load it from the environment instead:
import os
from dotenv import load_dotenv
from openai import OpenAI
load_dotenv()
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
In production, set OPENAI_API_KEY through your hosting platform's secrets manager (Render, Railway, AWS Secrets Manager, a Kubernetes secret, and so on) instead of shipping a .env file with your deployment at all. The .env file is a local-development convenience only.
Proving Statelessness With Two Calls
Here's the experiment. We'll tell the model our name in one call, then ask it to recall that name in a completely separate call.