2024-03-11.04-06-19.mp4
- A backend service that integrates Node.js with ChatGPT API.
- Create
.env
file and insert the key value pair below.
PORT=11000
- Execute the scripts.
# Highly suggest to use Node.js version >= 18.
yarn install
yarn start
# To run the test.
yarn test:all
- Use postman to send post request.
[REQUEST]
Method: POST
URL: http://localhost:11000/api/openai/chat
Raw-JSON:
"apiKey": "{{API_KEY}}",
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Say this is a test!"}],
"temperature": 0.7
- Further documentation can be found in OpenAI official docs.