AgentOS
Deploy AI agents as production web services
Deploy agents, teams, and flows as production-ready APIs.
Quick Start
- Install
bash pip install praisonai[os] - 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) - CLI
bash praisonai app --port 8080
What AgentOS Creates
| Endpoint | Method | Purpose |
|---|---|---|
/ | GET | App status |
/health | GET | Health check |
/api/agents | GET | List agents |
/api/chat | POST | Chat with agent |
/docs | GET | API documentation |
Configuration
Defaults
from praisonai import AgentOS
from praisonaiagents import Agent
app = AgentOS(agents=[Agent(instructions="Help me")])
app.serve() # Port 8000Inline Options
app = AgentOS(
name="My AI App",
agents=[agent1, agent2],
teams=[my_team],
flows=[my_flow]
)
app.serve(port=9000, reload=True)Config Class
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
| Option | Type | Default | Description |
|---|---|---|---|
name | str | "PraisonAI App" | Application name |
host | str | "0.0.0.0" | Host address |
port | int | 8000 | Port number |
reload | bool | False | Auto-reload (dev mode) |
cors_origins | list[str] | ["*"] | Allowed CORS origins |
api_prefix | str | "/api" | API route prefix |
docs_url | str | "/docs" | API docs URL |
openapi_url | str | "/openapi.json" | OpenAPI schema URL |
debug | bool | False | Debug mode |
log_level | str | "info" | Logging level |
workers | int | 1 | Worker processes |
timeout | int | 60 | Request timeout (seconds) |
CLI Commands
| Command | Description |
|---|---|
praisonai app | Start with defaults |
praisonai app --port 9000 | Custom port |
praisonai app --host 127.0.0.1 | Custom host |
praisonai app --config agents.yaml | Load agents from file |
praisonai app --reload | Dev mode with auto-reload |
praisonai app --debug | Enable debug logging |
praisonai app --name "My API" | Custom app name |
YAML Config File
agents:
- name: Assistant
instructions: You are a helpful assistant
llm: gpt-4o-mini
- name: Researcher
instructions: You research topics thoroughly
llm: gpt-4opraisonai app --config agents.yaml --port 8080Architecture
Deployment Patterns
Single Agent
from praisonai import AgentOS
from praisonaiagents import Agent
app = AgentOS(agents=[
Agent(name="support", instructions="Customer support agent")
])
app.serve(port=8000)Multiple Agents
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
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
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
curl -X POST http://localhost:8000/api/chat \
-H "Content-Type: application/json" \
-d '{"message": "Hello!", "agent_name": "support"}'Response:
{
"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)