Platform Python SDK

Clean public API exports for PraisonAI Platform integration

The Platform Python SDK wraps authentication, workspaces, and issues in a few importable symbols.

python
import os
from praisonaiagents import Agent
from praisonai_platform import PlatformClient, create_app

agent = Agent(
    name="platform-assistant",
    instructions="Help users manage workspace issues.",
)

async with PlatformClient(
    os.getenv("PLATFORM_URL", "http://localhost:8000"),
    token=os.getenv("PLATFORM_TOKEN"),
) as client:
    workspace = await client.create_workspace("My Team")

The user manages team work; the agent creates workspaces and issues via the platform SDK.

Diagram

🤖 Agent

📦 PlatformClient

🌐 Platform API

⚙️ create_app

How It Works

Diagram
PlatformPythonSdkAgentUserPlatformPythonSdkAgentUserRequestProcessResultResponse

Quick Start

  1. Simple Usage

    Install and register a user:

    bash
    pip install praisonai-platform
    python
    import asyncio
    from praisonai_platform import PlatformClient
    
    async def main():
        async with PlatformClient("http://localhost:8000") as client:
            await client.register("user@example.com", "password")
            workspaces = await client.list_workspaces()
            print(workspaces)
    
    asyncio.run(main())
  2. With Configuration

    Deploy the API server and connect with a stored token:

    python
    import os
    from praisonai_platform import PlatformClient, create_app
    
    # Run the server (uvicorn praisonai_platform:app)
    app = create_app()
    
    client = PlatformClient(
        base_url=os.getenv("PLATFORM_URL", "http://localhost:8000"),
        token=os.getenv("PLATFORM_TOKEN"),
    )

How It Works

Diagram
Platform Python SDKAgentUserPlatform Python SDKAgentUserRequestProcess requestResultResponse
ExportPurpose
create_app()FastAPI factory for self-hosted Platform API
PlatformClientAsync HTTP client with JWT handling
__version__Package version string
python
from praisonai_platform import __version__
print(__version__)

Configuration Options

ParameterTypeDefaultDescription
base_urlstr—Platform API base URL
tokenstrNoneJWT bearer token (auto-set after login)

Best Practices

Prefer async context managers

async with PlatformClient(...) reuses a connection pool for multiple calls.

Let login set the token

After register() or login(), the client stores the JWT automatically.

Configure via environment variables

Set PLATFORM_URL and PLATFORM_TOKEN in production — avoid hardcoded URLs.

Check version compatibility

Import __version__ at startup when you depend on specific API behaviour.


Related