A simple chat API server designed for testing with Promptfoo.
- Git
- Node.js v20 or higher
- npm (comes with Node.js)
- Promptfoo CLI - Install with:
npm install -g promptfoo
Option 1: Using Git (recommended)
git clone https://github.com/promptfoo/redscan-lite.git
cd redscan-lite
Option 2: Download ZIP
- Go to https://github.com/promptfoo/redscan-lite
- Click the green "Code" button
- Select "Download ZIP"
- Extract the ZIP file and open the folder
-
Open in your editor
code . # or use your preferred editor
- Use any editor you're comfortable with (VS Code, IntelliJ, Vim, Cursor, etc.)
- Please disable AI autocomplete/copilot features for the interview
-
Install dependencies
npm install
-
Start the server
npm start
The server runs on http://localhost:8080
-
Optional: Enable AI responses
export OPENAI_API_KEY=your-key-here npm start
The API requires authentication. Here's the complete flow:
curl -X POST http://localhost:8080/auth
Response: { "token": "550e8400-e29b-41d4-a716-446655440001", "ttl": 300 }
curl -X POST http://localhost:8080/session
Response: { "sessionId": "660e8400-e29b-41d4-a716-446655440002" }
curl -X POST http://localhost:8080/chat \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "x-session-id: YOUR_SESSION_ID" \
-H "Content-Type: application/json" \
-d '{"input": "Hello", "role": "engineering"}'
Response: { "message": "<response>", "usage": { "prompt_tokens": 10, "completion_tokens": 15, "total_tokens": 25 } }
Note: If no session ID is provided, one will be created and returned in the x-session-id
response header.
The included promptfooconfig.yaml
tests against a public demo API:
promptfoo eval
Note: The config uses a public Promptfoo demo endpoint. To test your local server, update the URL in promptfooconfig.yaml
to http://localhost:8080/chat
.