Skip to main content

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 status
  • GET /agents - List available agents
  • POST /agents/{name}/load - Load a specific agent
  • GET /connections - List available connections
  • GET /connections/{name}/actions - List actions for a specific connection
  • POST /agent/action - Execute a single agent action
  • POST /agent/start - Start the agent loop
  • POST /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.