Skip to main content
Platform Python SDK provides clean public API exports for seamless integration with PraisonAI Platform features.

Quick Start

1

Simple Import

from praisonai_platform import PlatformClient, create_app

# Create FastAPI app
app = create_app()

# Use HTTP client
async with PlatformClient("http://localhost:8000") as client:
    await client.register("user@example.com", "password")
2

With Authentication

from praisonai_platform import PlatformClient

# Client with token
client = PlatformClient(
    base_url="http://localhost:8000",
    token="your-jwt-token"
)

workspaces = await client.list_workspaces()

How It Works

ComponentPurposeUsage
create_app()FastAPI factoryServer deployment
PlatformClientHTTP clientAPI integration
__version__Package versionVersion checking

API Exports

The package exports three main components:
from praisonai_platform import create_app

# Create FastAPI application instance
app = create_app()

# Run with uvicorn
if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)

Client Features

Authentication

Register, login, and manage JWT tokens

Workspaces

Multi-tenant workspace management

Issues

Issue tracking and project management

Agents

AI agent lifecycle management

Common Patterns

Server Deployment

from praisonai_platform import create_app

def deploy_server():
    """Deploy Platform API server"""
    app = create_app()
    
    # Add custom middleware if needed
    # app.add_middleware(...)
    
    return app

# For production
app = deploy_server()

SDK Integration

from praisonai_platform import PlatformClient

class AgentWorkflow:
    def __init__(self, platform_url: str, token: str):
        self.client = PlatformClient(platform_url, token)
    
    async def setup_workspace(self):
        """Create workspace and project"""
        workspace = await self.client.create_workspace("AI Project")
        project = await self.client.create_project(
            workspace["id"], 
            "Agent Tasks"
        )
        return workspace, project

Version Checking

from praisonai_platform import __version__
import sys

def check_compatibility():
    """Ensure compatible Platform SDK version"""
    required = "0.1.0"
    if __version__ < required:
        sys.exit(f"Platform SDK {required}+ required, got {__version__}")

Best Practices

Always use async context managers for HTTP clients to ensure proper cleanup:
async with PlatformClient("http://localhost:8000") as client:
    workspaces = await client.list_workspaces()
# Client automatically closes
Store and reuse JWT tokens for multiple requests:
client = PlatformClient("http://localhost:8000")
auth_data = await client.register("user@example.com", "pass")
# Token is automatically stored in client._token
Wrap API calls in try-catch for HTTP errors:
try:
    workspace = await client.create_workspace("Duplicate Name")
except httpx.HTTPStatusError as e:
    if e.response.status_code == 409:
        print("Workspace name already exists")
Use environment variables for configuration:
import os
from praisonai_platform import PlatformClient

client = PlatformClient(
    base_url=os.getenv("PLATFORM_URL", "http://localhost:8000"),
    token=os.getenv("PLATFORM_TOKEN")
)

Platform Architecture

Complete Platform SDK reference

Authentication Guide

JWT token management