Skip to main content

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_KEY
  • PHALA_CLOUD_API_PREFIX (e.g. https://cloud-api.phala.com/api/v1)

Client options

  • api_key
  • base_url
  • version (2025-10-28 / 2026-01-21 / 2026-05-22)
  • timeout
  • headers
  • use_cookie_auth

API Style

  • Direct methods: raise on HTTP/validation errors
  • Safe methods (safe_*): return SafeResult
  • 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 to https://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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phala_cloud-0.1.3.tar.gz (130.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phala_cloud-0.1.3-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file phala_cloud-0.1.3.tar.gz.

File metadata

  • Download URL: phala_cloud-0.1.3.tar.gz
  • Upload date:
  • Size: 130.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for phala_cloud-0.1.3.tar.gz
Algorithm Hash digest
SHA256 940edcdc8d52464551cc0468bc8832619c435450eeb634537a30549a8838b361
MD5 ab1b5a9ca4fd98a1fa6f78e20e065fcf
BLAKE2b-256 51f196d47bb0365681745729ff2215c60bf8b08f177d8066730e6ca5a520a38e

See more details on using hashes here.

Provenance

The following attestation bundles were made for phala_cloud-0.1.3.tar.gz:

Publisher: release-python.yml on Phala-Network/phala-cloud

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phala_cloud-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: phala_cloud-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 34.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for phala_cloud-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 69b8629c2fb67df42f2db73f5d515c4ab1d7cedc9c64377ff76bc0765482fd08
MD5 d72574cbba92b49f6afd020ed75f7357
BLAKE2b-256 5482e6f538b5e4d27d7eb27e4703179d11f857efff91786bb86e0809442bd417

See more details on using hashes here.

Provenance

The following attestation bundles were made for phala_cloud-0.1.3-py3-none-any.whl:

Publisher: release-python.yml on Phala-Network/phala-cloud

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page