This guide covers setting up and running the AI Agents service locally for development.
- Python 3.13+
- pipenv (recommended) or pip
- PostgreSQL (optional, for persistent sessions)
git clone <repository-url>
cd ai-agents
pipenv install
pipenv shell# Copy environment template
cp env.example .env
# Edit .env with your API keys
# At least one API key is required:
OPENAI_API_KEY=your-openai-key
ANTHROPIC_API_KEY=your-anthropic-key
GOOGLE_API_KEY=your-google-key
# Optional: PostgreSQL for persistent sessions
SESSION_STORE_URI=postgresql://ai_agents_user:ai_agents_password@localhost:5432/ai_agents_session_store# Start the development server
pipenv run uvicorn src.service.main:app --reload --host 0.0.0.0 --port 7001The service will be available at: http://localhost:7001
For persistent session storage, set up PostgreSQL:
cd agent_store_deploy
./setup_local_postgres.sh# Install PostgreSQL (macOS)
brew install postgresql
brew services start postgresql
# Create database and user
createdb ai_agents_session_store
psql ai_agents_session_store -c "CREATE USER ai_agents_user WITH PASSWORD 'ai_agents_password';"
psql ai_agents_session_store -c "GRANT ALL PRIVILEGES ON DATABASE ai_agents_session_store TO ai_agents_user;"pipenv run pytestpipenv run black src/
pipenv run flake8 src/pipenv run mypy src/# Install all dependencies
pipenv install
# Install development dependencies
pipenv install --dev
# Add new dependency
pipenv install package-namecurl http://localhost:7001/health# Test trip planner agent
curl -X POST "http://localhost:7001/api/agents/chat" \
-H "Content-Type: application/json" \
-d '{
"agent_name": "trip_planner_agent",
"user_id": "test-user",
"session_id": "test-session",
"query": {
"source": "New York",
"destination": "Paris"
}
}'- Swagger UI: http://localhost:7001/docs
- ReDoc: http://localhost:7001/redoc
ai-agents/
βββ src/
β βββ agents/ # Agent implementations
β βββ service/ # FastAPI service
β βββ configs/ # Configuration files
β βββ models/ # Data models
βββ agent_store_deploy/ # Database setup scripts
βββ service_cloud_deploy/ # Deployment scripts
βββ postman/ # API testing collection
βββ tests/ # Test files
# Set in .env file
LOG_LEVEL=DEBUG# Logs are written to dev_app.log
tail -f dev_app.log# Connect to local PostgreSQL
psql -h localhost -p 5432 -U ai_agents_user -d ai_agents_session_store
# Check session tables
\dt
SELECT * FROM sessions LIMIT 5;# Kill process using port 7001
lsof -ti:7001 | xargs kill -9- Check if PostgreSQL is running:
brew services list | grep postgresql - Verify connection string in
.env - Check database exists:
psql -l | grep ai_agents_session_store
# Ensure you're in the virtual environment
pipenv shell
# Reinstall dependencies
pipenv install --dev- Verify at least one API key is set in
.env - Check key is valid and has sufficient credits
- Test with a simple curl request
- Sessions stored in memory
- Lost when service restarts
- Good for development and testing
- Sessions persisted to PostgreSQL
- Survive service restarts
- Set
SESSION_STORE_URIin.env
- Main README - High-level architecture
- Heroku Deployment - Production deployment
- Agent Store Deploy - Database setup
- Postman Collection - API testing