Skip to main content
The Python SDK is currently in beta. The API surface may change between releases.
The 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 like get_current_user() and get_cvm_list().
You can switch versions on an existing client without creating a new one from scratch:

Sync vs. Async

Every method on the sync PhalaCloud client has an identical counterpart on AsyncPhalaCloud. The async version simply requires await.
Both clients support context managers for automatic cleanup:

Safe Methods

Every action method has a safe_* variant that returns a SafeResult instead of raising exceptions. This is useful when you want to handle errors as values rather than control flow.
Read more in Error Handling.

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

See Webhooks for full payload format and delivery behavior.