AgentOS

Deploy AI agents as production web services

AgentOS deploys agents, teams, and flows as production-ready HTTP APIs with built-in health checks, CORS, and Express integration.

Diagram

Endpoints

Production

Development

🤖 Agent

👥 AgentTeam

🔄 AgentFlow

🚀 AgentOS

/api/chat

/health

/api/agents

Quick Start

  1. Simple Usage
    bash
    npm install praisonai express
  2. With Configuration
    typescript
    import { AgentOS, Agent } from 'praisonai';
    
    const agent = new Agent({
      name: 'assistant',
      instructions: 'You are a helpful assistant'
    });
    
    const app = new AgentOS({
      name: 'My AI App',
      agents: [agent]
    });
    
    await app.serve({ port: 8000 });
  3. Test
    bash
    curl -X POST http://localhost:8000/api/chat \
      -H "Content-Type: application/json" \
      -d '{"message": "Hello!"}'

How It Works

Diagram
AgentAgentOSClientAgentAgentOSClientPOST /api/chatchat(message)responseJSON response
StepDescription
1Client sends HTTP request to AgentOS endpoint
2AgentOS routes to the appropriate agent
3Agent processes the message and returns a response
4AgentOS formats and returns the response as JSON

Configuration Options

typescript
import { AgentOS, Agent } from 'praisonai';

const app = new AgentOS({
  name: 'My AI App',
  agents: [agent],
  teams: [team],      // Optional: AgentTeam instances
  flows: [flow],      // Optional: AgentFlow instances
  config: {
    host: '0.0.0.0',
    port: 8000,
    corsOrigins: ['*'],
    apiPrefix: '/api',
    debug: false,
    timeout: 60
  }
});
OptionTypeDefaultDescription
namestring"PraisonAI App"Application name
agentsAgent[][]Agents to serve
teamsAgentTeam[][]Teams to serve
flowsAgentFlow[][]Flows to serve
config.hoststring"0.0.0.0"Server host
config.portnumber8000Server port
config.corsOriginsstring[]["*"]Allowed CORS origins
config.apiPrefixstring"/api"API route prefix
config.debugbooleanfalseEnable debug mode
config.timeoutnumber60Request timeout (seconds)

API Endpoints

EndpointMethodDescription
/GETApp info (name, status, agent count)
/healthGETHealth check ({ status: 'healthy' })
/api/agentsGETList available agents
/api/chatPOSTChat with an agent
/api/teamsGETList available teams
/api/flowsGETList available flows

Chat Request

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

Chat Response

json
{
  "response": "Hello! How can I help you today?",
  "agent_name": "assistant",
  "session_id": "user-123"
}

Common Patterns

Single Agent

typescript
import { AgentOS, Agent } from 'praisonai';

const agent = new Agent({
  instructions: 'You are a helpful assistant'
});

const app = new AgentOS({ agents: [agent] });
await app.serve();

Multi-Agent

typescript
import { AgentOS, Agent } from 'praisonai';

const researcher = new Agent({ 
  name: 'researcher',
  instructions: 'Research topics' 
});
const writer = new Agent({ 
  name: 'writer',
  instructions: 'Write content' 
});

const app = new AgentOS({
  agents: [researcher, writer],
  name: 'content-team'
});
await app.serve();

With Teams

typescript
import { AgentOS, Agent, AgentTeam } from 'praisonai';

const agent = new Agent({
  instructions: 'You are a helpful assistant'
});

const team = new AgentTeam({
  agents: [agent],
  process: 'sequential'
});

const app = new AgentOS({
  agents: [agent],
  teams: [team]
});
await app.serve();

Custom API Prefix

typescript
const app = new AgentOS({
  agents: [agent],
  config: {
    apiPrefix: '/v1'
  }
});

// Endpoints now at /v1/chat, /v1/agents, etc.

Best Practices

Use environment variables for port

Read port from environment for deployment flexibility.

typescript
await app.serve({
  port: parseInt(process.env.PORT || '8000')
});
Configure CORS for production

Restrict CORS origins in production instead of using ‘*’.

typescript
config: {
  corsOrigins: ['https://yourdomain.com']
}
Stop server gracefully

Use the stop() method for clean shutdown.

typescript
process.on('SIGTERM', async () => {
  await app.stop();
  process.exit(0);
});

Backward Compatibility

typescript
// Both are equivalent
import { AgentOS, AgentApp } from 'praisonai';

const app1 = new AgentOS({ agents: [agent] });
const app2 = new AgentApp({ agents: [agent] });

// They are the same class
console.log(AgentOS === AgentApp); // true

Additional config aliases:

  • managers → teams (deprecated)
  • workflows → flows (deprecated)

Related