This project demonstrates how to integrate and use the OpenAI API with a Node.js application.
-
Must have an
OPENAI_API_KEY
from OpenAI -
Node.js v18+
-
Create a
.env
file in the root directory of your project and set your API key:OPENAI_API_KEY=<ADD_YOUR_API_KEY>
-
Download Postman for API testing.
-
Import the JSON file
OpenAI - NodeJS.postman_collection.json
located at the root directory of this project into Postman.
-
Install the necessary dependencies:
npm install
-
Start the application:
npm start
-
Open http://localhost:3500 in your browser to see the result.
- Download Postman.
- Open Postman and import the JSON file
OpenAI - NodeJS.postman_collection.json
located at the root directory of this project. - Use the imported collection to test the endpoints.
- Generate Text:
POST /openai/generate-text
- Generate Image:
POST /openai/generate-image
- Vision:
POST /openai/vision
- Text to Speech:
POST /openai/text-to-speech
- Speech to Text:
POST /openai/speech-to-text
- Index:
GET /