monish563/NU-KIOSK-API
Northwestern CS Kiosk API
REST API backend for the Northwestern CS Department Kiosk. This is a stripped-down version optimized for integration with external systems (e.g., speech-to-text/text-to-speech).
Quick Start
1. Install Dependencies
pip install -r requirements.txt2. Configure Environment
cp .env.example .env
# Edit .env and add your API key3. Run the Server
python -m backend.mainThe API will be available at http://0.0.0.0:8000
Deploy to Hugging Face Spaces
Deploy this API as a public endpoint so your manager (or STT/TTS systems) can send requests from anywhere.
1. Create a new Space
- Go to huggingface.co/spaces
- Click Create new Space
- Choose Docker SDK, Blank template
- Name it (e.g.
monish563/NU-Kiosk-API) - Create, then push this
kiosk-apifolder to the Space repo
2. Add secrets (Settings → Variables and secrets → Secrets Private)
*At least one LLM API key is required. KIOSK_HF_TOKEN is required if KIOSK_HF_DATASET_REPO is set.
3. Endpoint URL for your manager
Once the Space is built and running, the base URL will be:
https://<your-username>-<space-name>.hf.spaceMain endpoint (for STT → TTS flow):
POST https://<your-username>-<space-name>.hf.space/api/query
Content-Type: application/json
{"question": "Where is Professor Hammond's office?"}Response: {"answer": "...", ...} — send answer to your TTS system.
API Reference
Health Check
GET /Response:
{
"status": "ok",
"service": "Northwestern CS Kiosk API"
}Query (Main Endpoint)
POST /api/queryThis is the primary endpoint for speech integration.
Request Body:
{
"question": "Where is Professor Hammond's office?",
"session_id": "optional-session-id",
"provider": "anthropic"
}Response:
{
"session_id": "default",
"session_title": "Chat – Jan 23, 10:30 AM",
"question": "Where is Professor Hammond's office?",
"answer": "Professor Kristian Hammond's office is located in Mudd 3225.",
"blueprint": "location",
"facts": [...],
"notes": [],
"usage": {
"provider": "anthropic",
"model": "claude-haiku-4-5",
"tokens": 512
},
"action": {
"type": "lookup_location",
"arguments": { "name": "Kristian Hammond" }
}
}Key Fields:
answer- The response text (send to text-to-speech)question- Echo of the input questionblueprint- Which tool was used internallyfacts- Structured data retrievedusage- Token/model metadata
List Providers
GET /api/providersReturns available LLM providers and their configuration status.
Response:
{
"providers": {
"claude": {
"name": "Claude",
"configured": true,
"default_model": "claude-haiku-4-5"
},
"gpt": {
"name": "GPT",
"configured": false,
"note": "Set OPENAI_API_KEY before using this provider."
}
},
"default_provider": "claude"
}Get History
GET /api/history?session_id=defaultReturns conversation history for a session.
Response:
{
"session_id": "default",
"title": "Chat – Jan 23, 10:30 AM",
"history": [
{
"timestamp": 1706012345.123,
"question": "Who is Kristian Hammond?",
"answer": "Professor Kristian Hammond is...",
"blueprint": "person_lookup"
}
]
}List Sessions
GET /api/sessionsReturns all conversation sessions.
Response:
{
"sessions": [
{
"session_id": "default",
"title": "Chat – Jan 23, 10:30 AM",
"created_at": 1706012345.123,
"updated_at": 1706012400.456
}
]
}Integration Example
cURL
curl -X POST "http://localhost:8000/api/query" \
-H "Content-Type: application/json" \
-d '{"question": "Where is Professor Hammond?"}'Python
import requests
response = requests.post(
"http://localhost:8000/api/query",
json={"question": "Where is Professor Hammond?"}
)
data = response.json()
answer = data["answer"] # Send this to text-to-speechJavaScript
const response = await fetch("http://localhost:8000/api/query", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ question: "Where is Professor Hammond?" })
});
const data = await response.json();
const answer = data.answer; // Send this to text-to-speechSpeech Integration Flow
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Microphone │ ──▶ │ STT API │ ──▶ │ Kiosk API │ ──▶ │ TTS API │
│ │ │ (Speech to │ │ /api/query │ │ (Text to │
│ │ │ Text) │ │ │ │ Speech) │
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
│ │ │
▼ ▼ ▼
"Where is {"answer": [Audio]
Prof X?" "Prof X is 🔊
in Mudd..."}Available Query Types
Environment Variables
*At least one API key is required.
Project Structure
kiosk-api/
├── Archive/ # Data files (CSV)
├── backend/
│ ├── data/ # Data loading utilities
│ ├── mcp/ # LLM planner & tool execution
│ ├── providers/ # LLM provider implementations
│ ├── tools/ # Query blueprints
│ ├── main.py # FastAPI application
│ └── responders.py # Response generation
├── .env.example # Environment template
├── requirements.txt # Python dependencies
└── README.md # This file