Platform SDK Client

Async Python client for the PraisonAI Platform API with connection pooling

PlatformClient gives agents and scripts full CRUD access to workspaces, issues, labels, and agents over the Platform API.

python
import os
from praisonaiagents import Agent
from praisonai_platform.client import PlatformClient

agent = Agent(
    name="platform-bot",
    instructions="Track and update 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")
    issue = await client.create_issue(workspace["id"], "Fix login bug")

The user tracks bugs; the agent uses PlatformClient to log and update workspace issues.

Diagram

🤖 Agent

📦 PlatformClient

🔐 Auth

🏢 Workspaces

🎯 Issues

🏷️ Labels

Quick Start

  1. Simple Usage
    bash
    pip install praisonai-platform
    python
    import asyncio
    from praisonai_platform.client import PlatformClient
    
    async def main():
        async with PlatformClient("http://localhost:8000") as client:
            await client.register("user@example.com", "password123")
            workspace = await client.create_workspace("My Team")
            project = await client.create_project(workspace["id"], "Sprint 1")
            await client.create_issue(
                workspace["id"],
                "Fix login bug",
                project_id=project["id"],
            )
    
    asyncio.run(main())
  2. With Configuration

    Pass an existing token and batch related calls in one session:

    python
    import os
    import asyncio
    from praisonai_platform.client import PlatformClient
    
    async def setup_workspace():
        client = PlatformClient(
            os.getenv("PLATFORM_URL", "http://localhost:8000"),
            token=os.getenv("PLATFORM_TOKEN"),
        )
        workspace = await client.create_workspace("Dev Team")
        await client.add_member(workspace["id"], "user-456", role="admin")
        await client.create_project(workspace["id"], "Q1 Sprint")
    
    asyncio.run(setup_workspace())

How It Works

Diagram
APIPlatformClientAppAPIPlatformClientApploop[Multiple requests]async with PlatformClient()API callpooled HTTP requestJSON responsesession close
PatternWhen to use
Context managerMultiple API calls — reuses connections
Standalone clientSingle request with a known token

API Areas

AreaKey methods
Authregister, login, get_me
Workspacescreate_workspace, list_workspaces, add_member
Projectscreate_project, list_projects, get_project_stats
Issuescreate_issue, list_issues, update_issue
Commentsadd_comment, list_comments
Agentscreate_agent, list_agents, update_agent
Labelscreate_label, add_label_to_issue, list_issue_labels
Dependenciescreate_dependency, list_dependencies

See Platform SDK Client for endpoint-level detail.


Error Handling

python
import httpx
from praisonai_platform.client import PlatformClient

try:
    async with PlatformClient("http://localhost:8000") as client:
        await client.get_workspace("invalid-id")
except httpx.HTTPStatusError as e:
    if e.response.status_code == 404:
        print("Workspace not found")
    elif e.response.status_code == 401:
        print("Authentication required")

Best Practices

Use connection pooling

Keep related calls inside one async with PlatformClient(...) block.

Handle token lifecycle

Call register() or login() once; the client stores the JWT for later requests.

Scope calls to a workspace

Pass workspace_id on every resource method — RBAC enforces membership.

Read config from the environment

Use os.getenv("PLATFORM_URL") and os.getenv("PLATFORM_TOKEN") in production.


Related