Using OpenAI with SDK


OpenAI allows for access to different LLM models using APIs. I created my first simple exploration by following a few steps.

First, I had created an account with OpenAI- you can do so by funding your account with as little as $5. Then, I created a project and within that project, created an API key. That key, when used with a program on my client workstation, would allow me to access a model that I selected.

Next, I created a project file titled ‘example.py’. I then set an environmental variable to hold that API secret key that I had just created. That environmental key is held privately within my computer and shared with the file when it is executed.

Now for the code of “example.py” itself:

from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-5.5",
input="Write a one-sentence bedtime story about a unicorn."
)
print(response.output_text)

In order to run this, I needed to install a virtual environment:

python3 -m venv .venv
source .venv/bin/activate
[ the venv environment is now running]
python example.py

And my terminal output the LLM model’s bedtime story:


Very cool!


Leave a comment