Python SDK for Phala Cloud API (sync/async, pydantic, REPL-friendly)
Project description
Phala Cloud Python SDK
Python SDK for Phala Cloud API, aligned with @phala/cloud action surface.
Goals
- Pythonic API (
snake_case, sync-first REPL experience) - Sync + Async parity
- Pydantic request/response validation
- Safe calls (
safe_*) without exceptions
Requirements
- Python >= 3.10
- uv (for development)
Installation
pip install phala-cloud
Quickstart
Sync
from phala_cloud import create_client
client = create_client(api_key="<api-key>")
me = client.get_current_user()
print(me.model_dump())
Async
import asyncio
from phala_cloud import create_async_client
async def main() -> None:
client = create_async_client(api_key="<api-key>")
me = await client.get_current_user()
print(me.model_dump())
await client.aclose()
asyncio.run(main())
Configuration
Environment variables
PHALA_CLOUD_API_KEYPHALA_CLOUD_API_PREFIX(e.g.https://cloud-api.phala.com/api/v1)
Client options
api_keybase_urlversion(2025-10-28/2026-01-21)timeoutheadersuse_cookie_auth
API Style
- Direct methods: raise on HTTP/validation errors
- Safe methods (
safe_*): returnSafeResult - Function-style wrappers available in
phala_cloud.actions
Example:
result = client.safe_get_kms_list()
if result.ok:
print(result.data.items)
else:
print(result.error)
Development
cd python
# Install dependencies
uv sync
# Run tests
make test
# Lint & format
make check
E2E Test
E2E tests cover sync + async, direct + safe styles, and full interface paths.
Required:
PHALA_CLOUD_E2E_API_KEY— your Phala Cloud API key
Optional:
PHALA_CLOUD_E2E_BASE_URL— defaults tohttps://cloud-api.phala.com/api/v1
Run
cd python
PHALA_CLOUD_E2E_API_KEY="<api-key>" make e2e
Or put them in python/.env.test:
PHALA_CLOUD_E2E_API_KEY=<api-key>
# PHALA_CLOUD_E2E_BASE_URL=https://cloud-api.phala.com/api/v1
Then simply:
cd python
make e2e
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file phala_cloud-0.1.2.tar.gz.
File metadata
- Download URL: phala_cloud-0.1.2.tar.gz
- Upload date:
- Size: 84.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ec1a821835ba1add363ac0e34fb9ecccf7906e81f0a04095270a5056e34f1d7
|
|
| MD5 |
d8e090093b5cedefbf727e45f8783c9c
|
|
| BLAKE2b-256 |
43044bf503d98bdaa9650e49300b946fcb5ccef0331f3c34447e7e3a4c0ee5d3
|
Provenance
The following attestation bundles were made for phala_cloud-0.1.2.tar.gz:
Publisher:
release-python.yml on Phala-Network/phala-cloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
phala_cloud-0.1.2.tar.gz -
Subject digest:
7ec1a821835ba1add363ac0e34fb9ecccf7906e81f0a04095270a5056e34f1d7 - Sigstore transparency entry: 1188750228
- Sigstore integration time:
-
Permalink:
Phala-Network/phala-cloud@d53ceae05eae9d88224add64b4a8632fdc21b06c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Phala-Network
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@d53ceae05eae9d88224add64b4a8632fdc21b06c -
Trigger Event:
issue_comment
-
Statement type:
File details
Details for the file phala_cloud-0.1.2-py3-none-any.whl.
File metadata
- Download URL: phala_cloud-0.1.2-py3-none-any.whl
- Upload date:
- Size: 31.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4880de72036ebf23ee2cf58757983d859a67c9612bef6d0d2fbddc6533ce75ae
|
|
| MD5 |
b5983f10c74ce0c38c9a84830157e5c5
|
|
| BLAKE2b-256 |
7b764d13e700e7034864644dcdd040dd9e544e2c210a85a8597ea2a8127899b1
|
Provenance
The following attestation bundles were made for phala_cloud-0.1.2-py3-none-any.whl:
Publisher:
release-python.yml on Phala-Network/phala-cloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
phala_cloud-0.1.2-py3-none-any.whl -
Subject digest:
4880de72036ebf23ee2cf58757983d859a67c9612bef6d0d2fbddc6533ce75ae - Sigstore transparency entry: 1188750237
- Sigstore integration time:
-
Permalink:
Phala-Network/phala-cloud@d53ceae05eae9d88224add64b4a8632fdc21b06c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Phala-Network
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@d53ceae05eae9d88224add64b4a8632fdc21b06c -
Trigger Event:
issue_comment
-
Statement type: