From the project root (/Users/joe/brain/agentic-brain):
# Install with API support
pip install -e ".[api]"
# Or install all dependencies (including dev, api, llm)
pip install -e ".[all]"python3 -c "from agentic_brain.api import app; print('✓ FastAPI API installed successfully')"cd /Users/joe/brain/agentic-brain/src
python3 -m agentic_brain.api.serverServer will start at: http://localhost:8000
cd /Users/joe/brain/agentic-brain
uvicorn agentic_brain.api.server:app --host 0.0.0.0 --port 8000 --reloadcd /Users/joe/brain/agentic-brain
uvicorn agentic_brain.api.server:app --reloadOnce the server is running:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
curl http://localhost:8000/healthcurl -X POST http://localhost:8000/chat \
-H "Content-Type: application/json" \
-d '{"message":"Hello bot!"}'pip install pytest pytest-asyncio httpx# From project root
pytest agentic_brain/api/test_api.py -v
# Run with coverage
pytest agentic_brain/api/test_api.py --cov=agentic_brain.api -v# Install wscat
npm install -g wscat
# Connect to WebSocket
wscat -c ws://localhost:8000/ws/chat
# In the wscat terminal, send JSON:
{"message": "Hello bot!"}Create test_ws.py:
import asyncio
import json
import websockets
async def test():
async with websockets.connect("ws://localhost:8000/ws/chat") as ws:
# Receive connection confirmation
msg = await ws.recv()
print(f"Server: {msg}")
# Send message
await ws.send(json.dumps({"message": "Hello bot!"}))
# Receive response
response = await ws.recv()
print(f"Response: {response}")
asyncio.run(test())Then run:
pip install websockets
python3 test_ws.pyagentic-brain/
├── src/agentic_brain/api/
│ ├── __init__.py # Package exports
│ ├── models.py # Pydantic models
│ ├── server.py # FastAPI application
│ ├── test_api.py # Test suite
│ └── README.md # Full documentation
├── pyproject.toml # Project configuration
└── README.md # Main project README
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Health check |
| POST | /chat |
Send message |
| GET | /session/{id} |
Get session info |
| GET | /session/{id}/messages |
Get session messages |
| DELETE | /session/{id} |
Delete session |
| DELETE | /sessions |
Clear all sessions |
| WS | /ws/chat |
Real-time WebSocket chat |
Solution:
pip install -e ".[api]"Solution - Use a different port:
uvicorn agentic_brain.api.server:app --port 8001Make sure the server is running:
# In another terminal
uvicorn agentic_brain.api.server:app-
Integrate with Chatbot Logic
- Replace the echo responses in
server.pywith actual chatbot logic - Update the
POST /chatendpoint handler - Update the WebSocket message handler
- Replace the echo responses in
-
Add Persistence
- Replace in-memory sessions with database storage
- Consider Redis for caching
- Store message history in PostgreSQL
-
Add Authentication
- Implement JWT token validation
- Add user authentication endpoints
- Restrict session access by user
-
Production Deployment
- Use production ASGI server (Gunicorn + Uvicorn)
- Add HTTPS/SSL certificates
- Configure proper logging
- Set up monitoring and alerting
Apache-2.0 © 2026 Agentic Brain Contributors