The Personal Assistant We'll Build › Your Assistant's First Words
AI Agent HandbookAll chapters The Personal Assistant We'll Build › Your Assistant's First WordsOne section · Sections in this chapter7 / 13 ↓
Let's give you a tiny preview. Here's what the very first version of your assistant might look like: just a simple program that can respond to a prompt.
Example (GPT-5)
## Our assistant's humble beginning
## (Don't worry about the details yet; we'll cover this in Chapter 3)
import os
from openai import OpenAI
## Initialize the client with your API key
client = OpenAI(
api_key=os.getenv("OPENAI_API_KEY")
) # Set your key as an environment variable
def ask_assistant(user_message):
# Send a message to the language model and get a response
response = client.chat.completions.create(
model="gpt-5", # The language model we're using
messages=[
{
"role": "system",
"content": "You are a helpful personal assistant.",
}, # Sets the assistant's behavior
{"role": "user", "content": user_message}, # Your question
],
)
return response.choices[0].message.content
user_input = "What's the capital of France?"
answer = ask_assistant(user_input)
print(answer)Paris.
Simple, right? Just 16 lines of actual code. But this is where everything begins.
Let's break down what's happening here. We're using OpenAI's API to access GPT-5, a language model. We send it two types of messages: a system message (which sets the assistant's personality and behavior) and a user message (your actual question). The model processes these, generates a response, and sends it back. In Chapter 3, we'll explore exactly how this works and why each piece matters.
Right now, this assistant can only respond to one question at a time. It has no memory, no tools, no ability to plan or reason deeply. But by the end of the book, you'll have transformed this basic foundation into something far more capable.