Making a minimal Responses API call
Modern AI agents need a way to talk to large language models from inside ordinary Python programs. The OpenAI Responses API provides that bridge. It lets us send a prompt to a model and receive a structured response that our code can work with, rather than treating the model as something external or magical.
This lesson exists to remove the mystery around that first call. We want to see what the API is, how it fits into a Python program, and what a minimal request and response actually look like.
What the OpenAI Responses API is
The OpenAI Responses API is a single, unified interface for interacting with OpenAI models. It replaces older, more fragmented APIs and gives us a consistent way to send input and receive model output.
From our program’s point of view, it is just another HTTP-backed service. We construct a request, send it through a client library, and get back a response object. That response contains text and metadata we can inspect and use in code.
At this level, we do not worry about tools, memory, or workflows. We only care about making a request and seeing something come back.
Installing and importing the OpenAI client library
To call the Responses API from Python, we use the official OpenAI client library. This library handles authentication, request formatting, and response parsing for us.
Installing the library is a command-line action:
pip install openai
Once installed, we import the client into our program:
from openai import OpenAI
This import gives us access to a client object that knows how to talk to the API.
Making a minimal API request
A minimal request creates a client and sends a single prompt to a model. We do not configure tools, context windows, or output formats yet.
Here is the smallest useful example:
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-4.1-mini",
input="Write a one-sentence description of Mars."
)
This code does three things. It creates a client, specifies a model, and supplies a short input prompt. The call returns a response object that represents the model’s output.
At this stage, the important idea is that the model call is just a function call from Python’s perspective.
Supplying a simple input prompt
The input parameter is the text we want the model to respond to. For now, it can be a single string.
The prompt does not need special formatting or structure. It is simply passed through to the model as-is. Later lessons will show how to supply richer instructions and structured context, but a plain string is enough to get started.
Keeping the prompt simple makes it easier to see the cause-and-effect relationship between input and output.
Receiving a basic model response
The response returned by the API is an object, not just a string. It contains one or more output items, each with content.
To extract the generated text, we typically access the first output’s text content:
text = response.output_text
print(text)
This gives us the model’s reply as a Python string that we can print, store, or pass into other parts of our program.
The key shift here is mental. We treat the model’s output as data produced by a function call, not as conversational prose meant only for a human reader.
Conclusion
At this point, we have made a complete round trip from Python to a language model and back. We know what the OpenAI Responses API is, how to install and import the client library, how to send a minimal request, and how to extract a basic response.
That is enough orientation to remove the friction around “calling the model.” From here on, we can focus on shaping inputs and interpreting outputs in ways that support real agent behavior.