The Python SDK is currently in beta. The API surface may change between releases.
phala-cloud SDK gives you a Pythonic interface to the Phala Cloud API. It ships with both sync and async clients, Pydantic-validated responses, and a safe_* method pattern that lets you handle errors without try/except blocks.
Installation
Requires Python 3.10 or later. The SDK depends on
httpx, pydantic, and dstack-sdk.Quick Start
Client Creation
create_client(**kwargs) / create_async_client(**kwargs)
Factory functions that return a PhalaCloud (sync) or AsyncPhalaCloud (async) instance. Both accept the same configuration options.
Configuration Options
API Versions
The SDK supports two API versions. The version affects response shapes for certain endpoints likeget_current_user() and get_cvm_list().
Sync vs. Async
Every method on the syncPhalaCloud client has an identical counterpart on AsyncPhalaCloud. The async version simply requires await.
Safe Methods
Every action method has asafe_* variant that returns a SafeResult instead of raising exceptions. This is useful when you want to handle errors as values rather than control flow.
Available Actions
Authentication & User
CVM Query
CVM Lifecycle
CVM Configuration
Apps
Workspaces
KMS (Key Management)
SSH Keys
Nodes & Instance Types
Utility Functions
The SDK also exports standalone utility functions for working with CVM configurations:Webhook Verification Example
Related
- Authentication — API key configuration
- CVM Lifecycle — provisioning and managing CVMs
- Error Handling — error classes and safe methods
- Webhooks — webhook events, signatures, and delivery
- Cloud API Reference — full REST API docs

