Server Mode
ZerePy includes a powerful server mode that enables remote control and monitoring of agents through a RESTful API. This allows you to integrate ZerePy agents into larger applications or control them programmatically over HTTP.
Starting the Server
You can start ZerePy in server mode using:
python main.py --server --host 0.0.0.0 --port 8000
The server provides a REST API that exposes all core ZerePy functionality, including:
- Agent management (listing, loading)
- Connection management
- Action execution
- Agent lifecycle control (start/stop)
API Endpoints
Key endpoints include:
GET /
- Server statusGET /agents
- List available agentsPOST /agents/{name}/load
- Load a specific agentGET /connections
- List available connectionsGET /connections/{name}/actions
- List actions for a specific connectionPOST /agent/action
- Execute a single agent actionPOST /agent/start
- Start the agent loopPOST /agent/stop
- Stop the agent loop
Python Client
A Python client is provided for easy integration:
from src.server.client import ZerePyClient
client = ZerePyClient("http://localhost:8000")
# List available agents
agents = client.list_agents()
# Load an agent
client.load_agent("example")
# List connections
connections = client.list_connections()
# Execute an action
client.perform_action(
connection="anthropic",
action="generate-text",
params=["Tell me a joke", "You are a helpful AI assistant"]
)
# Start/stop agent loop
client.start_agent()
client.stop_agent()
Use Cases
Server mode is particularly useful for:
- Building web interfaces for agent management
- Integrating agents into larger applications
- Remote monitoring and control
- Automated testing and deployment
- Building agent networks
Dependencies
Server mode requires additional dependencies which can be installed via:
poetry install --extras server
This installs FastAPI, Uvicorn, and related dependencies needed for the server functionality.