This is a simple node-express API application to interact with OpenAI.
- Clone the repository.
npm install- Copy the
.env.templateto a.envfile; add your credentials. - Run
node --env-file=.env index.jsto start the server.
You can interact with the server using Postman or any other favorite API client (e.g., cURL).
To test the API, execute a POST request to http://localhost:8080/interact.
The request should have a body in the following format:
{
"prompt": "Here is some user input that will be sent to OpenAI."
}Using cURL, this could look like this:
curl -X POST \
-H "Content-Type: application/json" \
-d '{"prompt": "Here is some user input that will be sent to OpenAI."}' \
http://localhost:8080/interact