This is a basic Express application with a /chat endpoint that forwards messages to ChatGPT's API. The purpose is to demonstrate Promptfoo's capabilities including identifying and remediating vulnerabilities. The system prompt is intentionally weak. This is not intended for production use in any way.
- Install dependencies:
npm install-
Create a
.envfile in the root directory -
Add your OpenAI API key to
.env:
OPENAI_API_KEY=your_openai_api_key_here
PORT=4000
Start the server:
npm startFor development with auto-reload:
npm run devThe server will start on port 4000 (or the port specified in your .env file).
Send a message to ChatGPT.
Request Body:
{
"message": "Hello, how are you?"
}Response:
{
"response": "I'm doing well, thank you for asking!"
}Health check endpoint.
Response:
{
"status": "ok"
}The API returns appropriate HTTP status codes:
400- Missing or invalid message field401- Invalid OpenAI API key429- Rate limit exceeded500- Server error or missing API key configuration