Skip to main content
Deploy agents as a local FastAPI server using praisonai deploy run --type api.

Quick Start - CLI

1

Install PraisonAI

pip install praisonai
2

Set API Key

export OPENAI_API_KEY="your-key"
3

Initialize Deploy Config

praisonai deploy init --file agents.yaml --type api
4

Deploy

praisonai deploy run --file agents.yaml --type api
Expected Output:
🚀 Starting deployment...

✅ Deployment successful!
🔗 URL: http://127.0.0.1:8005

Metadata:
  • type: api
  • host: 127.0.0.1
  • port: 8005
  • workers: 1
5

Verify

curl http://127.0.0.1:8005/health

Quick Start - SDK

1

Create Deploy Script

from praisonai.deploy import Deploy, DeployConfig, DeployType
from praisonai.deploy.models import APIConfig

config = DeployConfig(
    type=DeployType.API,
    api=APIConfig(
        host="127.0.0.1",
        port=8005,
        workers=1,
        cors_enabled=True,
        auth_enabled=False,
        reload=False
    )
)

deploy = Deploy(config, "agents.yaml")
result = deploy.deploy()

print(f"URL: {result.url}")
2

Run

python deploy_api.py

Deploy from YAML

from praisonai.deploy import Deploy

# Load config from agents.yaml deploy section
deploy = Deploy.from_yaml("agents.yaml")
result = deploy.deploy()

print(f"Success: {result.success}")
print(f"URL: {result.url}")

agents.yaml with Deploy Config

framework: praisonai
topic: helpful assistant
roles:
  assistant:
    role: Assistant
    goal: Help users with their questions
    backstory: You are a helpful assistant
    tasks:
      help_task:
        description: Answer user questions
        expected_output: Helpful response

deploy:
  type: api
  api:
    host: "127.0.0.1"
    port: 8005
    workers: 1
    cors_enabled: true
    auth_enabled: false
    reload: false

API Config Options

FieldTypeDefaultDescription
hoststring127.0.0.1Server host
portint8005Server port
workersint1Number of worker processes
cors_enabledbooltrueEnable CORS
auth_enabledboolfalseEnable authentication
auth_tokenstringnullAuthentication token
reloadboolfalseEnable auto-reload (dev)

CLI Flags

FlagTypeDefaultDescription
--file, -fstringagents.yamlPath to agents.yaml
--typechoice-Must be api
--backgroundflagfalseRun in background
--jsonflagfalseOutput as JSON

Background Mode

Run the API server in background:
praisonai deploy run --file agents.yaml --type api --background

Deploy Methods (SDK)

MethodDescription
deploy(background=False)Execute deployment
plan()Generate deployment plan without executing
status()Get current deployment status
doctor()Run health checks
destroy(force=False)Destroy/delete deployment

Status & Management

from praisonai.deploy import Deploy

deploy = Deploy.from_yaml("agents.yaml")

# Check status
status = deploy.status()
print(f"State: {status.state}")
print(f"URL: {status.url}")
print(f"Healthy: {status.healthy}")

# Run health checks
report = deploy.doctor()
for check in report.checks:
    print(f"{check.name}: {'' if check.passed else ''} {check.message}")

# Destroy deployment
result = deploy.destroy(force=True)
print(f"Destroyed: {result.success}")

Check Status (CLI)

praisonai deploy status --file agents.yaml
Expected Output:
📊 Checking deployment status...

╭─────────────────────────────────────────────────────────────────────────────╮
│                            Deployment Status                                 │
├─────────────────┬───────────────────────────────────────────────────────────┤
│ Property        │ Value                                                     │
├─────────────────┼───────────────────────────────────────────────────────────┤
│ State           │ RUNNING                                                   │
│ Service Name    │ praisonai-api                                             │
│ Provider        │ api                                                       │
│ URL             │ http://127.0.0.1:8005                                     │
│ Healthy         │ ✅ Yes                                                    │
│ Instances       │ 1/1                                                       │
╰─────────────────┴───────────────────────────────────────────────────────────╯

Stop Server

praisonai deploy destroy --file agents.yaml

Agent.launch() Method

For simple single-agent deployments:
from praisonaiagents import Agent

agent = Agent(instructions="You are a helpful assistant.", llm="gpt-4o-mini")
agent.launch(path="/ask", port=8000)
Output:
🚀 Agent 'Agent' available at http://0.0.0.0:8000
✅ FastAPI server started at http://0.0.0.0:8000
📚 API documentation available at http://0.0.0.0:8000/docs
🔌 Available endpoints: /ask

Agents.launch() Method

For multi-agent deployments:
from praisonaiagents import Agent, AgentTeam

researcher = Agent(name="Researcher", instructions="Research topics", llm="gpt-4o-mini")
writer = Agent(name="Writer", instructions="Write content", llm="gpt-4o-mini")

agents = AgentTeam(agents=[researcher, writer])
agents.launch(path="/content", port=8000)
Output:
🚀 Multi-Agent HTTP API available at http://0.0.0.0:8000/content
📊 Available agents for this endpoint (2): Researcher, Writer
🔗 Per-agent endpoints: /content/researcher, /content/writer
✅ FastAPI server started at http://0.0.0.0:8000
📚 API documentation available at http://0.0.0.0:8000/docs

launch() Parameters

ParameterTypeDefaultDescription
pathstr"/"API endpoint path
portint8000Server port
hoststr"0.0.0.0"Server host
debugboolFalseDebug mode
protocolstr"http""http" or "mcp"

Verify Deployment

# Health check
curl http://localhost:8005/health

# Test endpoint
curl -X POST http://localhost:8005/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello"}'

Troubleshooting

IssueFix
Port in useChange port in agents.yaml or lsof -i :8005
No agents.yamlRun praisonai deploy init --type api
Missing API keyexport OPENAI_API_KEY="your-key"
Server not startingRun praisonai deploy doctor
Missing depspip install "praisonaiagents[os]"
Import errorpip install praisonai