Python SDK for Phala Cloud API, aligned with @phala/cloud action surface.
- Pythonic API (
snake_case, sync-first REPL experience) - Sync + Async parity
- Pydantic request/response validation
- Safe calls (
safe_*) without exceptions
- Python >= 3.10
- uv (for development)
pip install phala-cloudfrom phala_cloud import create_client
client = create_client(api_key="<api-key>")
me = client.get_current_user()
print(me.model_dump())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())PHALA_CLOUD_API_KEYPHALA_CLOUD_API_PREFIX(e.g.https://cloud-api.phala.com/api/v1)
api_keybase_urlversion(2025-10-28/2026-01-21/2026-05-22)timeoutheadersuse_cookie_auth
- 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)cd python
# Install dependencies
uv sync
# Run tests
make test
# Lint & format
make checkE2E 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
cd python
PHALA_CLOUD_E2E_API_KEY="<api-key>" make e2eOr put them in python/.env.test:
PHALA_CLOUD_E2E_API_KEY=<api-key>
# PHALA_CLOUD_E2E_BASE_URL=https://cloud-api.phala.com/api/v1Then simply:
cd python
make e2eApache-2.0