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.
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.
Quick Start
- Simple Usage
bash pip install praisonai-platformpython 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()) - 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
| Pattern | When to use |
|---|---|
| Context manager | Multiple API calls — reuses connections |
| Standalone client | Single request with a known token |
API Areas
| Area | Key methods |
|---|---|
| Auth | register, login, get_me |
| Workspaces | create_workspace, list_workspaces, add_member |
| Projects | create_project, list_projects, get_project_stats |
| Issues | create_issue, list_issues, update_issue |
| Comments | add_comment, list_comments |
| Agents | create_agent, list_agents, update_agent |
| Labels | create_label, add_label_to_issue, list_issue_labels |
| Dependencies | create_dependency, list_dependencies |
See Platform SDK Client for endpoint-level detail.
Error Handling
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.