ChatGPT Cloud Service is a Node.js cloud backend written in TypeScript that allows developers to easily implement the ChatGPT service into their applications for their users. This service handles the authentication token and modifies the requests before passing them to the ChatGPT API.
By using this microservice, developers no longer need to expose their API keys to users, providing a secure way to add ChatGPT functionality to their apps.
- Securely integrate ChatGPT into your applications
- Modify and customize requests before sending them to the ChatGPT API
- Easy-to-use TypeScript interface
- Deployable as a containerized application
- Manage user authentication tokens
- Planned features:
- Database integration
Before using the ChatGPT Microservice, make sure you have the following installed:
- Node.js
- npm
- ChatGPT API access token
- Docker (optional, for containerization)
- [Optional] Firebase Authentication
-
Clone the repository:
git clone https://github.com/arihantparsoya/chatgpt-cloud-service.git
-
Navigate to the project directory:
cd chatgpt-cloud-service
-
Install the dependencies:
npm install
-
Open the
.env
file in the project root directory. -
Set your ChatGPT API key in
.env
file:CHATGPT_API_KEY=your-api-key
To add context and information to your prompts before sending it to ChatGPT, add the additional details as message in the chatController.ts file.
-
Start the project:
npm start
-
The service will be running at
https://localhost:3000
. -
Make a POST request to
https://localhost:3000/chat
with the following parameters:Example using cURL:
curl --location 'https://localhost:3000/chat' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer USER_BEARER_TOKEN' \ --data '{ "model": "gpt-3.5-turbo", "messages": [ { "role": "system", "content": "you are a helpful assistant" }, { "role": "assistant", "content": "Hi there! How can I assist you?" }, { "role": "user", "content": "What is the population of USA" } ] }'
-
The microservice will modify the request and forward it to the ChatGPT API. The response from the API will be returned to the user.
-
Build the Docker image:
docker build -t chatgpt-cloud-service .
-
Run the Docker container:
docker run -p 3000:3000 chatgpt-cloud-service
The microservice will be accessible at
https://localhost:3000
.
If you want to add authentication to your APIs using Firebase, you can enable it by setting USE_AUTHENTICATION
variable in .env
file:
USE_AUTHENTICATION=false
Configure Firebase for authentication by adding your Firebase configurations in serviceAccountKey.json.
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.
Community
Join our Discord community to connect with other developers, ask questions, and get support. Link to Discord Community
This project is licensed under the Apache License 2.0. See the LICENSE file for more details.