AgentOS

Deploy AI agents as production web services

Deploy agents, teams, and flows as production-ready APIs.

Diagram

Endpoints

Production

Development

🤖 Agent

👥 AgentTeam

🔄 AgentFlow

🚀 AgentOS

/api/chat

/health

/docs


Quick Start

  1. Install
    bash
    pip install praisonai[os]
  2. Python Code
    python
    from praisonai import AgentOS
    from praisonaiagents import Agent
    
    app = AgentOS(agents=[
        Agent(instructions="You are a helpful assistant")
    ])
    app.serve(port=8080)
  3. CLI
    bash
    praisonai app --port 8080

What AgentOS Creates

Diagram

AgentOS Server

Features

🔒 CORS

📊 Auto Docs

💬 WebSocket

Routes

GET /

GET /health

GET /api/agents

POST /api/chat

GET /docs

EndpointMethodPurpose
/GETApp status
/healthGETHealth check
/api/agentsGETList agents
/api/chatPOSTChat with agent
/docsGETAPI documentation

Configuration

Diagram

Config Tiers

✅ Defaults

⚙️ Inline

📁 Config Class

Defaults

python
from praisonai import AgentOS
from praisonaiagents import Agent

app = AgentOS(agents=[Agent(instructions="Help me")])
app.serve()  # Port 8000

Inline Options

python
app = AgentOS(
    name="My AI App",
    agents=[agent1, agent2],
    teams=[my_team],
    flows=[my_flow]
)
app.serve(port=9000, reload=True)

Config Class

python
from praisonaiagents import AgentOSConfig

config = AgentOSConfig(
    name="Production App",
    host="0.0.0.0",
    port=8000,
    reload=False,
    cors_origins=["https://myapp.com"],
    api_prefix="/api",
    docs_url="/docs",
    debug=False,
    log_level="info",
    workers=4,
    timeout=60
)

app = AgentOS(agents=[...], config=config)
app.serve()

All Configuration Options

OptionTypeDefaultDescription
namestr"PraisonAI App"Application name
hoststr"0.0.0.0"Host address
portint8000Port number
reloadboolFalseAuto-reload (dev mode)
cors_originslist[str]["*"]Allowed CORS origins
api_prefixstr"/api"API route prefix
docs_urlstr"/docs"API docs URL
openapi_urlstr"/openapi.json"OpenAPI schema URL
debugboolFalseDebug mode
log_levelstr"info"Logging level
workersint1Worker processes
timeoutint60Request timeout (seconds)

CLI Commands

Diagram

praisonai app

–port 8000

–host 0.0.0.0

–config agents.yaml

–reload

–debug

–name ‘My App’

CommandDescription
praisonai appStart with defaults
praisonai app --port 9000Custom port
praisonai app --host 127.0.0.1Custom host
praisonai app --config agents.yamlLoad agents from file
praisonai app --reloadDev mode with auto-reload
praisonai app --debugEnable debug logging
praisonai app --name "My API"Custom app name

YAML Config File

agents.yaml
agents:
  - name: Assistant
    instructions: You are a helpful assistant
    llm: gpt-4o-mini

  - name: Researcher
    instructions: You research topics thoroughly
    llm: gpt-4o
bash
praisonai app --config agents.yaml --port 8080

Architecture

Diagram
LLMAgentAgentOSClientLLMAgentAgentOSClientPOST /api/chatRoute requestProcessResponseResultJSON Response

Deployment Patterns

Single Agent

python
from praisonai import AgentOS
from praisonaiagents import Agent

app = AgentOS(agents=[
    Agent(name="support", instructions="Customer support agent")
])
app.serve(port=8000)

Multiple Agents

python
app = AgentOS(agents=[
    Agent(name="support", instructions="Customer support"),
    Agent(name="sales", instructions="Sales assistance"),
    Agent(name="tech", instructions="Technical help")
])
app.serve()

With Teams

python
from praisonaiagents import Agent, AgentTeam, Task

researcher = Agent(name="researcher", instructions="Research")
writer = Agent(name="writer", instructions="Write")

task1 = Task(description="Research topic", agent=researcher)
task2 = Task(description="Write article", agent=writer, context=[task1])

team = AgentTeam(agents=[researcher, writer], tasks=[task1, task2])

app = AgentOS(teams=[team])
app.serve()

With Flows

python
from praisonaiagents import Agent, AgentFlow

flow = AgentFlow(steps=[
    Agent(instructions="Step 1"),
    Agent(instructions="Step 2")
])

app = AgentOS(flows=[flow])
app.serve()

Chat API Request

bash
curl -X POST http://localhost:8000/api/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello!", "agent_name": "support"}'

Response:

json
{
  "response": "Hello! How can I help you today?",
  "agent_name": "support",
  "session_id": null
}

Best Practices

Use for all production deployments

Even for single agents, AgentOS provides proper API structure, CORS, health checks, and auto-generated docs.

Enable reload only in development

Use --reload during development. Disable in production for better performance.

Configure CORS for security

Replace ["*"] with specific origins in production: cors_origins=["https://myapp.com"]

Use workers for scaling

Increase workers for production: workers=4 (typically 2-4x CPU cores)


Related