The Go SDK is currently in beta. The API surface may change between releases.
phala Go package provides a strongly-typed client for the Phala Cloud API. It handles authentication, automatic retries with exponential backoff, and structured error responses out of the box.
Installation
Requires Go 1.25 or later.Quick Start
Client Creation
NewClient(opts ...Option) (*Client, error)
Creates a new Phala Cloud API client. The API key is resolved from options first, then falls back to the PHALA_CLOUD_API_KEY environment variable. Returns an error if no API key is available.
Configuration Options
Every option is a function passed toNewClient. They follow Go’s functional options pattern, so you can combine as many as you need.
Environment Variables
The client resolves environment variables automatically. If you pass an explicit option, it takes priority over the corresponding environment variable.
Pointer Helpers
Many request structs use pointer fields for optional values. The SDK provides helper functions to make this ergonomic:CVM ID Resolution
The SDK automatically normalizes CVM identifiers before sending them to the API. You can pass any of the following formats to any method that accepts acvmID string:
- UUID (with or without dashes) — dashes are stripped
- 40-char hex app ID —
app_prefix is added - Integer ID, hashed ID, or name — used as-is
Available Methods
Authentication & User
CVM Lifecycle
CVM Configuration
CVM Query
Apps
Workspaces
Nodes, Instance Types, and OS Images
KMS
SSH Keys
Measurement Utilities
See KMS for examples.
Webhook Verification
Related
- Authentication — API key setup and custom headers
- CVM Lifecycle — provisioning, starting, stopping, deleting
- Error Handling — error types and retry logic
- Webhooks — webhook events, signatures, and delivery
- Cloud API Reference — full REST API docs

