Kong AI + API Gateway Hackathon
Objective
This template is produced to give the participants in the Kong AI + Gateway Hackathon a flying start. This template includes a basic infrastructure configuration, so all they need to do is to integrate with Kong Konnect and Opper AI, before starting to build the functionality that they want to demo.
The objective for the hackathon is to explore how to build systems using an AI-powered API Gateway and agents that are specialized to handle different types of requests.
A Starting Point For Your Demo Project
The Kong Gateway connected with a complete API (written in Python) with persistent chats stored in Couchbase, a knowledge base, and a full LLM integration through Opper AI.
A frontend (written in React) that provides a chat interface for users to interact with the API.
A great container-based dev env on Polytope, including hot reload, that makes it easy to iterate and collaborate on your solution. One command and you and all your team members are up and running with the same environment!
While this is a great starting point, we don't want to do all the work for you, so the implementation is intentionally incomplete. Here are some known issues you'll need to address:
The bot is very unhelpful!
The knowledge base is limited and not very useful.
The bot hallucinates a lot! If it can't find the answer in the knowledge base, it just makes stuff up.
Installing Your Demo Project
Make sure you have all of the Cillers System Demo Template prerequisites installed:
Clone the template repo:
git clone https://github.com/Cillers-com/kong-ai-gateway-hackathon.git kong-demo && cd kong-demo
Follow the Kong Konnect integration guide.
Follow the Opper AI integration guide.
Configure Your Kong Services And Routes
Go to your Kong Konnect Gateway Manager: https://cloud.konghq.com/us/gateway-manager/
Add The "api" Service
Click "Gateway Services" in the left sidebar. Click "New gateway service".
Specify http://host.docker.internal:3001 as Full URL, and "api" as Name. Click “Save”.
Click the “Routes” tab. Click “New route”.
Select Specify “/api”, "/docs", "/redoc" and "/openapi.json" as Paths. Click “View Advanced Fields” and uncheck "Strip Path". Click "Save"
Add The "frontend" Service
Click "Gateway Services". Click "New gateway service".
Specify http://host.docker.internal:3002 as Full URL, and "frontend" as Name. Click “Save”.
Click the "Routes" tab and then "New route".
Specify "frontend-route" as Name, "/" as Paths. Click "View Advanced Fields". Uncheck "Strip Path". Click "Save".
Click "Gateway Services". It should now look as follows:
Start Your Demo
Run the following command in your demo project directory:
pt run stack
Open the UI: http://localhost:8000
Start building your solution!
Project Structure
This app has two main components:
The API - A Python FastAPI backend that handles chat session management, knowledge base querying, and Opper AI integration
The UI - A React TypeScript frontend that provides the user interface
The API follows a RESTful design with the following endpoints:
POST /api/chats
- Create a new chat sessionGET /api/chats/{chat_id}
- Get a chat session by IDGET /api/chats/{chat_id}/messages
- Get all messages for a chat sessionPOST /api/chats/{chat_id}/messages
- Add a message to a chat session and get a responseDELETE /api/chats/{chat_id}
- Delete a chat session and all its messages
Example usage:
# Create a new chat session
curl -X POST http://localhost:8000/api/chats -H "Content-Type: application/json" -d '{}'
# Get chat details (replace UUID with the one from previous response)
curl http://localhost:8000/api/chats/550e8400-e29b-41d4-a716-446655440000
# Send a message and get a response
curl -X POST http://localhost:8000/api/chats/550e8400-e29b-41d4-a716-446655440000/messages \
-H "Content-Type: application/json" \
-d '{"content": "What is your return policy?"}'
# Get chat history
curl http://localhost:8000/api/chats/550e8400-e29b-41d4-a716-446655440000/messages
# Search knowledge base
curl 'http://localhost:8000/api/knowledge-base/search?query=warranty'
Last updated