Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenAI Responses API Example

A simple Node.js application demonstrating the OpenAI API with a basic text-generation example using the Responses API (client.responses.create).

Prerequisites

  • Node.js 22 or newer (required by the openai v7 SDK)
  • An OpenAI API key

Setup

  1. Clone or download this repository
  2. Install dependencies:
    npm install
    
  3. Configure your OpenAI API key:
    • Open the .env file
    • Replace your_openai_api_key_here with your actual OpenAI API key
    OPENAI_API_KEY=your_actual_api_key
    

Usage

Run the example script:

npm start

This will execute a simple prompt asking for a one-sentence bedtime story about a unicorn using gpt-6-luna.

About This Example

The script demonstrates:

  • Loading environment variables with dotenv
  • Initializing the OpenAI client
  • Using system prompts to guide the AI's behavior
  • Setting the reasoning effort (reasoning.effort) to trade quality for speed and cost
  • Error handling for API requests

Modifying the Example

You can modify the openai.js file to:

  • Change the prompt
  • Adjust the reasoning effort (none, low, medium, high); temperature (0-2) only works with effort none
  • Try different models
  • Customize the system prompt
  • Add more messages to the conversation

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages