Skip to content

codeyani/openai-nodejs

Repository files navigation

OpenAI API Integration and Usage

This project demonstrates how to integrate and use the OpenAI API with a Node.js application.

Prerequisites

  • 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.

Getting Started

  1. Install the necessary dependencies:

    npm install
  2. Start the application:

    npm start
  3. Open http://localhost:3500 in your browser to see the result.

Testing with Postman

  1. Download Postman.
  2. Open Postman and import the JSON file OpenAI - NodeJS.postman_collection.json located at the root directory of this project.
  3. Use the imported collection to test the endpoints.

API 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 /

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published