#Give me a code pls

1 messages · Page 1 of 1 (latest)

finite ruinBOT
#

Hi @gentle knoll. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

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:

  1. Install the OpenAI SDK with pip:
    pip install openai
    
  2. Save the code to a file (e.g., example.py).
  3. Set your OpenAI API key in your environment variables as OPENAI_API_KEY.
  4. Run the script:
    python example.py
    

You should see the model's generated story printed in your terminal.
Source: OpenAI Developer Quickstart

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: