Deploy Module

Deployment utilities for PraisonAI agents

Deploy Module

The Deploy module provides utilities for deploying PraisonAI agents as APIs and services.

Installation

bash
pip install "praisonai[os]"

Quick Start

python
from praisonaiagents import Agent

agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant."
)

# Deploy as HTTP API
agent.launch(path="/ask", port=8000)

CLI Deployment

bash
# Deploy with CLI
praisonai --deploy

# Deploy with specific port
praisonai --deploy --port 8080

Deployment Options

Single Agent

python
from praisonaiagents import Agent

agent = Agent(instructions="You are helpful.")
agent.launch(
    path="/agent",
    port=8000,
    host="127.0.0.1"  # loopback default; set "0.0.0.0" to expose (requires a token)
)

Multiple Agents

python
from praisonaiagents import Agent, AgentTeam

agents = AgentTeam(agents=[
    Agent(name="Research", instructions="Research topics"),
    Agent(name="Writer", instructions="Write content")
])

agents.launch(path="/team", port=8000)

MCP Server

python
from praisonaiagents import Agent

agent = Agent(instructions="You are helpful.")
agent.launch(port=8080, protocol="mcp")

Configuration

Environment Variables

VariableDescription
PRAISONAI_PORTDefault port (8000)
PRAISONAI_HOSTDefault host (127.0.0.1)
PRAISONAI_LAUNCH_AUTH_TOKENBearer token required by .launch() when set; auto-generated on non-loopback bind
PRAISONAI_API_KEYAPI key for authentication

Launch Options

python
agent.launch(
    path="/endpoint",      # URL path
    port=8000,             # Port number
    host="127.0.0.1",      # Bind address (loopback default; "0.0.0.0" to expose, requires a token)
    debug=False,           # Debug mode
    cors_origins=["*"],    # CORS settings
    api_key="secret",      # Authentication
    protocol="http"        # http or mcp
)

Docker Deployment

dockerfile
FROM python:3.11-slim

WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .
EXPOSE 8000

CMD ["python", "agent.py"]

Cloud Deployment

See deployment guides:

See Also