Aegra core API - Self-hosted Agent Protocol server
Actively maintained. Last release 2 days ago, commits in 23 of the last 26 weeks. A safe choice.
pip install aegra-apiaegra-api
Aegra API - Self-hosted Agent Protocol server.
Aegra is an open-source, self-hosted alternative to LangSmith Deployments. This package provides the core API server that implements the Agent Protocol, allowing you to run AI agents on your own infrastructure without vendor lock-in.
Features
- Agent Protocol Compliant: Works with Agent Chat UI, LangGraph Studio, CopilotKit
- Drop-in Replacement: Compatible with the LangGraph SDK
- Self-Hosted: Run on your own PostgreSQL database
- Streaming Support: Real-time streaming of agent responses
- Human-in-the-Loop: Built-in support for human approval workflows
- Scheduled Cron Jobs: Trigger runs on a schedule with timezone support and multi-instance safe claim
- Webhooks: Get a POST with the result when a run or a cron-fired run finishes
- Vector Store: Semantic search capabilities with PostgreSQL
Installation
pip install aegra-api
Quick Start
The easiest way to get started is with the aegra-cli:
# Install the CLI
pip install aegra-cli
# Initialize a new project (interactive)
aegra init
cd <your-project>
# Configure environment
cp .env.example .env
# Add your OPENAI_API_KEY to .env
# Install dependencies and start developing
uv sync
uv run aegra dev
Manual Setup
If you prefer manual setup:
# Install dependencies
pip install aegra-api
# Set environment variables
export POSTGRES_USER=aegra
export POSTGRES_PASSWORD=aegra_secret
export POSTGRES_HOST=localhost
export POSTGRES_DB=aegra
# Run migrations
alembic upgrade head
# Start server
uvicorn aegra_api.main:app --port 2026 --reload
Configuration
aegra.json
Define your agent graphs in aegra.json:
{
"graphs": {
"agent": "./graphs/my_agent/graph.py:graph",
"assistant": {
"path": "./graphs/assistant/graph.py:graph",
"description": "Assistant for support workflows"
}
},
"http": {
"app": "./custom_routes.py:app"
}
}
Graph entries accept either the legacy string import path or an object with a required path and optional .
The description is used for the graph's default assistant and synchronized on startup when it changes. Only system-owned assistants are synchronized; a user-created assistant with the same ID is left unchanged. An omitted or description uses ; an empty string is preserved.