#Say
1 messages · Page 1 of 1 (latest)
Certainly! Here is a recent example of OpenAI code for making a basic API request using the official OpenAI SDK in JavaScript, as shown in the latest documentation:
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);
To run this code, you need to install the OpenAI SDK with:
npm install openai
Then, save the code in a file (e.g., example.mjs) and execute it with Node.js:
node example.mjs
This will output the model's response to your prompt. This example reflects the most recent usage patterns for OpenAI's API and SDKs as of 2025 Developer quickstart.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@quick pelican Kapa.ai is still learning and improving, please let me know how I did by reacting below.