NodeJS wrapper to interact with OpenAI
This project is licensed under the MIT License. See LICENSE for more information.
- Node.js (version 14.X.X)
- Optional- Docker: Install Docker
-
Clone the repository:
git clone https://github.com/rajeshkumaravel/sb-nodejs-openai
-
Install dependencies:
npm install
-
Start the server:
npm start
-
Clone the repository:
git clone https://github.com/rajeshkumaravel/sb-nodejs-openai
-
Navigate to the project's root directory:
cd sb-nodejs-openai
-
Build the Docker image:
docker build -t sb-nodejs-openai .
This command will read the instructions from the Dockerfile and build an image with the name
sb-nodejs-openai
. -
Run the Docker container:
docker run -p 4400:4400 -d sb-nodejs-openai
This command will start a Docker container based on the
sb-nodejs-openai
image and map port 4400 from the container to port 4400 on your local machine. The-d
flag runs the container in detached mode, allowing it to run in the background. -
To stop the Docker container, use the following command:
docker stop <container_id>
Replace
<container_id>
with the ID or name of the running container. You can find the container ID by runningdocker ps
.
-
If you encounter any issues during the build or run process, make sure you have Docker properly installed and running on your system.
-
Check the Docker logs to see if there are any error messages or issues reported by the container. You can use the following command to view the logs:
docker logs <container_id>
Replace
<container_id>
with the ID or name of the running container.
-
Post setup of application, copy
.env.sample
file and paste it under root directory -
Rename the file as
.env
-
Update the required environment variable
# Your unique OPENAI API key value goes here OPENAI_API_KEY=<KEY_GENERATED_FROM_OPENAI_API>
The following API endpoints are available:
- Refer swagger documentation link for more details
- To access swagger; visit http://localhost:{PORT}/docs
HTTP Verbs | Endpoints | Action |
---|---|---|
POST | /api/fetch | To query with OpenAI |
POST | /api/fetch/description | To get description for given title |
POST | /api/fetch/keywords | To get keywords for given title |
POST | /api/fetch/topics | To generate topics or table of contents for given title |
POST | /api/fetch/images | To generate images for given title |