#Give me a code pls
1 messages · Page 1 of 1 (latest)
Certainly! Here is a simple example code that uses the OpenAI API to generate a one-sentence bedtime story about a unicorn. This example is in Python and uses the official OpenAI SDK:
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-5",
input="Write a one-sentence bedtime story about a unicorn."
)
print(response.output_text)
To run this code:
- Install the OpenAI SDK with pip:
pip install openai - Save the code to a file (e.g.,
example.py). - Set your OpenAI API key in your environment variables as
OPENAI_API_KEY. - Run the script:
python example.py