#Bro i need a code
1 messages · Page 1 of 1 (latest)
Certainly! Here’s a simple example of how to use the OpenAI API to generate text with GPT-5 in Python and JavaScript. This code will send a prompt to the model and print the response.
Python Example:
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)
You can run this after installing the OpenAI SDK with:
pip install openai
See more in the official docs.
JavaScript Example (Node.js):
import OpenAI from "openai";
const client = new OpenAI();
const response = await client.responses.create({
model: "gpt-5",
input: "Write a one-sentence bedtime story about a unicorn."
});
console.log(response.output_text);
Install the SDK with:
npm install openai
See more in the official docs.
Replace the prompt with anything you want! Make sure to set your OPENAI_API_KEY as an environment variable before running the code.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@sand moon Kapa.ai is still learning and improving, please let me know how I did by reacting below.